Param name should not be duplicate.
String epName;
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
Enumeration en;
HashSet<String> envSet = new HashSet<String>();
EnvironmentProperty ep;
boolean oneFailed = false;
boolean duplicate = false;
if (!descriptor.getContextParametersSet().isEmpty()) {
// get the context parameters
for ( en = descriptor.getContextParameters(); en.hasMoreElements(); ) {
ep = (EnvironmentProperty)en.nextElement();
epName = ep.getName();
if (epName.length() != 0)
duplicate = checkDuplicate(epName, envSet);
else {
oneFailed = true;
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"Error: Param name/value entry should not be empty strings."));
}
if ( !duplicate) {
envSet.add(epName);
}
else {
oneFailed = true;
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"Error: Duplicate param names are not allowed."));
}
}
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
(getClass().getName() + ".passed",
"Param named/value exists for in the web app [ {0} ].",
new Object[] {descriptor.getName()}));
} else {
result.setStatus(Result.NOT_APPLICABLE);
result.addNaDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable",
"There are no context parameters within the web archive [ {0} ]",
new Object[] {descriptor.getName()}));
return result;
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else {
result.setStatus(Result.PASSED);
}
return result;