1 23 package com.sun.enterprise.tools.verifier.tests.webservices; 24 25 import com.sun.enterprise.deployment.*; 26 import com.sun.enterprise.tools.verifier.*; 27 import java.util.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 30 33 34 42 43 public class OnlyOneServletMappingCheck extends WSTest implements WSCheck { 44 45 49 public Result check (WebServiceEndpoint desc) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 54 if (desc.implementedByWebComponent()) { 55 WebBundleDescriptor webBundle = (WebBundleDescriptor)desc.getBundleDescriptor(); 56 WebComponentDescriptor webComponent = 57 (WebComponentDescriptor) webBundle. 58 getWebComponentByCanonicalName(desc.getWebComponentLink()); 59 if(webComponent != null && webComponent.isServlet()) { 60 int sz = getSize(webComponent.getUrlPatternsSet()); 61 if (sz == 0) { 62 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 64 "For [ {0} ]", new Object [] {compName.toString()})); 65 result.failed(smh.getLocalString 66 (getClass().getName() + ".failed", 67 "Found [{0}] servlet mappings for the servlet linked to by this port-component.", 68 new Object [] {"0"})); 69 } 70 if (sz > 1) { 71 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 73 "For [ {0} ]", new Object [] {compName.toString()})); 74 result.failed(smh.getLocalString 75 (getClass().getName() + ".failed", 76 "Found [{0}] servlet mappings for the servlet linked to by this port-component.", 77 new Object [] {Integer.toString(sz)})); 78 } 79 else { 80 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 82 "For [ {0} ]", new Object [] {compName.toString()})); 83 result.passed(smh.getLocalString (getClass().getName() + ".passed", 84 "Found only one servlet mapping for the servlet linked to by this port-component.")); 85 86 } 87 } 88 } 89 else { 90 91 result.addNaDetails(smh.getLocalString 92 ("tests.componentNameConstructor", "For [ {0} ]", 93 new Object [] {compName.toString()})); 94 result.notApplicable(smh.getLocalString(getClass().getName() + ".notapp", 95 " Not applicable since this is Not a JAX-RPC Service Endpoint.")); 96 97 } 98 99 return result; 100 } 101 102 108 private int getSize(Set urlPatterns) { 109 int size = urlPatterns.size(); 110 if (getVerifierContext().isAppserverMode()) for (Object url : urlPatterns) { 112 String urlPattern = (String )url; 113 if(urlPattern.indexOf("__container") != -1) 114 size--; 115 } 116 return size; 117 } 118 } 119 120 | Popular Tags |