KickJava   Java API By Example, From Geeks To Geeks.

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


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_23;
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 defined
41  * in the ejb-jar.xml deployment descriptor file using the session element.
42  *
43  * For a stateless session bean implementation, the ejb-link element
44  * associates the port-component with a session element in the ejb-jar.xml. The ejb-link
45  * element may not refer to a session element defined in another module.
46  */

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

54     public Result check (WebServiceEndpoint wsdescriptor) {
55
56     Result result = getInitializedResult();
57         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
58
59         if (wsdescriptor.implementedByEjbComponent()) {
60             EjbDescriptor ejbdesc = wsdescriptor.getEjbComponentImpl();
61
62             if (ejbdesc == null) {
63
64                result.addErrorDetails(smh.getLocalString
65                                   ("tests.componentNameConstructor",
66                                    "For [ {0} ]",
67                                    new Object JavaDoc[] {compName.toString()}));
68                  result.failed(smh.getLocalString
69                    (getClass().getName() + ".failed1",
70                     "Service Implementation bean Could Not be Resolved from the ejb-link specified"));
71                return result;
72              }
73
74             if (ejbdesc instanceof EjbSessionDescriptor) {
75                EjbSessionDescriptor session = (EjbSessionDescriptor)ejbdesc;
76                if (EjbSessionDescriptor.STATELESS.equals(session.getSessionType())) {
77                    result.addGoodDetails(smh.getLocalString
78                                   ("tests.componentNameConstructor",
79                                    "For [ {0} ]",
80                                    new Object JavaDoc[] {compName.toString()}));
81                    result.passed(smh.getLocalString
82                    (getClass().getName() + ".passed",
83                    "Service Implementation bean defined in ejb-jar.xml using {0} session element", new Object JavaDoc[] {"stateless"}));
84                }
85                else {
86                  // result.fail, endpoint can be a stateful session bean
87
result.addErrorDetails(smh.getLocalString
88                                   ("tests.componentNameConstructor",
89                                    "For [ {0} ]",
90                                    new Object JavaDoc[] {compName.toString()}));
91                  result.failed(smh.getLocalString
92                    (getClass().getName() + ".failed",
93                     "Service Implementation bean cannot be Stateful Session Bean"));
94                }
95             }
96             else {
97               // result.fail, service endpoint should be Session Bean
98
result.addErrorDetails(smh.getLocalString
99                      ("tests.componentNameConstructor", "For [ {0} ]",
100                       new Object JavaDoc[] {compName.toString()}));
101               result.failed(smh.getLocalString
102                  (getClass().getName() + ".failed2",
103                  "Service Implementation bean Should be a Session Bean"));
104             }
105   
106         }
107         else {
108
109           // result.notapp
110
result.addNaDetails(smh.getLocalString
111                      ("tests.componentNameConstructor", "For [ {0} ]",
112                       new Object JavaDoc[] {compName.toString()}));
113           result.notApplicable(smh.getLocalString
114                  (getClass().getName() + ".notapp",
115                  "This is a JAX-RPC Service Endpoint"));
116         }
117
118         return result;
119     }
120  }
121
122
Popular Tags