1 23 24 package com.sun.enterprise.tools.verifier.tests.web; 25 26 import com.sun.enterprise.tools.verifier.Result; 27 import com.sun.enterprise.tools.verifier.TagLibDescriptor; 28 import com.sun.enterprise.tools.verifier.Context; 29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 32 35 public class TagLibPublicID extends WebTest implements WebCheck { 36 37 public Result check(WebBundleDescriptor descriptor) { 38 39 Result result = getInitializedResult(); 40 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 41 42 String acceptablePubidLiterals[] = { 43 "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" , 44 "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" }; 45 46 String acceptableURLs[] = {"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd", 47 "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"}; 48 Context context = getVerifierContext(); 49 TagLibDescriptor tlds[] = context.getTagLibDescriptors(); 50 51 addGoodDetails(result, compName); 52 result.passed(smh.getLocalString 53 (getClass().getName() + ".passed", 54 "Test passed successfully")); 55 56 if (tlds != null && tlds.length !=0) { 57 boolean oneFailed = false; 58 for (int i=0;i<tlds.length;i++) { 60 String publicID = tlds[i].getPublicID(); 61 String systemID = tlds[i].getSystemID(); 62 if (publicID==null) continue; 63 boolean match = false; 64 for (int k=0;k<acceptablePubidLiterals.length;k++) { 65 if (publicID.compareTo(acceptablePubidLiterals[k])==0 && systemID.compareTo(acceptableURLs[k])==0) { 66 match=true; 67 addGoodDetails(result, compName); 68 result.passed 69 (smh.getLocalString 70 (getClass().getName() + ".passed1", 71 "The deployment descriptor [ {0} ] has the proper PubidLiteral: [ {1} ] and sytemID: [ {2} ]", 72 new Object [] {tlds[i].getUri(), acceptablePubidLiterals[k], acceptableURLs[k]})); 73 break; 74 } 75 } 76 77 if (!match) { 78 oneFailed=true; 79 addErrorDetails(result, compName); 80 result.addErrorDetails 81 (smh.getLocalString 82 (getClass().getName() + ".failed", 83 "The deployment descriptor for [ {0} ] does not have an expected PubidLiteral or SystemID", 84 new Object [] {tlds[i].getUri()})); 85 86 } 87 } 88 if(oneFailed) 89 result.setStatus(Result.FAILED); 90 return result; 91 92 } 93 return result; 94 } 95 } 96 | Popular Tags |