InterfaceMethodTestpublic abstract class InterfaceMethodTest extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest Superclass for all local/remote interfaces method testing. |
Fields Summary |
---|
static String[] | EJBObjectMethods |
Methods Summary |
---|
public com.sun.enterprise.tools.verifier.Result | check(com.sun.enterprise.deployment.EjbDescriptor descriptor)Run the verifier test against the local or remote interface, get all methods
and delegate actual testing for individual methods to the
runIndividualMethodTest
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (!(descriptor instanceof EjbSessionDescriptor) &&
!(descriptor instanceof EjbEntityDescriptor)) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.homeintf.HomeMethodTest.notApplicable1",
"Test apply only to session or entity beans."));
return result;
}
if(getInterfaceName(descriptor) == null || "".equals(getInterfaceName(descriptor))){
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceTest.notApplicable",
"Not Applicable because, EJB [ {0} ] does not have {1} Interface.",
new Object[] {descriptor.getEjbClassName(), getInterfaceType()}));
return result;
}
try {
Arrays.sort(EJBObjectMethods);
// retrieve the local/remote interface methods
ClassLoader jcl = getVerifierContext().getClassLoader();
Class interfaceClass = Class.forName(getClassName(descriptor), false, jcl);
if (studyInterface(descriptor, interfaceClass, result)) {
result.setStatus(Result.PASSED);
} else {
result.setStatus(Result.FAILED);
}
} catch (ClassNotFoundException e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failedException",
"Error: "+ getInterfaceType()+"interface [ {0} ] does not " +
"exist or is not loadable within bean [ {1} ]",
new Object[] {getClassName(descriptor),descriptor.getName()}));
}
return result;
| private java.lang.String | getClassName(com.sun.enterprise.deployment.EjbDescriptor descriptor)
return getInterfaceName(descriptor);
| protected abstract java.lang.String | getInterfaceName(com.sun.enterprise.deployment.EjbDescriptor descriptor)Methods to get the type of interface: local/remote and the name of the class
| protected abstract java.lang.String | getInterfaceType()
| protected abstract boolean | runIndividualMethodTest(com.sun.enterprise.deployment.EjbDescriptor descriptor, java.lang.reflect.Method method, com.sun.enterprise.tools.verifier.Result result)
run an individual verifier test against a declared method of the
local or remote interface.
| private boolean | studyInterface(com.sun.enterprise.deployment.EjbDescriptor descriptor, java.lang.Class clazz, com.sun.enterprise.tools.verifier.Result result)
study an interface by running an individual test on each method of the
inteface then recursively study all the interfaces this interface extends
boolean allGood = true;
Method [] interfaceMethods = clazz.getDeclaredMethods();
for (Method interfaceMethod : interfaceMethods) {
if (Arrays.binarySearch(EJBObjectMethods, interfaceMethod.getName()) < 0) {
if (!runIndividualMethodTest(descriptor, interfaceMethod,result))
allGood = false;
} // if you found a business method
} // for all local or remote interface methods for the current class
// now all superinterfaces....
for (Class intf : clazz.getInterfaces()) {
if (!studyInterface(descriptor, intf, result))
allGood = false;
}
return allGood;
|
|