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

URLPatternUnique

public abstract class URLPatternUnique extends WebTest implements WebCheck

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)
the url-pattern should be unique. Refer to bug#4903615 This test serves as a base class for three classes. It has a pure virtual function which has to be implemented in concrete subclasses. Note: This right now reports WARNING, as it is not clear from spec if it should report a failure.

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

        boolean na=true, warning=false;
        Result result = getInitializedResult();
        ComponentNameConstructor compName =
                getVerifierContext().getComponentNameConstructor();
        //this warning will be displayed depending on the final status.
        result.addWarningDetails(smh.getLocalString
                                                   ("tests.componentNameConstructor",
                                                        "For [ {0} ]",
                                                        new Object[] {compName.toString()}));

        //Assumes that DOL gives us the list of url-patterns including duplicates
        Set<String> urlPatterns=new HashSet<String>();
        for(Iterator iter=getUrlPatterns(descriptor).iterator();iter.hasNext();){
            na=false;
            String urlPattern=(String)iter.next();
            if(!urlPatterns.add(urlPattern)){
                    warning=true;
                    result.setStatus(Result.WARNING);
                    result.addWarningDetails(smh.getLocalString
                                                     (getClass().getName() + ".warning",
                                                      "url-pattern [ {0} ] already exists in web archive [ {1} ]",
                                                      new Object[] {urlPattern, descriptor.getName()}));
            }
        }

        if(na){
            result.setStatus(Result.NOT_APPLICABLE);
            result.addNaDetails(smh.getLocalString
                                               ("tests.componentNameConstructor",
                                                    "For [ {0} ]",
                                                    new Object[] {compName.toString()}));	    
            result.addNaDetails(smh.getLocalString
                                                     (getClass().getName() + ".notApplicable",
                                                    "There is no url-pattern element within the web archive [ {0} ]",
                                                    new Object[] {descriptor.getName()}));
        }else if(!warning) {
            result.passed(smh.getLocalString
                                               ("tests.componentNameConstructor",
                                                    "For [ {0} ]",
                                                    new Object[] {compName.toString()}));	    
            result.addGoodDetails(smh.getLocalString
                                                     (getClass().getName() + ".passed",
                                                    "All the url-patterns are unique within the web archive [ {0} ]",
                                                    new Object[] {descriptor.getName()}));
        }
        return result;
    
protected abstract java.util.CollectiongetUrlPatterns(WebBundleDescriptor descriptor)