1 23 24 package com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2; 25 26 import java.util.*; 27 import com.sun.enterprise.deployment.*; 28 import com.sun.enterprise.tools.verifier.Result; 29 import com.sun.enterprise.tools.verifier.Verifier; 30 import java.lang.ClassLoader ; 31 import com.sun.enterprise.tools.verifier.tests.*; 32 33 40 abstract public class CmrFieldTest extends CMPTest { 41 42 52 protected abstract boolean runIndividualCmrTest(Descriptor entity, RelationRoleDescriptor rrd, Class c, Result r); 53 54 60 public Result check(EjbCMPEntityDescriptor descriptor) { 61 62 Result result = getInitializedResult(); 63 addErrorDetails(result, 64 getVerifierContext().getComponentNameConstructor()); 65 66 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 67 boolean oneFailed = false; 68 boolean found = false; 69 70 Class c = loadEjbClass(descriptor, result); 71 72 if (c!=null) { 73 Set cmrFields = ((EjbCMPEntityDescriptor)descriptor).getPersistenceDescriptor().getRelationships(); 74 Iterator cmrIterator = cmrFields.iterator(); 75 76 if (cmrIterator.hasNext()) { 77 while (cmrIterator.hasNext()) { 78 RelationshipDescriptor cmfDescriptor = (RelationshipDescriptor) cmrIterator.next(); 79 { 80 RelationRoleDescriptor role = cmfDescriptor.getSource(); 82 if (role.getOwner().equals(descriptor) && role.getCMRField()!=null) { 83 found = true; 84 if (!runIndividualCmrTest(descriptor, role, c, result)) { 85 oneFailed = true; 86 } 87 } 88 } 89 { 91 RelationRoleDescriptor role = cmfDescriptor.getSink(); 93 if (role.getOwner().equals(descriptor) && role.getCMRField()!=null) { 94 found = true; 95 if (!runIndividualCmrTest(descriptor, role, c, result)) { 96 oneFailed = true; 97 } 98 } 99 } 100 } 101 if (oneFailed) 102 result.setStatus(Result.FAILED); 103 else if (found == false) { 104 result.addNaDetails(smh.getLocalString 105 ("tests.componentNameConstructor", 106 "For [ {0} ]", 107 new Object [] {compName.toString()})); 108 result.notApplicable(smh.getLocalString 109 ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldTest.notApplicable", 110 "Not Applicable : The EJB has no CMR fields declared", 111 new Object [] {})); 112 } 113 else 114 result.setStatus(Result.PASSED); 115 } 116 else { 117 result.addNaDetails(smh.getLocalString 118 ("tests.componentNameConstructor", 119 "For [ {0} ]", 120 new Object [] {compName.toString()})); 121 result.notApplicable(smh.getLocalString 122 ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldTest.notApplicable", 123 "Not Applicable : The EJB has no CMR fields declared", 124 new Object [] {})); 125 } 126 } 127 return result; 128 } 129 } 130 | Popular Tags |