Search in sources :

Example 6 with EjbEntityDescriptor

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

the class CmpFieldsDefinedForContainerPersistence method check.

/**
 * Container managed fields must have at least one element for container-managed
 * persistence, and have no container managed fields defined for bean managed
 * persistence test.
 *
 * @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();
    if (descriptor instanceof EjbEntityDescriptor) {
        String persistentType = ((EjbEntityDescriptor) descriptor).getPersistenceType();
        if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistentType)) {
            // RULE:
            // Container managed fields must have at least one element for container-
            // managed persistence, and have no container managed fields defined for
            // bean managed persistence test.
            Set persistentFields = ((EjbCMPEntityDescriptor) descriptor).getPersistenceDescriptor().getCMPFields();
            if (persistentFields.size() >= 1) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "[ {0} ] container managed fields found in [ {1} ]", new Object[] { new Integer(persistentFields.size()).toString(), descriptor.getName() }));
            } else {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: [ {0} ] container managed fields found in [ {1} ]. Container managed fields must have at least one element for container-managed persistence", new Object[] { new Integer(persistentFields.size()).toString(), descriptor.getName() }));
            }
        } else {
            // if (BEAN_PERSISTENCE.equals(persistentType))
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "Expected persistence type [ {0} ], but [ {1} ] bean has persistence type [ {2} ]", new Object[] { EjbEntityDescriptor.CONTAINER_PERSISTENCE, descriptor.getName(), persistentType }));
        }
        return result;
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "[ {0} ] expected {1} bean, but called with {2} bean.", new Object[] { getClass(), "Entity", "Session" }));
        return result;
    }
}
Also used : EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) Set(java.util.Set) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 7 with EjbEntityDescriptor

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

the class CmpFieldsJavaTypesAssigned method check.

/**
 * The Bean Provider must ensure that the Java types assigned to the
 * container-managed fields are restricted to the following: Java primitive
 * types, Java serializable types, and references of enterprise beans' remote
 * or home interfaces.
 *
 * @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();
    if (descriptor instanceof EjbEntityDescriptor) {
        String persistence = ((EjbEntityDescriptor) descriptor).getPersistenceType();
        if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistence)) {
            // this test apply only to 1.x cmp beans
            if (EjbCMPEntityDescriptor.CMP_1_1 != ((EjbCMPEntityDescriptor) descriptor).getCMPVersion()) {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CMPTest.notApplicable3", "Test do not apply to this cmp-version of container managed persistence EJBs"));
                return result;
            }
            boolean oneFailed = false;
            boolean badField = false;
            Iterator itr = ((EjbCMPEntityDescriptor) descriptor).getPersistenceDescriptor().getCMPFields().iterator();
            while (itr.hasNext()) {
                FieldDescriptor nextPersistentField = (FieldDescriptor) itr.next();
                badField = false;
                boolean foundField = false;
                // ensure that the Java types assigned to the container-managed
                // fields are restricted to the following: Java primitive types,
                // Java serializable types, and references of enterprise beans'
                // remote or home interfaces.
                Class c1 = null;
                try {
                    Class c = Class.forName(((EjbEntityDescriptor) descriptor).getEjbClassName(), false, getVerifierContext().getClassLoader());
                    // start do while loop here....
                    do {
                        try {
                            c1 = c;
                            Field f = c.getDeclaredField(nextPersistentField.getName());
                            foundField = true;
                            Class fc = f.getType();
                            if ((RmiIIOPUtils.isValidRmiIDLPrimitiveType(fc)) || (descriptor.getRemoteClassName().equals(fc.getName())) || (descriptor.getHomeClassName().equals(fc.getName())) || (EjbUtils.isValidSerializableType(fc)) || (fc.getName().equals(descriptor.getLocalClassName())) || (fc.getName().equals(descriptor.getLocalHomeClassName()))) {
                                continue;
                            } else {
                                if (!oneFailed) {
                                    oneFailed = true;
                                }
                                badField = true;
                            }
                            if (badField) {
                                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Field [ {0} ] defined within entity bean class [ {1} ] was assigned an invalid type.  Container managed field must be assigned in the entity bean class with Java types restricted to the following: Java primitive types, Java serializable types, and references of enterprise beans' remote or home interfaces.", new Object[] { nextPersistentField.getName(), ((EjbEntityDescriptor) descriptor).getEjbClassName() }));
                            }
                        } catch (NoSuchFieldException e) {
                            foundField = false;
                        }
                    } while (((c = c.getSuperclass()) != null) && (!foundField));
                    if (!foundField) {
                        if (!oneFailed) {
                            oneFailed = true;
                        }
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failedException1", "Error: [ {0} ] field not found within class [ {1} ]", new Object[] { nextPersistentField.getName(), ((EjbEntityDescriptor) descriptor).getEjbClassName() }));
                    }
                } catch (ClassNotFoundException e) {
                    Verifier.debug(e);
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failedException", "Error: [ {0} ] class not found.", new Object[] { ((EjbEntityDescriptor) descriptor).getEjbClassName() }));
                }
                if (!oneFailed) {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "This entity bean class [ {0} ] has assigned [ {1} ] container managed field with valid Java type.", new Object[] { c1.getName(), nextPersistentField.getName() }));
                }
            }
            if (oneFailed) {
                result.setStatus(Result.FAILED);
            } else {
                result.setStatus(Result.PASSED);
            }
            return result;
        } else {
            // if (BEAN_PERSISTENCE.equals(persistence)) {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "Expected [ {0} ] managed persistence, but [ {1} ] bean has [ {2} ] managed persistence.", new Object[] { EjbEntityDescriptor.CONTAINER_PERSISTENCE, descriptor.getName(), persistence }));
            return result;
        }
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "{0} expected {1} bean, but called with {2}.", new Object[] { getClass(), "Entity", "Session" }));
        return result;
    }
}
Also used : Result(com.sun.enterprise.tools.verifier.Result) FieldDescriptor(org.glassfish.ejb.deployment.descriptor.FieldDescriptor) EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) Field(java.lang.reflect.Field) Iterator(java.util.Iterator) EjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)

Example 8 with EjbEntityDescriptor

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

the class CmpFieldsTransient method check.

/**
 * The Bean Provider is responsible for using the cmp-field elements of the
 * deployment descriptor to declare the instance's fields that the Container
 * must load and store at the defined times.
 *
 *  The fields must not be defined in the entity bean class as transient.
 *
 * @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();
    if (descriptor instanceof EjbEntityDescriptor) {
        String persistence = ((EjbEntityDescriptor) descriptor).getPersistenceType();
        if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistence)) {
            // this test apply only to 1.x cmp beans. in cmp 2.x, fields are virtual fields only
            if (EjbCMPEntityDescriptor.CMP_1_1 != ((EjbCMPEntityDescriptor) descriptor).getCMPVersion()) {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CMPTest.notApplicable3", "Test do not apply to this cmp-version of container managed persistence EJBs"));
                return result;
            }
            boolean oneFailed = false;
            boolean badField = false;
            for (Iterator itr = ((EjbCMPEntityDescriptor) descriptor).getPersistenceDescriptor().getCMPFields().iterator(); itr.hasNext(); ) {
                FieldDescriptor nextPersistentField = (FieldDescriptor) itr.next();
                badField = false;
                boolean foundField = false;
                // fields must not be defined in the entity bean class as transient.
                Class c1 = null;
                try {
                    Class c = Class.forName(((EjbEntityDescriptor) descriptor).getEjbClassName(), false, getVerifierContext().getClassLoader());
                    // start do while loop here....
                    do {
                        try {
                            c1 = c;
                            Field f = c.getDeclaredField(nextPersistentField.getName());
                            foundField = true;
                            int modifiers = f.getModifiers();
                            if (!Modifier.isTransient(modifiers)) {
                                continue;
                            } else {
                                if (!oneFailed) {
                                    oneFailed = true;
                                }
                                badField = true;
                            }
                            if (badField) {
                                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Field [ {0} ] defined within entity bean class [ {1} ] is defined as transient.  Container managed field must not be defined in the entity bean class as transient.", new Object[] { nextPersistentField.getName(), c.getName() }));
                            }
                        } catch (NoSuchFieldException e) {
                            foundField = false;
                        }
                    } while (((c = c.getSuperclass()) != null) && (!foundField));
                    if (!foundField) {
                        if (!oneFailed) {
                            oneFailed = true;
                        }
                        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                        result.failed(smh.getLocalString(getClass().getName() + ".failedException1", "Error: [ {0} ] field not found within class [ {1} ]", new Object[] { nextPersistentField.getName(), ((EjbEntityDescriptor) descriptor).getEjbClassName() }));
                    }
                } catch (ClassNotFoundException e) {
                    Verifier.debug(e);
                    if (!oneFailed) {
                        oneFailed = true;
                    }
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failedException", "Error: [ {0} ] class not found.", new Object[] { ((EjbEntityDescriptor) descriptor).getEjbClassName() }));
                }
                if (!oneFailed) {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "This entity bean class [ {0} ] has defined [ {1} ] container managed field as non-transient field.", new Object[] { c1.getName(), nextPersistentField.getName() }));
                }
            }
            if (oneFailed) {
                result.setStatus(Result.FAILED);
            } else {
                result.setStatus(Result.PASSED);
            }
            return result;
        } else {
            // if (BEAN_PERSISTENCE.equals(persistence)) {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "Expected [ {0} ] managed persistence, but [ {1} ] bean has [ {2} ] managed persistence.", new Object[] { EjbEntityDescriptor.CONTAINER_PERSISTENCE, descriptor.getName(), persistence }));
            return result;
        }
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "{0} expected {1} bean, but called with {2}.", new Object[] { getClass(), "Entity", "Session" }));
        return result;
    }
}
Also used : Result(com.sun.enterprise.tools.verifier.Result) FieldDescriptor(org.glassfish.ejb.deployment.descriptor.FieldDescriptor) EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) Field(java.lang.reflect.Field) Iterator(java.util.Iterator) EjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)

Example 9 with EjbEntityDescriptor

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

the class EjbCreateMethodArgs method check.

/**
 * Entity Bean's ejbCreate(...) methods arguments test.
 * Each entity Bean class may define zero or more ejbCreate(...) methods.
 * The number and signatures of a entity Bean's create methods are specific
 * to each EJB class. The method signatures must follow these rules:
 *
 * The method name must be ejbCreate.
 *
 * The methods arguments must be legal types for RMI-IIOP.
 *
 * @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();
    if (descriptor instanceof EjbEntityDescriptor) {
        boolean oneFailed = false;
        int foundAtLeastOne = 0;
        boolean remote_exists = false;
        try {
            VerifierTestContext context = getVerifierContext();
            ClassLoader jcl = context.getClassLoader();
            Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
            // bug fix for 4699227
            if (descriptor.getRemoteClassName() == null || descriptor.getRemoteClassName().equals("")) {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.localinterfaceonly.notapp", "Not Applicable because, EJB [ {0} ] has Local Interfaces only.", new Object[] { descriptor.getEjbClassName() }));
                return result;
            }
            if (descriptor.getRemoteClassName() != null && !descriptor.getRemoteClassName().equals(""))
                remote_exists = true;
            Class[] ejbCreateMethodParameterTypes;
            boolean ejbCreateFound = false;
            boolean isLegalRMIIIOP = false;
            // start do while loop here....
            do {
                Method[] methods = c.getDeclaredMethods();
                for (int i = 0; i < methods.length; i++) {
                    // reset flags from last time thru loop
                    ejbCreateFound = false;
                    isLegalRMIIIOP = false;
                    // The method name must be ejbCreate.
                    if (methods[i].getName().startsWith("ejbCreate")) {
                        foundAtLeastOne++;
                        ejbCreateFound = true;
                        if (remote_exists == true) {
                            // The methods arguments types must be legal types for RMI-IIOP.
                            ejbCreateMethodParameterTypes = methods[i].getParameterTypes();
                            if (RmiIIOPUtils.isValidRmiIIOPParameters(ejbCreateMethodParameterTypes)) {
                                // these method parameters are valid, continue
                                isLegalRMIIIOP = true;
                            }
                        } else
                            // if the ejb has only a local interface
                            isLegalRMIIIOP = true;
                        if (ejbCreateFound && !isLegalRMIIIOP) {
                            oneFailed = true;
                            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".debug1", "For EJB Class [ {0} ] method [ {1} ]", new Object[] { descriptor.getEjbClassName(), methods[i].getName() }));
                            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: An [ {0} ] method was found, but [ {1} ] method has illegal parameter values.   [ {2} ] methods arguments types must be legal types for RMI-IIOP.", new Object[] { methods[i].getName(), methods[i].getName(), methods[i].getName() }));
                            break;
                        }
                    }
                }
                if (oneFailed == true)
                    break;
            } while (((c = c.getSuperclass()) != null) && (foundAtLeastOne == 0));
            if (foundAtLeastOne == 0) {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "[ {0} ] does not declare any ejbCreate(...) methods.", new Object[] { descriptor.getEjbClassName() }));
            }
            if (oneFailed == false && foundAtLeastOne > 0) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.addGoodDetails(smh.getLocalString(getClass().getName() + ".debug1", "For EJB Class [ {0} ]", new Object[] { descriptor.getEjbClassName() }));
                result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "[ {0} ] properly declares ejbCreate<method> method with arguments that are legal types for RMI-IIOP.", new Object[] { descriptor.getEjbClassName() }));
            }
        } catch (ClassNotFoundException e) {
            Verifier.debug(e);
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failedException", "Error: [ {0} ] class not found.", new Object[] { descriptor.getEjbClassName() }));
            oneFailed = true;
        }
        if (oneFailed) {
            result.setStatus(result.FAILED);
        } else if (foundAtLeastOne == 0) {
            result.setStatus(result.NOT_APPLICABLE);
        } else {
            result.setStatus(result.PASSED);
        }
        return result;
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "[ {0} ] expected {1} bean, but called with {2} bean.", new Object[] { getClass(), "Entity", "Session" }));
        return result;
    }
}
Also used : VerifierTestContext(com.sun.enterprise.tools.verifier.VerifierTestContext) Method(java.lang.reflect.Method) Result(com.sun.enterprise.tools.verifier.Result) EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)

Example 10 with EjbEntityDescriptor

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

the class EjbCreateMethodFinal method check.

/**
 * Entity Bean's ejbCreate(...) methods final test.
 * Each entity Bean class may define zero or more ejbCreate(...) methods.
 * The number and signatures of a entity Bean's create methods are specific
 * to each EJB class. The method signatures must follow these rules:
 *
 * The method name must be ejbCreate.
 *
 * The method must not be declared as final.
 *
 * @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();
    if (descriptor instanceof EjbEntityDescriptor) {
        boolean oneFailed = false;
        int foundAtLeastOne = 0;
        try {
            VerifierTestContext context = getVerifierContext();
            ClassLoader jcl = context.getClassLoader();
            Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
            boolean ejbCreateFound = false;
            boolean isFinal = false;
            // start do while loop here....
            do {
                Method[] methods = c.getDeclaredMethods();
                for (int i = 0; i < methods.length; i++) {
                    // reset flags from last time thru loop
                    ejbCreateFound = false;
                    isFinal = false;
                    // The method name must be ejbCreate.
                    if (methods[i].getName().startsWith("ejbCreate")) {
                        foundAtLeastOne++;
                        ejbCreateFound = true;
                        // The method must not be declared as final.
                        int modifiers = methods[i].getModifiers();
                        if (Modifier.isFinal(modifiers)) {
                            isFinal = true;
                        }
                        // method
                        if (ejbCreateFound && isFinal) {
                            oneFailed = true;
                            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".debug1", "For EJB Class [ {0} ] method [ {1} ]", new Object[] { descriptor.getEjbClassName(), methods[i].getName() }));
                            result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: A final [ {0} ] method was found, but [ {1} ] cannot be declared as final.", new Object[] { methods[i].getName(), methods[i].getName() }));
                            break;
                        }
                    }
                }
                if (oneFailed == true)
                    break;
            } while (((c = c.getSuperclass()) != null) && (foundAtLeastOne == 0));
            if (foundAtLeastOne == 0) {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "[ {0} ] does not declare any ejbCreate(...) methods.", new Object[] { descriptor.getEjbClassName() }));
            }
            if (oneFailed == false && foundAtLeastOne > 0) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.addGoodDetails(smh.getLocalString(getClass().getName() + ".debug1", "For EJB Class [ {0} ] ", new Object[] { descriptor.getEjbClassName() }));
                result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "[ {0} ] properly declares non-final ejbCreate<method> method.", new Object[] { descriptor.getEjbClassName() }));
            }
        } catch (ClassNotFoundException e) {
            Verifier.debug(e);
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failedException", "Error: [ {0} ] class not found.", new Object[] { descriptor.getEjbClassName() }));
            oneFailed = true;
        }
        if (oneFailed) {
            result.setStatus(result.FAILED);
        } else if (foundAtLeastOne == 0) {
            result.setStatus(result.NOT_APPLICABLE);
        } else {
            result.setStatus(result.PASSED);
        }
        return result;
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "[ {0} ] expected {1} bean, but called with {2} bean.", new Object[] { getClass(), "Entity", "Session" }));
        return result;
    }
}
Also used : EjbEntityDescriptor(org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor) VerifierTestContext(com.sun.enterprise.tools.verifier.VerifierTestContext) Method(java.lang.reflect.Method) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)100 Result (com.sun.enterprise.tools.verifier.Result)88 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)87 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)49 Method (java.lang.reflect.Method)42 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)18 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)15 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)12 Iterator (java.util.Iterator)12 Field (java.lang.reflect.Field)10 FieldDescriptor (org.glassfish.ejb.deployment.descriptor.FieldDescriptor)9 Set (java.util.Set)8 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)7 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)6 Vector (java.util.Vector)5 Descriptor (org.glassfish.deployment.common.Descriptor)3 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 IASEjbExtraDescriptors (org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors)3 EjbMessageBeanDescriptor (com.sun.enterprise.deployment.EjbMessageBeanDescriptor)2