FileDocCategorySizeDatePackage
OnlyOneServletMappingCheck.javaAPI DocGlassfish v2 API6020Fri May 04 22:34:16 BST 2007com.sun.enterprise.tools.verifier.tests.webservices

OnlyOneServletMappingCheck

public class OnlyOneServletMappingCheck extends WSTest implements WSCheck

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebServiceEndpoint desc)

param
desc the WebServices descriptor
return
Result the results for this assertion


	Result result = getInitializedResult();
        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

        if (desc.implementedByWebComponent()) {
            WebBundleDescriptor webBundle = (WebBundleDescriptor)desc.getBundleDescriptor();
            WebComponentDescriptor webComponent =
                (WebComponentDescriptor) webBundle.
                getWebComponentByCanonicalName(desc.getWebComponentLink());
            if(webComponent != null && webComponent.isServlet()) {
               int sz = getSize(webComponent.getUrlPatternsSet());
               if (sz == 0) {
                  //result.fail , no servlet-mapping for servlet linked to port-component
                  result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
                  result.failed(smh.getLocalString
                       (getClass().getName() + ".failed",
                       "Found [{0}] servlet mappings for the servlet linked to by this port-component.",
                       new Object[] {"0"}));
               }
               if (sz > 1) {
                  //result.fail , more than one servlet-mapping for servlet linked to port-component
                  result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
                  result.failed(smh.getLocalString
                       (getClass().getName() + ".failed",
                       "Found [{0}] servlet mappings for the servlet linked to by this port-component.",
                       new Object[] {Integer.toString(sz)}));
                } 
                else {
                  //result.pass , one servlet-mapping for servlet linked to port-component
                   result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
                   result.passed(smh.getLocalString (getClass().getName() + ".passed",
                   "Found only one servlet mapping for the servlet linked to by this port-component."));

                }
            }
         }
         else {

            result.addNaDetails(smh.getLocalString
                     ("tests.componentNameConstructor", "For [ {0} ]",
                      new Object[] {compName.toString()}));
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notapp",
                 " Not applicable since this is Not a JAX-RPC Service Endpoint."));

         }

        return result;
    
private intgetSize(java.util.Set urlPatterns)
This is a hack, since descriptors from backend contain an extra url pattern.

param
urlPatterns
return

        int size = urlPatterns.size();
        if (getVerifierContext().isAppserverMode()) //only if backend
            for (Object url : urlPatterns) {
                String urlPattern = (String)url;
                if(urlPattern.indexOf("__container") != -1)
                    size--;
            }
        return size;