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 35 public class LibDirExists extends WebTest implements WebCheck { 36 37 final String servletLibDirPath = "WEB-INF/lib"; 38 39 46 public Result check(WebBundleDescriptor descriptor) { 47 48 Result result = getInitializedResult(); 49 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 50 51 if (!descriptor.getServletDescriptors().isEmpty()) { 52 boolean oneFailed = false; 53 int na = 0; 54 boolean foundIt = false; 55 Set servlets = descriptor.getServletDescriptors(); 57 Iterator itr = servlets.iterator(); 58 while (itr.hasNext()) { 60 foundIt = false; 61 WebComponentDescriptor servlet = (WebComponentDescriptor)itr.next(); 62 File warfile = new File(System.getProperty("java.io.tmpdir")); 64 warfile = new File(warfile, "wartmp"); 65 File warLibDir = null; 68 69 String uri = getAbstractArchiveUri(descriptor); 75 warLibDir = new File(uri, servletLibDirPath); 76 78 if (warLibDir.isDirectory()) { 79 foundIt = true; 80 } 81 96 97 if (foundIt) { 98 result.addGoodDetails(smh.getLocalString 99 ("tests.componentNameConstructor", 100 "For [ {0} ]", 101 new Object [] {compName.toString()})); 102 result.addGoodDetails(smh.getLocalString 103 (getClass().getName() + ".passed", 104 "Servlet lib dir [ {0} ] resides in WEB-INF/lib directory of [ {1} ].", 105 new Object [] {servletLibDirPath,uri})); 106 } else { 107 na++; 108 result.addNaDetails(smh.getLocalString 109 ("tests.componentNameConstructor", 110 "For [ {0} ]", 111 new Object [] {compName.toString()})); 112 result.addNaDetails(smh.getLocalString 113 (getClass().getName() + ".notApplicable2", 114 "Servlet lib dir [ {0} ] does not reside in [ {1} ].", 115 new Object [] {servletLibDirPath,uri})); 116 } 117 } 118 File wartmp = new File(System.getProperty("java.io.tmpdir")); 119 wartmp = new File(wartmp, "wartmp"); 120 deleteDirectory(wartmp.getAbsolutePath()); 121 if (na == descriptor.getServletDescriptors().size()) { 122 result.setStatus(Result.NOT_APPLICABLE); 123 } else if (oneFailed) { 124 result.setStatus(Result.FAILED); 125 } else { 126 result.setStatus(Result.PASSED); 127 } 128 } else { 129 result.addNaDetails(smh.getLocalString 130 ("tests.componentNameConstructor", 131 "For [ {0} ]", 132 new Object [] {compName.toString()})); 133 result.notApplicable(smh.getLocalString 134 (getClass().getName() + ".notApplicable", 135 "There are no servlet components within the web archive [ {0} ]", 136 new Object [] {descriptor.getName()})); 137 } 138 return result; 139 } 140 } 141 | Popular Tags |