1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime; 2 3 25 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 27 import java.io.*; 28 import java.util.jar.*; 29 import java.util.zip.*; 30 31 import com.sun.enterprise.deployment.*; 32 import com.sun.enterprise.tools.verifier.*; 33 34 import com.sun.enterprise.tools.verifier.tests.*; 35 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 36 37 import com.sun.enterprise.deployment.xml.DTDRegistry; 38 import com.sun.enterprise.deployment.node.runtime.EjbBundleRuntimeNode; 39 40 46 public class ASEjbJarPublicID extends EjbTest implements EjbCheck { 47 48 57 public Result check(EjbDescriptor descriptor) { 58 60 Result result = getInitializedResult(); 61 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 62 63 if (!getVerifierContext().getisXMLBasedOnSchema()){ 64 try{ 65 String acceptablePubidLiterals[] = { DTDRegistry.SUN_EJBJAR_200_DTD_PUBLIC_ID, 66 DTDRegistry.SUN_EJBJAR_210_DTD_PUBLIC_ID}; 67 String acceptableURLs[] = {DTDRegistry.SUN_EJBJAR_200_DTD_SYSTEM_ID, 68 DTDRegistry.SUN_EJBJAR_210_DTD_SYSTEM_ID}; 69 70 boolean foundDOCTYPE = false, foundPubid = false, foundURL = false; 71 EjbBundleDescriptor ejbBundleDesc = descriptor.getEjbBundleDescriptor(); 72 EjbBundleRuntimeNode ejbBundleRuntimeNode = new EjbBundleRuntimeNode(ejbBundleDesc); 73 74 String s = ejbBundleRuntimeNode.getDocType(); 75 if(s != null) { 76 if(s.indexOf("DOCTYPE") > -1) 77 foundDOCTYPE = true; 78 if(foundDOCTYPE){ 79 for (int i=0;i<acceptablePubidLiterals.length;i++) { 80 if (s.indexOf(acceptablePubidLiterals[i]) > -1) { 81 foundPubid = true; 82 result.addGoodDetails(smh.getLocalString 83 ("tests.componentNameConstructor", 84 "For [ {0} ]", 85 new Object [] {compName.toString()})); 86 result.addGoodDetails 87 (smh.getLocalString 88 (getClass().getName() + ".passed1", 89 "PASSED [AS-EJB ] : The Sun deployment descriptor has the proper PubidLiteral: {0}", 90 new Object [] {acceptablePubidLiterals[i]})); 91 } 92 if (s.indexOf(acceptableURLs[i]) > -1) { 94 foundURL = true; 95 result.addGoodDetails(smh.getLocalString 96 ("tests.componentNameConstructor", 97 "For [ {0} ]", 98 new Object [] {compName.toString()})); 99 result.addGoodDetails 100 (smh.getLocalString 101 (getClass().getName() + ".passed2", 102 "PASSED [AS-EJB] : The Sun deployment descriptor has the proper URL corresponding the the PubIdLiteral: {0}", 103 new Object [] {acceptableURLs[i]})); 104 } 105 } 106 } 107 } 108 if(!foundDOCTYPE){ 109 result.addErrorDetails(smh.getLocalString 110 ("tests.componentNameConstructor", 111 "For [ {0} ]", 112 new Object [] {compName.toString()})); 113 result.failed 114 (smh.getLocalString 115 (getClass().getName() + ".failed1", 116 "FAILED [AS-EJB] : No document type declaration found in the deployment descriptor for {0}", 117 new Object [] {descriptor.getName()})); 118 }else if(!foundPubid) { 119 result.addErrorDetails(smh.getLocalString 120 ("tests.componentNameConstructor", 121 "For [ {0} ]", 122 new Object [] {compName.toString()})); 123 result.failed 124 (smh.getLocalString 125 (getClass().getName() + ".failed2", 126 "FAILED [AS-EJB ejb] : The deployment descriptor for {0} does not have an expected PubidLiteral ", 127 new Object [] {descriptor.getName()})); 128 } else if (!foundURL){ 129 result.addErrorDetails(smh.getLocalString 130 ("tests.componentNameConstructor", 131 "For [ {0} ]", 132 new Object [] {compName.toString()})); 133 result.failed(smh.getLocalString 134 (getClass().getName() + ".failed", 135 "The deployment descriptor {0} doesnot have the right URL corresponding to the PubIdLiteral", 136 new Object [] {descriptor.getName()})); 137 } 138 139 140 }catch(Exception ex){ 141 result.failed(smh.getLocalString(getClass().getName()+".notRun", 142 "NOT RUN [AS-EJB cmp] Could not create descriptor Object.")); 143 } 144 }else{ 145 result.addNaDetails(smh.getLocalString 147 ("tests.componentNameConstructor", 148 "For [ {0} ]", 149 new Object [] {compName.toString()})); 150 result.notApplicable(smh.getLocalString 151 (getClass().getName() + ".notApplicable", 152 "NOT-APPLICABLE: No DOCTYPE found for [ {0} ]", 153 new Object [] {descriptor.getName()})); 154 155 156 } 157 return result; 158 } 159 } 160 | Popular Tags |