Search in sources :

Example 71 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.

the class RemoteInterfaceRmiIIOPException method runIndividualMethodTest.

/**
 * <p>
 * run an individual verifier test against a declared method of the
 * remote interface.
 * </p>
 *
 * @param descriptor the deployment descriptor for the bean
 * @param method the method to run the test on
 * @return true if the test passes
 */
protected boolean runIndividualMethodTest(EjbDescriptor descriptor, Method method, Result result) {
    Class[] methodExceptionTypes = method.getExceptionTypes();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    // methods must also throw java.rmi.RemoteException
    if (RmiIIOPUtils.isValidRmiIIOPException(methodExceptionTypes)) {
        // this is the right exception for method, throws RemoteException
        addGoodDetails(result, compName);
        result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "[ {0} ] method properly throws java.rmi.RemoteException.", new Object[] { method.getName() }));
        return true;
    } else {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: [ {0} ] method was found, but does not properly " + "throw java.rmi.RemoteException.", new Object[] { method.getName() }));
        return false;
    }
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)

Example 72 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.

the class EjbCreateExists 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();
    Class mbc = loadMessageBeanClass(descriptor, result);
    if (mbc != null) {
        Method m = getMethod(mbc, getMethodName(), null);
        if (m != null) {
            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.passed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateExists.passed", "Message-Drive bean [ {0} ] provide an {1} implementation with no argument", new Object[] { (descriptor).getEjbClassName(), getMethodName() }));
        } else {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateExists.failed", "Error: Message-Drive bean [ {0} ] does not implement an {1} with no arguments", new Object[] { (descriptor).getEjbClassName(), getMethodName() }));
        }
    }
    return result;
}
Also used : Method(java.lang.reflect.Method) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 73 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor in project Payara by payara.

the class EjbCreateReturnType 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();
    Class mbc = loadMessageBeanClass(descriptor, result);
    if (mbc != null) {
        Method m = getMethod(mbc, getMethodName(), null);
        if (m != null) {
            String returnType = m.getReturnType().getName();
            if ("void".equalsIgnoreCase(returnType)) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.passed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateReturnType.passed", "Message-Drive bean [ {0} ] {1} implementation has a void return type", new Object[] { (descriptor).getEjbClassName(), m.getName() }));
            } else {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateReturnType.failed", "Error: Message-Drive bean [ {0} ] {1} return type is [ {1} ]", new Object[] { (descriptor).getEjbClassName(), returnType }));
            }
        } else {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateExists.failed", "Error: Message-Drive bean [ {0} ] does not implement an {1} with no arguments", new Object[] { (descriptor).getEjbClassName(), getMethodName() }));
        }
    }
    return result;
}
Also used : Method(java.lang.reflect.Method) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 74 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor 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;
}
Also used : ContainerTransaction(org.glassfish.ejb.deployment.descriptor.ContainerTransaction) Iterator(java.util.Iterator) Collection(java.util.Collection) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 75 with ComponentNameConstructor

use of com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor 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;
}
Also used : Method(java.lang.reflect.Method) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)237 Result (com.sun.enterprise.tools.verifier.Result)212 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)87 Method (java.lang.reflect.Method)70 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)66 Iterator (java.util.Iterator)40 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)28 Set (java.util.Set)19 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)16 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)15 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)14 Field (java.lang.reflect.Field)13 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)12 Enumeration (java.util.Enumeration)11 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)11 FieldDescriptor (org.glassfish.ejb.deployment.descriptor.FieldDescriptor)9 TagLibDescriptor (com.sun.enterprise.tools.verifier.TagLibDescriptor)7 EjbReferenceDescriptor (com.sun.enterprise.deployment.EjbReferenceDescriptor)6 ResourceReferenceDescriptor (com.sun.enterprise.deployment.ResourceReferenceDescriptor)6 Vector (java.util.Vector)6