KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > webservices > JAXRPCEndpointIsServletClassCheck


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

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 import java.lang.reflect.*;
30
31 /*
32  * @class.setup_props: ;
33  */

34
35 /*
36  * @testName: check
37  * @assertion_ids: JSR109_WS_20;
38  * @test_Strategy:
39  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
40  * @testDescription: Service Implementations using a JAX-RPC Service Endpoint must be defined
41  * in the web.xml deployment descriptor file using the servlet-class element.
42  */

43 public class JAXRPCEndpointIsServletClassCheck extends WSTest implements WSCheck {
44
45     /**
46      * @param descriptor the WebServices descriptor
47      * @return <code>Result</code> the results for this assertion
48      */

49     public Result check (WebServiceEndpoint wsdescriptor) {
50
51     Result result = getInitializedResult();
52         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
53
54         ClassLoader JavaDoc loader = getVerifierContext().getClassLoader();
55
56         if (wsdescriptor.implementedByWebComponent()) {
57             WebBundleDescriptor webBundle = (WebBundleDescriptor)wsdescriptor.getBundleDescriptor();
58             WebComponentDescriptor webComponent =
59                 (WebComponentDescriptor) webBundle.
60                   getWebComponentByCanonicalName(wsdescriptor.getWebComponentLink());
61             if( webComponent != null && webComponent.isServlet()) {
62                 String JavaDoc servletClass = wsdescriptor.getWebComponentImpl().
63                                       getWebComponentImplementation();
64                 if ((servletClass == null) || (!wsdescriptor.getWebComponentImpl().isServlet())) {
65                      //result.fail, webcomponentimpl for webservice is not servlet
66
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
67                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
68                       result.failed(smh.getLocalString
69                       ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]",
70                        new Object JavaDoc[] {"The WebComponent implementation for this JAX-RPC endpoint is not a servlet"}));
71
72                 }
73                 else {
74                      // try to load the servlet class
75
try {
76                     Class JavaDoc cl = Class.forName(servletClass, false, getVerifierContext().getClassLoader());
77                       //result.pass
78
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
79                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
80                       result.passed(smh.getLocalString (
81                           "com.sun.enterprise.tools.verifier.tests.webservices.clpassed",
82                           "The [{0}] Class [{1}] exists and was loaded successfully.",
83                            new Object JavaDoc[] {"Servlet Class", servletClass}));
84
85                   }catch (ClassNotFoundException JavaDoc e) {
86                       //result.fail could not find servlet class
87
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
88                             "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
89                       result.failed(smh.getLocalString (
90                             "com.sun.enterprise.tools.verifier.tests.webservices.clfailed",
91                             "The [{0}] Class [{1}] could not be Loaded",
92                              new Object JavaDoc[] {"Servlet Class", servletClass}));
93
94                   }
95                 }
96             }
97             else {
98                 //result.fail, servlet-link could not be resolved
99
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
100                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
101                 result.failed(smh.getLocalString
102                   ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]",
103                   new Object JavaDoc[] {"The servlet-link for this JAX-RPC Endpoint could not be resolved"}));
104  
105             }
106         }
107         else {
108           //result.notapplicable
109
result.addNaDetails(smh.getLocalString
110                      ("tests.componentNameConstructor", "For [ {0} ]",
111                       new Object JavaDoc[] {compName.toString()}));
112           result.notApplicable(smh.getLocalString
113                  ("com.sun.enterprise.tools.verifier.tests.webservices.notapp",
114                  "[{0}]", new Object JavaDoc[] {"Not Applicable since this is NOT a JAX-RPC Service Endpoint"}));
115
116         }
117
118         return result;
119     }
120  }
121
122
Popular Tags