FileDocCategorySizeDatePackage
CmpFieldReturnType.javaAPI DocGlassfish v2 API5479Fri May 04 22:33:40 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2

CmpFieldReturnType

public class CmpFieldReturnType extends CmpFieldTest
Container-managed fields declaration test. CMP fields accessor methods should not return local interface type
author
Sheetal Vartak
version

Fields Summary
Constructors Summary
Methods Summary
protected booleanrunIndividualCmpFieldTest(Descriptor entity, Descriptor persistentField, java.lang.Class c, com.sun.enterprise.tools.verifier.Result result)
run an individual verifier test of a declated cmp field of the class

param
entity the descriptor for the entity bean containing the cmp-field
param
f the descriptor for the declared cmp field
param
c the class owning the cmp field
parma
r the result object to use to put the test results in
return
true if the test passed

	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
	String fieldName = persistentField.getName();
	String getMethodName = "get" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
        String setMethodName = "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
        Method getMethod = getMethod(c, getMethodName, null);
        if (getMethod != null) {
	    if (((EjbDescriptor)entity).getLocalClassName() != null) {
		if ((((EjbDescriptor)entity).getLocalClassName()).equals(getMethod.getReturnType().getName())) {
		     result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		    result.addErrorDetails(smh.getLocalString
			        ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmpFieldReturnType.failed",
				"Error : cmp-field accessor method [{0}] cannot return local interface [{1}] ",
				 new Object[] { getMethod.toString(),((EjbDescriptor)entity).getLocalClassName() }));         
		    return false;
		} else {
		     result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		    result.addGoodDetails(smh.getLocalString
			     ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmpFieldReturnType.passed",
			     "cmp-field accessor method [{0}] does not return local interface [{1}]. Test passed.",
		            new Object[] { getMethod.toString(),((EjbDescriptor)entity).getLocalClassName() })); 
		    return true;        
		}
	    } else {
		 result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		result.addGoodDetails(smh.getLocalString
			    ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmpFieldReturnType.failed2",
                            "Not Applicable :  no local interface found.",
		            new Object[] {})); 
		return true; 
	    }
	}else {
	     result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
	    result.addErrorDetails(smh.getLocalString
			    ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmpFieldReturnType.failed1",
                            "Error : cmp-field accessor method [{0}] not found.",
		            new Object[] {getMethodName})); 
	    return false;
	}