KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > intf > remoteintf > RemoteInterfaceRmiIIOPException


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.tools.verifier.tests.ejb.intf.remoteintf;
24
25 import com.sun.enterprise.deployment.EjbDescriptor;
26 import com.sun.enterprise.deployment.MethodDescriptor;
27 import com.sun.enterprise.tools.verifier.Result;
28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
29 import com.sun.enterprise.tools.verifier.tests.ejb.RmiIIOPUtils;
30 import com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceMethodTest;
31
32 import java.lang.reflect.Method JavaDoc;
33
34 /**
35  * Remote interface business method throws clause must include the
36  * java.rmi.RemoteException test.
37  * Verify the following:
38  *
39  * The methods defined in this interface must follow the rules for RMI-IIOP.
40  * This means that their throws clause must include the
41  * java.rmi.RemoteException.
42  *
43  */

44 public class RemoteInterfaceRmiIIOPException extends InterfaceMethodTest {
45     
46     /**
47      * <p>
48      * run an individual verifier test against a declared method of the
49      * remote interface.
50      * </p>
51      *
52      * @param descriptor the deployment descriptor for the bean
53      * @param method the method to run the test on
54      * @return true if the test passes
55      */

56     protected boolean runIndividualMethodTest(EjbDescriptor descriptor, Method JavaDoc method, Result result) {
57         
58         Class JavaDoc[] methodExceptionTypes = method.getExceptionTypes();
59         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
60         // The methods arguments types must be legal types for
61
// RMI-IIOP. This means that their exception values must
62
// throw java.rmi.RemoteException
63
// methods must also throw java.rmi.RemoteException
64
if (RmiIIOPUtils.isValidRmiIIOPException(methodExceptionTypes)) {
65             // this is the right exception for method, throws RemoteException
66
addGoodDetails(result, compName);
67             result.addGoodDetails(smh.getLocalString
68                     (getClass().getName() + ".passed",
69                     "[ {0} ] method properly throws java.rmi.RemoteException.",
70                     new Object JavaDoc[] {method.getName()}));
71             return true;
72         } else {
73             addErrorDetails(result, compName);
74             result.addErrorDetails(smh.getLocalString
75                     (getClass().getName() + ".failed",
76                     "Error: [ {0} ] method was found, but does not properly " +
77                     "throw java.rmi.RemoteException.",
78                     new Object JavaDoc[] {method.getName()}));
79             return false;
80         }
81     }
82     protected String JavaDoc getInterfaceName(EjbDescriptor descriptor) {
83         return descriptor.getRemoteClassName();
84     }
85     
86     protected String JavaDoc getInterfaceType() {
87         return MethodDescriptor.EJB_REMOTE;
88     }
89 }
90
Popular Tags