FileDocCategorySizeDatePackage
CmpFieldsDefinedForContainerPersistence.javaAPI DocGlassfish v2 API5649Fri May 04 22:33:38 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp

CmpFieldsDefinedForContainerPersistence

public class CmpFieldsDefinedForContainerPersistence extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
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.

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(EjbDescriptor descriptor)
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
Result the results for this assertion


	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;
	}