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

ServletUrlPatternExactCheck

public class ServletUrlPatternExactCheck extends WSTest implements WSCheck

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

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


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

        boolean pass = true;

        if (desc.implementedByWebComponent()) {
            WebBundleDescriptor webBundle = (WebBundleDescriptor)desc.getBundleDescriptor();
            WebComponentDescriptor webComponent =
                (WebComponentDescriptor) webBundle.
                getWebComponentByCanonicalName(desc.getWebComponentLink());
            if(webComponent != null && webComponent.isServlet()) {
                Enumeration en = webComponent.getUrlPatterns();
                while(en.hasMoreElements()) {
                  String pattern =(String) en.nextElement();
                  if (pattern.indexOf("*") == -1) {
                     // result.pass
                      result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
                      result.passed(smh.getLocalString (getClass().getName() + ".passed",
                      "The urlpattern for this servlet-mapping [{0}] is exact.",
                      new Object[] {pattern}));
                     
                  }
                  else {
                     // result.fail
                     result.addErrorDetails(smh.getLocalString
                                  ("tests.componentNameConstructor", "For [ {0} ]",
                                   new Object[] {compName.toString()}));
                     result.failed(smh.getLocalString (getClass().getName() + ".failed",
                     "The urlpattern for this servlet-mapping [{0}] contains '*' and is not exact.",
                     new Object[] {pattern}));

                     pass = false;
                  }
                  // we assume there is one servlet-mapping specified, 
                  // this check is done in another test
                  break;
                }
            }
         }
         else {
           //result.notapp
            result.addNaDetails(smh.getLocalString
                     ("tests.componentNameConstructor", "For [ {0} ]",
                      new Object[] {compName.toString()}));
            result.notApplicable(smh.getLocalString
                 (getClass().getName() + ".notapp",
                 "Not Applicable since this not a JAX-RPC Service Endpoint."));
         }

        return result;