FileDocCategorySizeDatePackage
ParamName.javaAPI DocGlassfish v2 API5701Fri May 04 22:34:10 BST 2007com.sun.enterprise.tools.verifier.tests.web

ParamName

public class ParamName extends WebTest implements WebCheck
Check the context param's name. It should not be duplicate.
author
Arun Jain

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)
Param name should not be duplicate.

param
descriptor the Web deployment descriptor
return
Result the results for this assertion


        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;
    
private booleancheckDuplicate(java.lang.String epName, java.util.HashSet theSet)

        
             return theSet.contains(epName);