Search in sources :

Example 91 with Result

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

the class ASEjbBCMaxCacheSize method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String beanCache = null;
    String maxCacheSize = null;
    try {
        beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache");
        if (beanCache != null) {
            maxCacheSize = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache/max-cache-size");
            if (maxCacheSize != null) {
                maxCacheSize = maxCacheSize.trim();
                if (maxCacheSize.length() == 0) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB bean-pool] : max-cache-size cannot be empty"));
                } else {
                    try {
                        int cacheValue = Integer.parseInt(maxCacheSize);
                        if (cacheValue <= 1 || cacheValue > Integer.MAX_VALUE) {
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB bean-cache] : max-cache-size should be greater than 1 and less than MAX_INT"));
                        } else {
                            addGoodDetails(result, compName);
                            result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB bean-cache] : max-cache-size is {0}", new Object[] { (new Integer(maxCacheSize)) }));
                        }
                    } catch (NumberFormatException nfex) {
                        Verifier.debug(nfex);
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB bean-pool] : The value {0} for max-pool-size is not a valid Integer number", new Object[] { maxCacheSize }));
                    }
                }
            } else // max-cache-size not defined
            {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB bean-cache] : max-cache-size is element not defined"));
            }
        } else // bean-cache element is not present
        {
            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 the descriptor object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 92 with Result

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

the class ASEjbBCVictimPolicy method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String beanCache = null;
    String victimPolicy = null;
    try {
        beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache");
        if (beanCache != null) {
            victimPolicy = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-cache/victim-selection-policy");
            if (victimPolicy != null) {
                victimPolicy = victimPolicy.trim();
                if (victimPolicy.length() == 0) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB bean-cache] : victim-selection-policy cannot be empty. It has to be either FIFO, NRU or LRU"));
                } else {
                    if (!victimPolicy.equalsIgnoreCase("FIFO") && !victimPolicy.equalsIgnoreCase("NRU") && !victimPolicy.equalsIgnoreCase("LRU")) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB bean-cache] : victim-selection-policy cannot be [{0}]. It should be either FIFO, NRU or LRU [case insensitive]", new Object[] { victimPolicy }));
                    } else {
                        addGoodDetails(result, compName);
                        result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB bean-cache] : victim-selection-policy is {0}", new Object[] { victimPolicy }));
                    }
                }
            } else // victim-selection-policy not defined
            {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB bean-cache] : victim-selection-policy element not defined"));
            }
        } else // bean-cache is 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 the descriptor object"));
    }
    return result;
}
Also used : ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 93 with Result

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

the class ASEjbBPMaxPoolSize method check.

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

Example 94 with Result

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

the class ASEjbBPSteadyPoolSize method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String pool = null;
    String steadyPoolSize = null;
    String maxPoolSize = null;
    try {
        pool = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-pool");
        if (pool != null) {
            steadyPoolSize = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-pool/steady-pool-size");
            if (steadyPoolSize != null) {
                steadyPoolSize = steadyPoolSize.trim();
                if (steadyPoolSize.length() == 0) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB bean-pool] : steady-pool-size cannot be empty"));
                } else {
                    try {
                        int value = Integer.parseInt(steadyPoolSize);
                        if (value < 0 || value > Integer.MAX_VALUE) {
                            addErrorDetails(result, compName);
                            result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB bean-pool] : steady-pool-size cannot be {0}. It should be between 0 and {1}", new Object[] { new Integer(value), new Integer(Integer.MAX_VALUE) }));
                        } else {
                            maxPoolSize = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\"" + descriptor.getName() + "\"]/bean-pool/max-pool-size");
                            int maxPool = 0;
                            if (maxPoolSize != null) {
                                try {
                                    maxPool = Integer.parseInt(maxPoolSize);
                                } catch (NumberFormatException nfe) {
                                    addErrorDetails(result, compName);
                                    result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB bean-pool] : The value {0} for max-pool-size is not a valid Integer number", new Object[] { maxPoolSize }));
                                    return result;
                                }
                                if (value <= maxPool) {
                                    addGoodDetails(result, compName);
                                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB bean-pool] : steady-pool-size is {0} and is less-than/equal-to max-pool-size [{1}]", new Object[] { new Integer(value), new Integer(maxPool) }));
                                } else {
                                    addWarningDetails(result, compName);
                                    result.warning(smh.getLocalString(getClass().getName() + ".warning", "WARNING [AS-EJB bean-pool] : steady-pool-size [{0}]  is greater than max-pool-size[{1}]", new Object[] { new Integer(value), new Integer(maxPool) }));
                                }
                            } else {
                                addGoodDetails(result, compName);
                                result.passed(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB bean-pool] : steady-pool-size is {0}", new Object[] { new Integer(value) }));
                            }
                        }
                    } catch (NumberFormatException nfex) {
                        Verifier.debug(nfex);
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed3", "FAILED [AS-EJB bean-pool] : The value {0} for steady-pool-size is not a valid Integer number", new Object[] { steadyPoolSize }));
                    }
                }
            } else // steady-pool-size not defined
            {
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB bean-pool] : steady-pool-size element not defined"));
            }
        } else // bean-pool not defined
        {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable1", "NOT APPLICABLE [AS-EJB] : bean-pool 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 95 with Result

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

the class ASCmpMappingTest method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        if (descriptor instanceof IASEjbCMPEntityDescriptor) {
            Collection col = null;
            if (getVerifierContext().getJDOException() != null) {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: Exception [ {0} ] while initializing JDOCodeGenerator. Please check your descriptors and mapping files for consistency ", new Object[] { getVerifierContext().getJDOException().getMessage() }));
                return result;
            } else {
                try {
                    JDOCodeGenerator jdc = getVerifierContext().getJDOCodeGenerator();
                    col = jdc.validate((IASEjbCMPEntityDescriptor) descriptor);
                } catch (Exception ex) {
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Exception [ {0} ] when calling JDOCodeGenerator.validate().", new Object[] { ex.getMessage() }));
                    return result;
                }
            }
            if (col.isEmpty()) {
                result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "The mappings for the cmp beans (if any) are correct."));
            } else {
                // collect all the cmpmapping related errors
                String allErrors = null;
                Iterator it = col.iterator();
                while (it.hasNext()) {
                    Exception e = (Exception) it.next();
                    if (!(e instanceof EJBQLException)) {
                        allErrors = e.getMessage() + "\n\n";
                    }
                }
                if (allErrors != null) {
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".parseError", "Error: Entity bean [ {0} ] has the following error(s) [ {1} ].", new Object[] { descriptor.getEjbClassName(), "\n" + allErrors }));
                } else {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.passed(smh.getLocalString(getClass().getName() + ".passed", "The mappings for the cmp beans (if any) are correct."));
                }
            }
        } else {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "Not applicable: Test only applies to container managed EJBs"));
        }
    } catch (Exception e) {
        result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: Exception [ {0} ] when calling JDOCodeGenerator.validate().", new Object[] { e.getMessage() }));
    }
    return result;
}
Also used : IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor) JDOCodeGenerator(com.sun.jdo.spi.persistence.support.ejb.ejbc.JDOCodeGenerator) Iterator(java.util.Iterator) EJBQLException(com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException) Collection(java.util.Collection) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) EJBQLException(com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

Result (com.sun.enterprise.tools.verifier.Result)288 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)212 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)88 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)66 Method (java.lang.reflect.Method)66 Iterator (java.util.Iterator)50 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)28 Set (java.util.Set)26 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)17 Enumeration (java.util.Enumeration)15 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)14 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)14 Field (java.lang.reflect.Field)13 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)10 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)9 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)9 FieldDescriptor (org.glassfish.ejb.deployment.descriptor.FieldDescriptor)9 TagLibDescriptor (com.sun.enterprise.tools.verifier.TagLibDescriptor)7 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)6 EjbReferenceDescriptor (com.sun.enterprise.deployment.EjbReferenceDescriptor)6