Search in sources :

Example 81 with ComponentNameConstructor

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

the class ASEjbMDBResourceAdapter method check.

/**
 * @param descriptor the Enterprise Java Bean deployment descriptor
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    boolean oneFailed = false;
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String value = null;
    int count = 0;
    try {
        count = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter");
        if (count > 0) {
            value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter/resource-adapter-mid");
            if (value == null || value.length() == 0) {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB mdb-resource-adapter] : resource-adapter-mid cannot be empty.", new Object[] { descriptor.getName() }));
            } else {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB mdb-resource-adapter] : resource-adapter-mid is {1}", new Object[] { descriptor.getName(), value }));
            }
            // activation-config
            count = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter/activation-config");
            if (count > 0) {
                count = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter/activation-config/activation-config-property");
                if (count > 0) {
                    for (int i = 1; i <= count; i++) {
                        value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter/activation-config/activation-config-property/activation-config-property-name");
                        if (value == null || value.length() == 0) {
                            oneFailed = true;
                            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB mdb-resource-adapter] : activation-config-property-name cannot be empty.", new Object[] { descriptor.getName() }));
                        } else {
                            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-EJB mdb-resource-adapter] : activation-config-property-name is {1}", new Object[] { descriptor.getName(), value }));
                        }
                        value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/mdb-resource-adapter/activation-config/activation-config-property/activation-config-property-value");
                        if (value == null || value.length() == 0) {
                            oneFailed = true;
                            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.failed(smh.getLocalString(getClass().getName() + ".failed3", "FAILED [AS-EJB mdb-resource-adapter] : activation-config-property-value cannot be empty.", new Object[] { descriptor.getName() }));
                        } else {
                            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                            result.passed(smh.getLocalString(getClass().getName() + ".passed3", "PASSED [AS-EJB mdb-resource-adapter] : activation-config-property-value is {1}", new Object[] { descriptor.getName(), value }));
                        }
                    }
                } else {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed4", "FAILED [AS-EJB mdb-resource-adapter] : activation-config-property is not defined", new Object[] { descriptor.getName() }));
                }
            }
        } else {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : mdb-resource-adapter is not defined."));
        }
    } catch (Exception ex) {
        oneFailed = true;
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create descriptor object"));
    }
    if (oneFailed)
        result.setStatus(Result.FAILED);
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 82 with ComponentNameConstructor

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

the class ASEjbName method check.

/**
 * @param descriptor the Enterprise Java Bean deployment descriptor
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbDescriptor descriptor) {
    boolean oneFailed = false;
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        String ejbName = descriptor.getName();
        if (ejbName.length() == 0) {
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "failed [AS-EJB ejb] : ejb-name cannot not be empty. It should be a valid ejb-name as defined in ejb-jar.xml"));
        } else {
            EjbDescriptor testDesc = descriptor.getEjbBundleDescriptor().getEjbByName(ejbName);
            if (testDesc != null && testDesc.getName().equals(ejbName)) {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB ejb] :  ejb-name is {0} and verified with ejb-jar.xml", new Object[] { ejbName }));
            } else {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB ejb] :  ejb-name {0} is not found in ejb-jar.xml. It should exist in ejb-jar.xml also.", new Object[] { ejbName }));
            }
        }
    } catch (Exception ex) {
        oneFailed = true;
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create descriptor object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) Result(com.sun.enterprise.tools.verifier.Result)

Example 83 with ComponentNameConstructor

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

the class ASEntBeanCmpResource method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        EjbBundleDescriptorImpl ejbBundleDesc = descriptor.getEjbBundleDescriptor();
        ResourceReferenceDescriptor cmpResource = ejbBundleDesc.getCMPResourceReference();
        if (cmpResource != null) {
            // String jndiName = cmpResource.getJndiName();
            String jndiName = getXPathValue("sun-ejb-jar/enterprise-beans/cmp-resource/jndi-name");
            if (jndiName == null || jndiName.length() == 0) {
                // 4698046
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB cmp-resource] : jndi-name cannot be an empty string"));
            } else {
                if (jndiName.startsWith("jdbc/") || jndiName.startsWith("jdo/")) {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB cmp-resource] : jndi-name is {0}", new Object[] { jndiName }));
                } else {
                    // 4698046
                    oneWarning = true;
                    addWarningDetails(result, compName);
                    result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB cmp-resource] : The jndi-name  is {0}, the preferred jndi-name should start with  jdbc/ or jdo/", new Object[] { jndiName }));
                }
            }
            ResourcePrincipal defPrincipal = cmpResource.getResourcePrincipal();
            if (defPrincipal != null) {
                // String name = defPrincipal.getName();
                String name = getXPathValue("sun-ejb-jar/enterprise-beans/cmp-resource/default-resource-principal/name");
                if (name == null || name.length() == 0) {
                    // 4698046
                    oneFailed = true;
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB default-resource-principal] :  name cannot be an empty string"));
                } else {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB default-resource-principal] : name is {0}", new Object[] { name }));
                }
                // String password = defPrincipal.getPassword();
                char[] password = getXPathValueasCharArray("sun-ejb-jar/enterprise-beans/cmp-resource/default-resource-principal/password");
                if (password == null || password.length == 0) {
                    // 4698046
                    oneWarning = true;
                    addWarningDetails(result, compName);
                    result.warning(smh.getLocalString(getClass().getName() + ".warning1", "WARNING [AS-EJB default-resource-principal] : password is an empty string"));
                } else {
                    addGoodDetails(result, compName);
                    result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-EJB default-resource-principal] : password is  {0}", new Object[] { new String(password) }));
                }
                Arrays.fill(password, ' ');
            } else {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB cmp-resource] : default-resource-principal Element not defined"));
            }
            Float specVer = getRuntimeSpecVersion();
            if ((Float.compare(specVer.floatValue(), (new Float("2.1")).floatValue()) >= 0)) {
                // property
                result = testProperty("property", result, "sun-ejb-jar/enterprise-beans/cmp-resource/property", compName, descriptor);
                // schema-generator-properties
                result = testProperty("schema-generator-properties", result, "sun-ejb-jar/enterprise-beans/cmp-resource/schema-generator-properties/property", compName, descriptor);
            }
            if (// 4698046
            oneFailed)
                result.setStatus(Result.FAILED);
            else if (oneWarning)
                result.setStatus(Result.WARNING);
        } else {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB enterprise-beans] : cmp-resource element is not defined"));
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
    }
    return result;
}
Also used : ResourcePrincipal(com.sun.enterprise.deployment.ResourcePrincipal) ResourceReferenceDescriptor(com.sun.enterprise.deployment.ResourceReferenceDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 84 with ComponentNameConstructor

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

the class ASEjbBCCacheIdleTimeout method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String beanCache = null;
    String idleTimeout = null;
    try {
        beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache");
        if (beanCache != null) {
            try {
                idleTimeout = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache/cache-idle-timeout-in-seconds");
                if (idleTimeout != null) {
                    idleTimeout = idleTimeout.trim();
                    if (idleTimeout.length() == 0) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB bean-cache] : cache-idle-timeout-in-seconds cannot be empty. It should be between 0 and {0}", new Object[] { new Long(Long.MAX_VALUE) }));
                    } else {
                        long value = new Integer(idleTimeout).longValue();
                        if (value < 0 || value > Long.MAX_VALUE) {
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB bean-cache] : cache-idle-timeout-in-seconds cannot be {0}. It should be between 0 and {1}", new Object[] { new Long(value), new Long(Long.MAX_VALUE) }));
                        } else {
                            addGoodDetails(result, compName);
                            result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB bean-cache] : cache-idle-timeout-in-seconds is [{0}]", new Object[] { new Long(value) }));
                        }
                    }
                } else // idle-timeout-in-seconds not defined
                {
                    addNaDetails(result, compName);
                    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB bean-cache] : cache-idle-timeout-in-seconds element not defined"));
                }
            } catch (NumberFormatException nfex) {
                Verifier.debug(nfex);
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB bean-cache] : [{0}] is not a valid Long number", new Object[] { idleTimeout }));
            }
        } else // bean-cache element not defined
        {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create an descriptor object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 85 with ComponentNameConstructor

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

the class ASEjbBCRemovalTimeout method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String beanCache = null;
    String removeTime = null;
    try {
        beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache");
        if (beanCache != null) {
            removeTime = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache/removal-timeout-in-seconds");
            if (removeTime != null) {
                try {
                    removeTime = removeTime.trim();
                    if (removeTime.length() == 0) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB bean-cache] : removal-timeout-in-seconds cannot be empty. It should be between 0 and {0}", new Object[] { new Long(Long.MAX_VALUE) }));
                    } else {
                        long value = new Integer(removeTime).longValue();
                        if (value < 0 || value > Long.MAX_VALUE) {
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB bean-cache] : removal-timeout-in-seconds cannot be {0}. It should be between 0 and {1}", new Object[] { new Long(value), new Long(Long.MAX_VALUE) }));
                        } else {
                            addGoodDetails(result, compName);
                            result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB bean-cache] : removal-timeout-in-seconds is {0}", new Object[] { new Long(value) }));
                        }
                    }
                } catch (NumberFormatException nfex) {
                    Verifier.debug(nfex);
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB bean-cache] : [{0}] is not a valid Long number", new Object[] { removeTime }));
                }
            } else // removal-timeout not defined
            {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB bean-cache] : removal-timeout-in-seconds element not defined"));
            }
        } else // bean-cache not defined
        {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create an descriptor object"));
    }
    return result;
}
Also used : 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