1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import java.util.*; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import com.sun.enterprise.deployment.WebComponentDescriptor; 30 31 32 36 public class ServletParamValue extends WebTest implements WebCheck { 37 38 39 46 public Result check(WebBundleDescriptor descriptor) { 47 48 Set servlets; 49 Iterator itr; 50 String epValue; 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 WebComponentDescriptor servlet; 54 Enumeration en; 55 EnvironmentProperty ep = null; 56 boolean oneFailed = false; 57 boolean status = false; 58 boolean notApp = false; 59 60 if (!descriptor.getServletDescriptors().isEmpty()) { 61 62 servlets = descriptor.getServletDescriptors(); 64 itr = servlets.iterator(); 65 while (itr.hasNext()) { 67 servlet = (WebComponentDescriptor)itr.next(); 68 en = servlet.getInitializationParameters(); 69 if (en.hasMoreElements()) { 70 ep = (EnvironmentProperty)en.nextElement(); 71 epValue = ep.getValue(); 72 if (epValue.length() != 0) { 73 result.addGoodDetails(smh.getLocalString 74 ("tests.componentNameConstructor", 75 "For [ {0} ]", 76 new Object [] {compName.toString()})); 77 result.addGoodDetails(smh.getLocalString 78 (getClass().getName() + ".passed", 79 "Param named/value exists for in the servlet [ {0} ].", 80 new Object [] {servlet.getName()})); 81 } else { 82 oneFailed = true; 84 result.addErrorDetails(smh.getLocalString 85 ("tests.componentNameConstructor", 86 "For [ {0} ]", 87 new Object [] {compName.toString()})); 88 result.addErrorDetails(smh.getLocalString 89 (getClass().getName() + ".failed", 90 "Error: Param name/value entry should of finite length.")); 91 } 92 } 93 } 94 95 } else { 96 notApp = true; 97 result.addNaDetails(smh.getLocalString 98 ("tests.componentNameConstructor", 99 "For [ {0} ]", 100 new Object [] {compName.toString()})); 101 result.notApplicable(smh.getLocalString 102 (getClass().getName() + ".notApplicable", 103 "There are no initialization parameters for the servlet within the web archive [ {0} ]", 104 new Object [] {descriptor.getName()})); 105 } 106 if (oneFailed) { 107 result.setStatus(Result.FAILED); 108 } else if (notApp){ 109 result.setStatus(Result.NOT_APPLICABLE); 110 } else { 111 result.setStatus(Result.PASSED); 112 } 113 return result; 114 } 115 } 116 | Popular Tags |