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 public abstract class URLPatternUnique extends WebTest implements WebCheck { 31 41 public Result check(WebBundleDescriptor descriptor) { 42 boolean na=true, warning=false; 43 Result result = getInitializedResult(); 44 ComponentNameConstructor compName = 45 getVerifierContext().getComponentNameConstructor(); 46 result.addWarningDetails(smh.getLocalString 48 ("tests.componentNameConstructor", 49 "For [ {0} ]", 50 new Object [] {compName.toString()})); 51 52 Set<String > urlPatterns=new HashSet<String >(); 54 for(Iterator iter=getUrlPatterns(descriptor).iterator();iter.hasNext();){ 55 na=false; 56 String urlPattern=(String )iter.next(); 57 if(!urlPatterns.add(urlPattern)){ 58 warning=true; 59 result.setStatus(Result.WARNING); 60 result.addWarningDetails(smh.getLocalString 61 (getClass().getName() + ".warning", 62 "url-pattern [ {0} ] already exists in web archive [ {1} ]", 63 new Object [] {urlPattern, descriptor.getName()})); 64 } 65 } 66 67 if(na){ 68 result.setStatus(Result.NOT_APPLICABLE); 69 result.addNaDetails(smh.getLocalString 70 ("tests.componentNameConstructor", 71 "For [ {0} ]", 72 new Object [] {compName.toString()})); 73 result.addNaDetails(smh.getLocalString 74 (getClass().getName() + ".notApplicable", 75 "There is no url-pattern element within the web archive [ {0} ]", 76 new Object [] {descriptor.getName()})); 77 }else if(!warning) { 78 result.passed(smh.getLocalString 79 ("tests.componentNameConstructor", 80 "For [ {0} ]", 81 new Object [] {compName.toString()})); 82 result.addGoodDetails(smh.getLocalString 83 (getClass().getName() + ".passed", 84 "All the url-patterns are unique within the web archive [ {0} ]", 85 new Object [] {descriptor.getName()})); 86 } 87 return result; 88 } 89 protected abstract Collection getUrlPatterns(WebBundleDescriptor descriptor); 90 } 91 | Popular Tags |