run an individual test against a declared ejbSelect method
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
// We don't use getQueryFor to free ourselfves from classloader issues.
Set set = descriptor.getPersistenceDescriptor().getQueriedMethods();
Iterator iterator = set.iterator();
while(iterator.hasNext()) {
MethodDescriptor queryMethod = (MethodDescriptor) iterator.next();
if (queryMethod.getName().equals(m.getName())) {
Class mParms[] = m.getParameterTypes();
String queryParms[] = queryMethod.getParameterClassNames();
if (queryParms != null) {
if (queryParms.length == mParms.length) {
boolean same = true;
for (int i=0;i<mParms.length;i++) {
if (!mParms[i].getName().equals(queryParms[i]))
same=false;
}
if (same) {
QueryDescriptor qd = descriptor.getPersistenceDescriptor().getQueryFor(queryMethod);
String query = qd.getQuery();
if (query == null && qd.getSQL()==null) {
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodQL.failed2",
"Error : [ {0} ] EJB-QL query and description are null",
new Object[] {m.getName()}));
return false;
} else {
if (query==null) {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodQL.passed1",
"Description for [ {0} ] is provided",
new Object[] {m.getName()}));
return true;
}
if (query.toUpperCase().indexOf("SELECT")==-1) {
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodQL.failed2",
"Error : EJB-QL query for method [ {0} is null",
new Object[] {m.getName()}));
return false;
} else {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodQL.passed2",
"EJB-QL query for [ {0} ] is correct",
new Object[] {m.getName()}));
return true;
}
}
}
}
}
else if (mParms.length == 0) {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodQL.passed3",
"No EJB-QL query found",
new Object[] {}));
return true;
} else {
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodQL.failed2",
"Error : EJB-QL query for method [ {0} is null",
new Object[] {m.getName()}));
return false;
}
}
}
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodQL.failed1",
"Error : [ {0} ] does not have a XML query element associated",
new Object[] {m.getName()}));
return false;