use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.
the class HasValidMethodDescriptor method check.
/**
* Run a verifier test against an individual declared message
* drive bean component
*
* @param descriptor the Enterprise Java Bean deployment descriptor
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbMessageBeanDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor.getTransactionType().equals(EjbDescriptor.CONTAINER_TRANSACTION_TYPE)) {
// returns the Message Listener methods and "ejbTimeout" if the bean is a
// TimedObject.
Collection methods = descriptor.getTransactionMethodDescriptors();
if (methods.size() == 0) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "Message-driven bean [ {0} ] does not define any method", new Object[] { descriptor.getName() }));
return result;
}
Iterator iterator = methods.iterator();
while (iterator.hasNext()) {
MethodDescriptor method = (MethodDescriptor) iterator.next();
if (descriptor.isTimedObject() && (method.getName()).equals("ejbTimeout"))
continue;
ContainerTransaction txAttr = descriptor.getContainerTransactionFor(method);
if (txAttr == null) {
if (getVerifierContext().getJavaEEVersion().compareTo(SpecVersionMapper.JavaEEVersion_5) < 0) {
// transaction attribute is not specified for method.
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed4", "Error : Message-driven bean [ {0} ] method definition [ {1} ] does not have a valid container transaction descriptor.", new Object[] { descriptor.getName(), method.getName() }));
}
// default transaction attr in EJB 3.0 is REQUIRED
continue;
}
String ta = txAttr.getTransactionAttribute();
if (ContainerTransaction.REQUIRED.equals(ta) || ContainerTransaction.NOT_SUPPORTED.equals(ta)) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Message-driven bean [ {0} ] method definition [ {1} ] in assembly-descriptor is correct", new Object[] { descriptor.getName(), method.getName() }));
} else {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed3", "Error : Message-driven bean [ {0} ] method definition [ {1} ] transaction attribute must be Required or NotSupported", new Object[] { descriptor.getName(), method.getName() }));
}
}
return result;
} else {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable2", "Message-driven bean [ {0} ] does not use container-managed transaction", new Object[] { descriptor.getName() }));
}
return result;
}
use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.
the class ImplementsMessageDrivenBean method check.
/**
* Run a verifier test against an individual declared message
* drive bean component
*
* @param descriptor the Enterprise Java Bean deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbMessageBeanDescriptor descriptor) {
Result result = getInitializedResult();
Class mbc = loadMessageBeanClass(descriptor, result);
testImplementationOf(mbc, "javax.ejb.MessageDrivenBean", result);
return result;
}
use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.
the class MessageBeanTest method check.
/**
* Container-managed persistent fields test, iterates over all declared
* cmp fields and invoke the runIndividualCmpFieldTest nethod
*
* @param descriptor the Enterprise Java Bean deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
if (descriptor instanceof EjbMessageBeanDescriptor) {
return check((EjbMessageBeanDescriptor) descriptor);
} else {
Result result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.MessageBeanTest.notApplicable", "Test apply only to message-driven Bean components"));
return result;
}
}
use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.
the class MessageListenerMethodModifiers method check.
public Result check(EjbMessageBeanDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
ClassLoader cl = getVerifierContext().getClassLoader();
try {
Class intfCls = Class.forName(descriptor.getMessageListenerType(), false, cl);
Class ejbCls = Class.forName(descriptor.getEjbClassName(), false, cl);
Method[] intfMethods = intfCls.getMethods();
for (Method method : intfMethods) {
for (Method ejbMethod : ejbCls.getMethods()) {
// if matching method is found then check the assertion
if (MethodUtils.methodEquals(ejbMethod, method)) {
if (Modifier.isFinal(ejbMethod.getModifiers()) || Modifier.isStatic(ejbMethod.getModifiers())) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Wrong method [ {0} ]", new Object[] { ejbMethod }));
}
break;
}
}
// another test will report failure if listener method is not found
}
}// will be caught in other tests
catch (ClassNotFoundException e) {
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid message listener method(s)."));
}
return result;
}
use of com.sun.enterprise.tools.verifier.Result in project Payara by payara.
the class RemoteExceptionNotThrown method check.
public Result check(EjbMessageBeanDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
ClassLoader cl = getVerifierContext().getClassLoader();
try {
Method[] methods = descriptor.getMessageListenerInterfaceMethods(cl);
for (int i = 0; i < methods.length; i++) {
if (containsRemote(methods[i].getExceptionTypes())) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Method [ {0} ] throws RemoteException", new Object[] { methods[i] }));
}
}
} catch (NoSuchMethodException e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed1", "[ {0} ]", new Object[] { e.getMessage() }));
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid message listener method(s)."));
}
return result;
}
Aggregations