1 23 package com.sun.enterprise.tools.verifier.tests.web.spec22; 24 25 import com.sun.enterprise.tools.verifier.tests.web.WebTest; 26 import java.util.zip.*; 27 import java.util.jar.*; 28 import java.util.*; 29 import java.io.*; 30 import com.sun.enterprise.tools.verifier.tests.web.WebCheck; 31 import com.sun.enterprise.deployment.*; 32 import com.sun.enterprise.tools.verifier.*; 33 import com.sun.enterprise.tools.verifier.tests.*; 34 import com.sun.enterprise.util.FileClassLoader; 35 36 37 41 public class JspFileName extends WebTest implements WebCheck { 42 43 44 51 public Result check(WebBundleDescriptor descriptor) { 52 53 Result result = getInitializedResult(); 54 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 55 String specVersion = descriptor.getSpecVersion(); 56 Float specVer = new Float (specVersion); 57 if (!descriptor.getJspDescriptors().isEmpty()) { 58 boolean oneFailed = false; 59 int count = getNonRuntimeCountNodeSet("/web-app/servlet"); 60 for(int i=1;i<=count;i++){ 61 String jspFilename = getXPathValueForNonRuntime("/web-app/servlet["+i+"]/jsp-file"); 62 if(jspFilename!=null){ 63 if (jspFilename.startsWith("/")){ 64 if(specVer.compareTo(new Float ("2.3"))<0){ 65 result.addGoodDetails(smh.getLocalString 66 ("tests.componentNameConstructor", 67 "For [ {0} ]", 68 new Object [] {compName.toString()})); 69 result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", 70 " PASSED : Jsp Name [ {0} ] is valid", 71 new Object [] { jspFilename })); 72 73 }else{ 74 result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", 75 "For [ {0} ]", 76 new Object [] {compName.toString()})); 77 result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed1", 78 " Jsp Name [ {0} ] is valid and starts with a leading '/'", 79 new Object [] { jspFilename })); 80 81 } 82 }else{ 83 if(specVer.compareTo(new Float ("2.3"))<0){ 84 result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", 85 "For [ {0} ]", 86 new Object [] {compName.toString()})); 87 result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", 88 " PASSED Jsp Name [ {0} ] is valid", 89 new Object [] { jspFilename })); 90 91 }else{ 92 result.addErrorDetails(smh.getLocalString 93 ("tests.componentNameConstructor", 94 "For [ {0} ]", 95 new Object [] {compName.toString()})); 96 result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", 97 " Error : Jsp Name [ {0} ] in invalid as it does not start with a leading '/'", 98 new Object [] { jspFilename })); 99 oneFailed=true; 100 } 101 } 102 103 } 104 } 105 if (oneFailed) { 106 result.setStatus(Result.FAILED); 107 } else { 108 result.setStatus(Result.PASSED); 109 } 110 } else { 111 result.addNaDetails(smh.getLocalString 112 ("tests.componentNameConstructor", 113 "For [ {0} ]", 114 new Object [] {compName.toString()})); 115 result.notApplicable(smh.getLocalString 116 (getClass().getName() + ".notApplicable", 117 "There are no Jsp components within the web archive [ {0} ]", 118 new Object [] {descriptor.getName()})); 119 } 120 return result; 121 122 } 123 } 124 | Popular Tags |