QueryMethodTestpublic abstract class QueryMethodTest extends CMPTest Superclass for all finder method test |
Fields Summary |
---|
ComponentNameConstructor | compName |
Methods Summary |
---|
public com.sun.enterprise.tools.verifier.Result | check(EjbCMPEntityDescriptor descriptor)check if a field has been declared in a class
boolean allIsWell = true;
Result result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
if (descriptor.getHomeClassName() != null && !((descriptor.getHomeClassName()).equals("")) &&
descriptor.getRemoteClassName() != null && !((descriptor.getRemoteClassName()).equals(""))) {
allIsWell = commonToBothInterfaces(descriptor.getHomeClassName(),descriptor.getRemoteClassName(),descriptor, result);
}
if(allIsWell == true) {
if (descriptor.getLocalHomeClassName() != null && !((descriptor.getLocalHomeClassName()).equals("")) &&
descriptor.getLocalClassName() != null && !((descriptor.getLocalClassName()).equals(""))) {
allIsWell = commonToBothInterfaces(descriptor.getLocalHomeClassName(),descriptor.getLocalClassName(),descriptor, result);
}
}
if (allIsWell)
result.setStatus(Result.PASSED);
else
result.setStatus(Result.FAILED);
return result;
| private boolean | commonToBothInterfaces(java.lang.String ejbHome, java.lang.String remote, EjbDescriptor descriptor, com.sun.enterprise.tools.verifier.Result result)This method is responsible for the logic of the test. It is called for both local and remote interfaces.
boolean allIsWell = true;
boolean found = false;
String ejbClassName = descriptor.getEjbClassName();
Context context = getVerifierContext();
ClassLoader jcl = context.getClassLoader();
try {
Class ejbClass = Class.forName(ejbClassName, false,
getVerifierContext().getClassLoader());
Method[] methods = Class.forName(ejbHome, false,
getVerifierContext().getClassLoader()).getMethods();
for (int i=0;i<methods.length;i++) {
String methodName = methods[i].getName();
// get the expected return type
String methodReturnType = methods[i].getReturnType().getName();
if (methodName.startsWith("find")) {
found = true;
if (methodReturnType.equals(remote) ||
isSubclassOf(Class.forName(methodReturnType, false,
getVerifierContext().getClassLoader()), "java.util.Collection") ||
isImplementorOf(Class.forName(methodReturnType, false,
getVerifierContext().getClassLoader()), "java.util.Collection")) {
if (!runIndividualQueryTest(methods[i], (EjbCMPEntityDescriptor) descriptor, ejbClass, result))
allIsWell=false;
}
}
}
if (found == false) {
result.addGoodDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.EjbTest.passed",
"Not Applicable : No find methods found",
new Object[] {}));
}
return allIsWell;
} catch (ClassNotFoundException e) {
Verifier.debug(e);
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.failed(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.EjbTest.failedException",
"Error: [ {0} ] class not found.",
new Object[] {descriptor.getEjbClassName()}));
allIsWell= false;
return allIsWell;
}
| protected abstract boolean | runIndividualQueryTest(java.lang.reflect.Method method, EjbCMPEntityDescriptor descriptor, java.lang.Class targetClass, com.sun.enterprise.tools.verifier.Result result)
Run an individual test against a finder method (single or multi)
|
|