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 30 31 35 public class ParamName extends WebTest implements WebCheck { 36 37 38 45 public Result check(WebBundleDescriptor descriptor) { 46 47 String epName; 48 Result result = getInitializedResult(); 49 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 50 Enumeration en; 51 HashSet<String > envSet = new HashSet<String >(); 52 EnvironmentProperty ep; 53 boolean oneFailed = false; 54 boolean duplicate = false; 55 56 if (!descriptor.getContextParametersSet().isEmpty()) { 57 58 for ( en = descriptor.getContextParameters(); en.hasMoreElements(); ) { 60 ep = (EnvironmentProperty)en.nextElement(); 61 epName = ep.getName(); 62 if (epName.length() != 0) 63 duplicate = checkDuplicate(epName, envSet); 64 else { 65 oneFailed = true; 66 result.addErrorDetails(smh.getLocalString 67 ("tests.componentNameConstructor", 68 "For [ {0} ]", 69 new Object [] {compName.toString()})); 70 result.addErrorDetails(smh.getLocalString 71 (getClass().getName() + ".failed", 72 "Error: Param name/value entry should not be empty strings.")); 73 } 74 if ( !duplicate) { 75 envSet.add(epName); 76 } 77 else { 78 oneFailed = true; 79 result.addErrorDetails(smh.getLocalString 80 ("tests.componentNameConstructor", 81 "For [ {0} ]", 82 new Object [] {compName.toString()})); 83 result.addErrorDetails(smh.getLocalString 84 (getClass().getName() + ".failed", 85 "Error: Duplicate param names are not allowed.")); 86 } 87 } 88 result.addGoodDetails(smh.getLocalString 89 ("tests.componentNameConstructor", 90 "For [ {0} ]", 91 new Object [] {compName.toString()})); 92 result.addGoodDetails(smh.getLocalString 93 (getClass().getName() + ".passed", 94 "Param named/value exists for in the web app [ {0} ].", 95 new Object [] {descriptor.getName()})); 96 97 } else { 98 result.setStatus(Result.NOT_APPLICABLE); 99 result.addNaDetails(smh.getLocalString 100 ("tests.componentNameConstructor", 101 "For [ {0} ]", 102 new Object [] {compName.toString()})); 103 result.notApplicable(smh.getLocalString 104 (getClass().getName() + ".notApplicable", 105 "There are no context parameters within the web archive [ {0} ]", 106 new Object [] {descriptor.getName()})); 107 return result; 108 } 109 if (oneFailed) { 110 result.setStatus(Result.FAILED); 111 } else { 112 result.setStatus(Result.PASSED); 113 } 114 return result; 115 } 116 private boolean checkDuplicate(String epName, HashSet theSet) { 117 118 return theSet.contains(epName); 119 } 120 121 } 122 123 | Popular Tags |