KickJava   Java API By Example, From Geeks To Geeks.

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


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_15;
38  * @test_Strategy:
39  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
40  * @testDescription:The developer is responsible for packaging, either by containment or
41  * reference, the WSDL file, Service Endpoint Interface class, Service Implementation Bean
42  * class, and their dependent classes, JAX-RPC mapping file along with a Web services
43  * deployment descriptor in a J2EE module.
44  */

45
46 public class ServletImplClassCheck extends WSTest implements WSCheck {
47
48     /**
49      * @param descriptor the WebServices descriptor
50      * @return <code>Result</code> the results for this assertion
51      */

52     public Result check (WebServiceEndpoint descriptor) {
53
54     Result result = getInitializedResult();
55         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
56
57         boolean pass = true;
58         if (descriptor.implementedByWebComponent()) {
59           String JavaDoc servletClass=null;
60           ClassLoader JavaDoc loader = getVerifierContext().getClassLoader();
61           WebComponentDescriptor wcd = descriptor.getWebComponentImpl();
62           if (wcd!=null)
63               servletClass = wcd.getWebComponentImplementation();
64           if ((servletClass == null) || (!descriptor.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 (getClass().getName() + ".failed1",
69              "The Web Component Implementation for this JAX-RPC Service Endpoint [{0}] is not a Servlet.",
70               new Object JavaDoc[] {compName.toString()}));
71             
72           }
73           else {
74             try {
75               Class JavaDoc cl = Class.forName(servletClass, false, getVerifierContext().getClassLoader());
76                 //result.pass
77
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
78                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
79                   result.passed(smh.getLocalString (getClass().getName() + ".passed",
80                     "The Servlet Implementation Class [{0}] was loaded successfully.",
81                            new Object JavaDoc[] {servletClass}));
82
83             }catch (ClassNotFoundException JavaDoc e) {
84                 //result.fail could not find servlet class
85
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
86                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
87                 result.failed(smh.getLocalString (getClass().getName() + ".failed",
88                  "The Servlet Implementation Class [{0}] was not found.",
89                  new Object JavaDoc[] {servletClass}));
90                 pass = false;
91             }
92           }
93         }
94         else {
95             //result.Not Applicable
96
result.addNaDetails(smh.getLocalString
97                      ("tests.componentNameConstructor", "For [ {0} ]",
98                       new Object JavaDoc[] {compName.toString()}));
99             result.notApplicable(smh.getLocalString (getClass().getName() + ".notapp",
100                  "Not Applicable since this not a JAX-RPC Service Endpoint."));
101
102         }
103
104         return result;
105     }
106  }
107
108
Popular Tags