1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import com.sun.enterprise.tools.verifier.tests.web.WebTest; 26 import java.util.*; 27 import java.io.*; 28 import com.sun.enterprise.deployment.*; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 33 34 35 39 public class JspFile extends WebTest implements WebCheck { 40 41 42 50 public Result check(WebBundleDescriptor descriptor) { 51 52 Result result = getInitializedResult(); 53 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 54 55 if (!descriptor.getJspDescriptors().isEmpty()) { 56 boolean oneFailed = false; 57 boolean foundIt = false; 58 FileArchive arch=null; 61 Set jsps = descriptor.getJspDescriptors(); 63 Iterator itr = jsps.iterator(); 64 while (itr.hasNext()) { 66 foundIt = false; 67 WebComponentDescriptor jsp = (WebComponentDescriptor)itr.next(); 68 String jspFilename = jsp.getWebComponentImplementation(); 69 String uri = null; 70 try{ 71 uri=getAbstractArchiveUri(descriptor); 74 try{ 75 arch = new FileArchive(); 76 arch.open(uri); 77 }catch(IOException e){throw e;} 78 83 if (jspFilename.startsWith("/")) 84 jspFilename = jspFilename.substring(1); 85 File jspf = new File(arch.getArchiveUri()+File.separator+jspFilename); 90 if(jspf.exists()) 91 foundIt=true; 92 jspf = null; 93 }catch (Exception e){ 97 if (!oneFailed ) { 98 oneFailed = true; 99 } 100 } 101 102 if (foundIt) { 103 result.addGoodDetails(smh.getLocalString 104 ("tests.componentNameConstructor", 105 "For [ {0} ]", 106 new Object [] {compName.toString()})); 107 result.addGoodDetails(smh.getLocalString 108 (getClass().getName() + ".passed", 109 "Jsp file [ {0} ] contains the full path to Jsp file within web application [ {1} ]", 110 new Object [] {jspFilename, descriptor.getName()})); 111 } else { 112 if (!oneFailed ) { 113 oneFailed = true; 114 } 115 result.addErrorDetails(smh.getLocalString 116 ("tests.componentNameConstructor", 117 "For [ {0} ]", 118 new Object [] {compName.toString()})); 119 120 result.addErrorDetails(smh.getLocalString 121 (getClass().getName() + ".failed", 122 "Error: Jsp file [ {0} ] is not found within [ {1} ] or does not contain the full path to Jsp file within web application [ {2} ]", 123 new Object [] {jspFilename, uri, descriptor.getName()})); 124 } 125 } 126 if (oneFailed) { 127 result.setStatus(Result.FAILED); 128 } else { 129 result.setStatus(Result.PASSED); 130 } 131 } else { 132 result.addNaDetails(smh.getLocalString 133 ("tests.componentNameConstructor", 134 "For [ {0} ]", 135 new Object [] {compName.toString()})); 136 137 result.notApplicable(smh.getLocalString 138 (getClass().getName() + ".notApplicable", 139 "There are no Jsp components within the web archive [ {0} ]", 140 new Object [] {descriptor.getName()})); 141 } 142 return result; 143 } 144 } 145 | Popular Tags |