KickJava   Java API By Example, From Geeks To Geeks.

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


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_19; JSR109_WS_22; JSR109_WS_23; JSR109_WS_33;
38  * @test_Strategy:
39  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
40  * @testDescription: Service Implementations using a stateless session bean must be
41  * defined in the ejb-jar.xml deployment descriptor file using the session element.
42  *
43  * The developer declares the implementation of the Web service using
44  * the service-impl-bean element of the deployment descriptor.
45  *
46  * For a stateless session bean implementation, the ejb-link element associates the
47  * port-component with a session element in the ejb-jar.xml. The ejb-link element may
48  * not refer to a session element defined in another module.
49  *
50  * The service-impl-bean element defines the Web service implementation. A service
51  * implementation can be an EJB bean class or JAX-RPC web component.
52  */

53
54 public class ServiceImplBeanLinkCheck extends WSTest implements WSCheck {
55
56     public boolean resolveComponentLink(WebServiceEndpoint desc, Result result) {
57         boolean resolved = false;
58         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
59
60         if( desc.implementedByEjbComponent()) {
61             EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor)desc.getBundleDescriptor();
62             if( ejbBundle.hasEjbByName(desc.getEjbLink())) {
63                 EjbDescriptor ejb = ejbBundle.getEjbByName(desc.getEjbLink());
64                 if (ejb != null) {
65                     resolved = true;
66                     //result.pass , ejb-link resolved
67
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
68                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
69                      result.passed(smh.getLocalString (getClass().getName() + ".passed",
70                     "[{0}] link of service-impl-bean element resolved successfully.",
71                            new Object JavaDoc[] {desc.getEjbLink()}));
72
73                  }
74                  else {
75                    //result.fail, ejb-link could not be resolved
76
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
77                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
78                     result.failed(smh.getLocalString (getClass().getName() + ".failed",
79                     "Could not resolve [{0}] link of service-impl-bean element.",
80                   new Object JavaDoc[] {desc.getEjbLink()}));
81
82                  }
83             }
84         } else if( desc.implementedByWebComponent()) {
85             WebBundleDescriptor webBundle = (WebBundleDescriptor)desc.getBundleDescriptor();
86             WebComponentDescriptor webComponent =
87                 (WebComponentDescriptor) webBundle.
88                   getWebComponentByCanonicalName(desc.getWebComponentLink());
89             if( webComponent != null && webComponent.isServlet()) {
90                 resolved = true;
91                 //result.pass servlet-link resolved
92
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
93                          "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
94                 result.passed(smh.getLocalString (getClass().getName() + ".passed",
95                  "[{0}] link of service-impl-bean element resolved successfully.",
96                 new Object JavaDoc[] {desc.getWebComponentLink()}));
97             }
98             else {
99                    //result.fail, servlet-link could not be resolved
100
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
101                           "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
102                    result.failed(smh.getLocalString (getClass().getName() + ".failed",
103                    "Could not resolve [{0}] link of service-impl-bean element.",
104                    new Object JavaDoc[] {desc.getWebComponentLink()}));
105             }
106         }
107         return resolved;
108     }
109
110     /**
111      * @param descriptor the WebServices descriptor
112      * @return <code>Result</code> the results for this assertion
113      */

114     public Result check (WebServiceEndpoint wsdescriptor) {
115
116     Result result = getInitializedResult();
117         boolean pass = resolveComponentLink(wsdescriptor, result);
118         return result;
119     }
120  }
121
122
Popular Tags