Search in sources :

Example 1 with EjbMessageBeanDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor 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;
    }
}
Also used : EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) Result(com.sun.enterprise.tools.verifier.Result)

Example 2 with EjbMessageBeanDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor in project Payara by payara.

the class ASEjbJMSDurableSubscriptionName method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFailed = false;
    try {
        EjbMessageBeanDescriptor msgBeanDesc = (EjbMessageBeanDescriptor) descriptor;
        String jmsDurableName = msgBeanDesc.getDurableSubscriptionName();
        if (jmsDurableName != null) {
            if (jmsDurableName.length() == 0) {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB ejb] : jms-durable-subscription-name cannot be an empty string value"));
            } else {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB ejb] : jms-durable-subscription-name is {0}", new Object[] { jmsDurableName }));
            }
        } else {
            if (descriptor instanceof EjbMessageBeanDescriptor) {
                if (msgBeanDesc.hasTopicDest() && msgBeanDesc.hasDurableSubscription()) {
                    boolean failed = false;
                    int count = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter");
                    if (count > 0) {
                        String value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter/resource-adapter-mid");
                        if (value == null || value.length() == 0) {
                            failed = true;
                        }
                    } else {
                        failed = true;
                    }
                    if (failed) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB ejb] : jms-durable-subscription-name should be defined for an MDB with" + " destination type Topic and Durable subscription type"));
                    }
                } else {
                    addNaDetails(result, compName);
                    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : jms-durable-subscription-name element is not defined"));
                }
            } else {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : jms-durable-subscription-name element is not defined"));
            }
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create a descriptor object"));
    }
    return result;
}
Also used : EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 3 with EjbMessageBeanDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor in project Payara by payara.

the class ASEjbJMSMaxMessagesLoad method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        IASEjbExtraDescriptors iasEjbDescriptor = descriptor.getIASEjbExtraDescriptors();
        int value = iasEjbDescriptor.getJmsMaxMessagesLoad();
        Integer jmsMaxMsgs = new Integer(value);
        if (jmsMaxMsgs != null) {
            if (value < 1 || value > Integer.MAX_VALUE) {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB ejb] : {0} is not a valid value for jms-max-messages-load. It should be " + '\n' + "between 0 and MAX_INT", new Object[] { new Integer(value) }));
            } else {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB ejb] : jms-max-messages-load is {0}", new Object[] { jmsMaxMsgs }));
            }
        } else {
            if (descriptor instanceof EjbMessageBeanDescriptor) {
                // <addition author="irfan@sun.com" [bug/rfe]-id="4724447" >
                // Change in message output ms->jms //
                addWarningDetails(result, compName);
                result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB ejb] : jms-max-messages-load should be defined for MDBs"));
            } else {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : jms-max-messages-load element is not defined"));
            }
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create a descriptor object"));
    }
    return result;
}
Also used : EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) IASEjbExtraDescriptors(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 4 with EjbMessageBeanDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor in project Payara by payara.

the class MDBInheritsMDB method check.

public Result check(EjbMessageBeanDescriptor descriptor) {
    try {
        ClassLoader cl = getVerifierContext().getClassLoader();
        Class ejbCls = Class.forName(descriptor.getEjbClassName(), false, cl);
        Set<EjbDescriptor> descrptors = descriptor.getEjbBundleDescriptor().getEjbs();
        for (EjbDescriptor ejbDescriptor : descrptors) {
            if (!(ejbDescriptor instanceof EjbMessageBeanDescriptor))
                continue;
            if (descriptor.getEjbClassName().equals(ejbDescriptor.getEjbClassName()))
                continue;
            Class mdbCls = null;
            try {
                mdbCls = Class.forName(ejbDescriptor.getEjbClassName(), false, cl);
            } catch (ClassNotFoundException e) {
                // ignore as this error will be caught by other tests
                continue;
            }
            if (mdbCls.isAssignableFrom(ejbCls)) {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Message bean [ {0} ] inherits other message bean [ {1} ]", new Object[] { ejbCls.getName(), mdbCls.getName() }));
            }
        }
    } catch (ClassNotFoundException e) {
        // ignore as this error will be caught by other tests
        logger.fine(descriptor.getEjbClassName() + " Not found");
    }
    if (result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid Message bean [ {0} ]", new Object[] { descriptor.getEjbClassName() }));
    }
    return result;
}
Also used : EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Example 5 with EjbMessageBeanDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor in project Payara by payara.

the class EjbMethodIntfElement method check.

/**
 * The method-intf element must be one of the following "Remote" or "Home" or "LocalHome" or "Local".
 *
 * @param descriptor the Enterprise Java Bean deployment descriptor
 *
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    // method-intf don't make sense for messagedriven bean
    if (descriptor instanceof EjbMessageBeanDescriptor) {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "There are no <method-intf> elements within this bean [ {0} ]", new Object[] { descriptor.getName() }));
        return result;
    }
    // <ejb-class>verifier.ejb.hello.BogusEJB...
    try {
        boolean na = false;
        boolean na1 = false;
        boolean oneFailed = false;
        if (!descriptor.getMethodContainerTransactions().isEmpty()) {
            for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements(); ) {
                MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
                String methodIntf = methodDescriptor.getEjbClassSymbol();
                if (methodIntf == null) {
                    // || methodIntf.equals("")
                    continue;
                }
                // Home Remote LocalHome Local ServiceEndpoint
                if (!((methodIntf.equals(MethodDescriptor.EJB_REMOTE)) || (methodIntf.equals(MethodDescriptor.EJB_HOME)) || (methodIntf.equals(MethodDescriptor.EJB_LOCALHOME)) || (methodIntf.equals(MethodDescriptor.EJB_LOCAL)) || (methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) || (methodIntf.length() == 0))) {
                    // The method-intf element must be one of the following "Remote" or "Home"
                    // if (!((methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE))  ||
                    // (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME)) ||
                    // (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) ||
                    // (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) ||
                    // (methodDescriptor.getEjbClassSymbol().length()==0))) {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: Container transaction method [ {0} ] method-intf element [ {1} ] must be one of the following: [ {2} ] or [ {3} ] or [ {4} ] or [ {5} ]  within bean [ {6} ]", new Object[] { methodDescriptor.getName(), methodDescriptor.getEjbClassSymbol(), MethodDescriptor.EJB_REMOTE.toString(), MethodDescriptor.EJB_HOME, MethodDescriptor.EJB_LOCAL, MethodDescriptor.EJB_LOCALHOME, descriptor.getName() }));
                } else {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "Container Transaction method [ {0} ] method-intf element [ {1} ] is one of the following:  [ {2} ] or [ {3} ] or [ {4} ] or [ {5} ]  within bean [ {6} ]", new Object[] { methodDescriptor.getName(), methodDescriptor.getEjbClassSymbol(), MethodDescriptor.EJB_REMOTE, MethodDescriptor.EJB_HOME, MethodDescriptor.EJB_LOCAL, MethodDescriptor.EJB_LOCALHOME, descriptor.getName() }));
                }
            }
        } else {
            na = true;
        }
        Map permissionedMethods = descriptor.getPermissionedMethodsByPermission();
        if (permissionedMethods.size() > 0) {
            for (Iterator e = permissionedMethods.keySet().iterator(); e.hasNext(); ) {
                MethodPermission nextPermission = (MethodPermission) e.next();
                Set permissionedMethodsForRole = (HashSet) permissionedMethods.get(nextPermission);
                if (permissionedMethodsForRole != null) {
                    Set convertedPermissionedMethods = new HashSet();
                    for (Iterator itr = permissionedMethodsForRole.iterator(); itr.hasNext(); ) {
                        MethodDescriptor methodDescriptor = (MethodDescriptor) itr.next();
                        String methodIntf = methodDescriptor.getEjbClassSymbol();
                        if (methodIntf == null) {
                            // || methodIntf.equals("")
                            continue;
                        }
                        // Home Remote LocalHome Local ServiceEndpoint
                        if (!((methodIntf.equals(MethodDescriptor.EJB_REMOTE)) || (methodIntf.equals(MethodDescriptor.EJB_HOME)) || (methodIntf.equals(MethodDescriptor.EJB_LOCALHOME)) || (methodIntf.equals(MethodDescriptor.EJB_LOCAL)) || (methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) || (methodIntf.length() == 0))) {
                            // The method-intf element must be one of the following "Remote" or "Home"
                            // if (!((methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_REMOTE))  ||
                            // (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_HOME)) ||
                            // (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCAL)) ||
                            // (methodDescriptor.getEjbClassSymbol().equals(MethodDescriptor.EJB_LOCALHOME)) ||
                            // (methodDescriptor.getEjbClassSymbol().length()==0))) {
                            oneFailed = true;
                            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed1", "Error: Method permissions method [ {0} ] method-intf element [ {1} ] must be one of the interfaces of the bean [ {2} ]", new Object[] { methodDescriptor.getName(), methodDescriptor.getEjbClassSymbol(), descriptor.getName() }));
                        } else {
                            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed1", "Method permissions method [ {0} ] method-intf element [ {1} ] is one of the interfaces of the  bean [ {2} ]", new Object[] { methodDescriptor.getName(), methodDescriptor.getEjbClassSymbol(), descriptor.getName() }));
                        }
                    }
                }
            }
        } else {
            na1 = true;
        }
        if (oneFailed) {
            result.setStatus(Result.FAILED);
        } else if (na && na1) {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "There are no <method-intf> elements within this bean [ {0} ]", new Object[] { descriptor.getName() }));
        } else {
            result.setStatus(Result.PASSED);
        }
        return result;
    } catch (Throwable t) {
        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.failed(smh.getLocalString(getClass().getName() + ".failedException", "Error: [ {0} ] does not contain class [ {1} ] within bean [ {2} ]", new Object[] { descriptor.getName(), t.getMessage(), descriptor.getName() }));
        return result;
    }
}
Also used : Enumeration(java.util.Enumeration) Set(java.util.Set) HashSet(java.util.HashSet) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) MethodPermission(com.sun.enterprise.deployment.MethodPermission) Result(com.sun.enterprise.tools.verifier.Result) EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) Iterator(java.util.Iterator) Map(java.util.Map) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) HashSet(java.util.HashSet)

Aggregations

EjbMessageBeanDescriptor (org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor)10 Result (com.sun.enterprise.tools.verifier.Result)5 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)4 IASEjbExtraDescriptors (org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors)2 EjbIORConfigurationDescriptor (com.sun.enterprise.deployment.EjbIORConfigurationDescriptor)1 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)1 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)1 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)1 MethodPermission (com.sun.enterprise.deployment.MethodPermission)1 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)1 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 XMLElement (com.sun.enterprise.deployment.node.XMLElement)1 EjbRefNode (com.sun.enterprise.deployment.node.runtime.EjbRefNode)1 MessageDestinationRefNode (com.sun.enterprise.deployment.node.runtime.MessageDestinationRefNode)1 ResourceEnvRefNode (com.sun.enterprise.deployment.node.runtime.ResourceEnvRefNode)1 ResourceRefNode (com.sun.enterprise.deployment.node.runtime.ResourceRefNode)1 RuntimeDescriptorNode (com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode)1 ServiceRefNode (com.sun.enterprise.deployment.node.runtime.ServiceRefNode)1 WebServiceEndpointRuntimeNode (com.sun.enterprise.deployment.node.runtime.WebServiceEndpointRuntimeNode)1