1 23 package com.sun.enterprise.tools.verifier.tests.ejb.entity; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.util.*; 27 import com.sun.enterprise.deployment.*; 28 import com.sun.enterprise.tools.verifier.*; 29 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 38 public class UniqueAbstractSchemaName extends EjbTest implements EjbCheck { 39 40 41 49 public Result check(EjbDescriptor descriptor) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 boolean oneFailed = false; 54 String abstractSchema = null; 55 56 if (descriptor instanceof EjbEntityDescriptor) { 57 if (((EjbEntityDescriptor)descriptor).getPersistenceType().equals(EjbEntityDescriptor.CONTAINER_PERSISTENCE)) { 58 59 if (((EjbCMPEntityDescriptor) descriptor).getCMPVersion()==EjbCMPEntityDescriptor.CMP_2_x) { 60 abstractSchema = ((EjbCMPEntityDescriptor)descriptor).getAbstractSchemaName(); 61 if (abstractSchema==null) { 62 result.addErrorDetails(smh.getLocalString 63 ("tests.componentNameConstructor", 64 "For [ {0} ]", 65 new Object [] {compName.toString()})); 66 result.failed(smh.getLocalString 67 (getClass().getName() + ".failed2", 68 "No Abstract Schema Name specified for a CMP 2.0 Entity Bean {0} ", 69 new Object [] {descriptor.getName()})); 70 return result; 71 } 72 } 73 } 74 if (abstractSchema ==null) { 75 result.addNaDetails(smh.getLocalString 76 ("tests.componentNameConstructor", 77 "For [ {0} ]", 78 new Object [] {compName.toString()})); 79 result.notApplicable(smh.getLocalString 80 (getClass().getName() + ".notApplicable", 81 "This test is only for CMP 2.0 beans. Abstract Schema Names should be unique within an ejb JAR file.")); 82 return result; 83 } 84 85 EjbBundleDescriptor bundle = descriptor.getEjbBundleDescriptor(); 86 Iterator iterator = (bundle.getEjbs()).iterator(); 87 Vector<String > schemaNames = new Vector<String >(); 88 while(iterator.hasNext()) { 89 EjbDescriptor entity = (EjbDescriptor) iterator.next(); 90 if (entity instanceof EjbEntityDescriptor) { 91 if (!entity.equals(descriptor)) { 92 if (((EjbEntityDescriptor)entity).getPersistenceType().equals(EjbEntityDescriptor.CONTAINER_PERSISTENCE)) { 93 schemaNames.addElement(((EjbCMPEntityDescriptor)entity).getAbstractSchemaName()); 94 } 95 } 96 } 97 } 98 99 for (int i = 0; i < schemaNames.size(); i++) { 100 if (abstractSchema.equals(schemaNames.elementAt(i))) { 101 result.addErrorDetails(smh.getLocalString 102 ("tests.componentNameConstructor", 103 "For [ {0} ]", 104 new Object [] {compName.toString()})); 105 result.addErrorDetails 106 (smh.getLocalString 107 (getClass().getName() + ".failed", 108 "Abstract Schema Names should be unique within an ejb JAR file. Abstract Schema Name [ {0} ] is not unique.", 109 new Object [] {abstractSchema})); 110 oneFailed = true; 111 } 112 } 113 if (oneFailed == false) { 114 result.addGoodDetails(smh.getLocalString 115 ("tests.componentNameConstructor", 116 "For [ {0} ]", 117 new Object [] {compName.toString()})); 118 result.passed 119 (smh.getLocalString 120 (getClass().getName() + ".passed", 121 "PASSED : Abstract Schema Names for all beans within the ejb JAR file are unique.")); 122 } 123 else result.setStatus(Result.FAILED); 124 125 } else { 126 addNaDetails(result, compName); 127 result.notApplicable(smh.getLocalString 128 (getClass().getName() + ".notApplicable", 129 "This test is only for CMP 2.0 beans. Abstract Schema Names should be unique within an ejb JAR file.")); 130 } 131 return result; 132 } 133 } 134 | Popular Tags |