1 23 package com.sun.enterprise.tools.verifier.tests.app; 24 25 import com.sun.enterprise.tools.verifier.tests.app.ApplicationTest; 26 import java.util.*; 27 import com.sun.enterprise.deployment.*; 28 import com.sun.enterprise.tools.verifier.*; 29 30 33 34 public class AppWebContextUnique extends ApplicationTest implements AppCheck { 35 36 37 44 public Result check(Application descriptor) { 45 46 Result result = getInitializedResult(); 47 Set webs=descriptor.getWebBundleDescriptors(); 48 if(webs.size()<=1){ 49 result.notApplicable(smh.getLocalString 50 (getClass().getName() + ".notApplicable", 51 "There is one or less web component in application [ {0} ]", 52 new Object [] {descriptor.getName()})); 53 return result; 54 } 55 Set<String > contexts=new HashSet<String >(); 56 Iterator itr=webs.iterator(); 57 boolean oneFailed=false; 58 while (itr.hasNext()) { 59 WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next(); 60 String ctx=wbd.getContextRoot(); 61 if(!contexts.add(ctx)){ 62 oneFailed=true; 63 result.failed( 64 (smh.getLocalString 65 (getClass().getName() + ".failed", 66 "Error: There is already a web module with context-root [ {0} ] within application [ {1} ]", 67 new Object [] {ctx, descriptor.getName()}))); 68 } 69 } 70 if(!oneFailed){ 71 result.passed( 72 (smh.getLocalString 73 (getClass().getName() + ".passed", 74 "All the context-root values are unique within application [ {0} ]", 75 new Object [] {descriptor.getName()}))); 76 } 77 return result; 78 } 79 } 80 | Popular Tags |