1 23 package com.sun.enterprise.tools.verifier.tests.web.elements; 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.tests.web.WebCheck; 30 import com.sun.enterprise.tools.verifier.*; 31 import com.sun.enterprise.tools.verifier.tests.*; 32 import com.sun.enterprise.util.FileClassLoader; 33 34 35 39 public class UrlElement 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.getLocalizedContentDescriptors().hasMoreElements()) { 56 boolean oneFailed = false; 57 boolean foundIt = false; 58 for (Enumeration e = descriptor.getLocalizedContentDescriptors() ; e.hasMoreElements() ;) { 60 foundIt = false; 61 LocalizedContentDescriptorImpl urls = (LocalizedContentDescriptorImpl)e.nextElement(); 62 String url = urls.getUrl(); 63 if (url.length() > 0) { 64 foundIt = true; 65 } else { 66 foundIt = false; 67 } 68 69 if (foundIt) { 70 result.addGoodDetails(smh.getLocalString 71 ("tests.componentNameConstructor", 72 "For [ {0} ]", 73 new Object [] {compName.toString()})); 74 result.addGoodDetails(smh.getLocalString 75 (getClass().getName() + ".passed", 76 "Servlet url [ {0} ] defines a url location to a resource external to this web application.", 77 new Object [] {url})); 78 } else { 79 if (!oneFailed) { 80 oneFailed = true; 81 } 82 result.addErrorDetails(smh.getLocalString 83 ("tests.componentNameConstructor", 84 "For [ {0} ]", 85 new Object [] {compName.toString()})); 86 result.addErrorDetails(smh.getLocalString 87 (getClass().getName() + ".failed", 88 "Error: Servlet url [ {0} ] does not define a url location to a resource external to this web application.", 89 new Object [] {url})); 90 } 91 } 92 if (oneFailed) { 93 result.setStatus(Result.FAILED); 94 } else { 95 result.setStatus(Result.PASSED); 96 } 97 } else { 98 result.addNaDetails(smh.getLocalString 99 ("tests.componentNameConstructor", 100 "For [ {0} ]", 101 new Object [] {compName.toString()})); 102 result.notApplicable(smh.getLocalString 103 (getClass().getName() + ".notApplicable", 104 "There are no url elements within the web archive [ {0} ]", 105 new Object [] {descriptor.getName()})); 106 } 107 return result; 108 } 109 } 110 | Popular Tags |