KickJava   Java API By Example, From Geeks To Geeks.

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


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

24 package com.sun.enterprise.tools.verifier.tests.webservices;
25
26 import com.sun.enterprise.deployment.*;
27 import com.sun.enterprise.tools.verifier.*;
28 import java.util.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 /*
32  * @class.setup_props: ;
33  */

34
35 /*
36  * @testName: check
37  * @assertion_ids: JSR109_WS_10; JSR109_WS_11; JSR109_WS_12; JSR109_WS_13;
38  * JSR109_WS_14; JSR109_WS_47;
39  * @test_Strategy:
40  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
41  *
42  * The Service Implementation Bean must have a default public constructor.
43  *
44  * The Service Implementation Bean may implement the Service Endpoint Interface as defined by
45  * the JAX-RPC Servlet model. The bean must implement all the method signatures of the SEI.
46  * The business methods of the bean must be public and must not be static.
47  *
48  * If the Service Implementation Bean does not implement the SEI, the business methods
49  * must not be final, must not be static.The bean must implement all the method signatures
50  * of the SEI.
51  *
52  * The Service Implementation Bean class must be public, must not be final and must
53  * not be abstract.
54  *
55  * The Service Implementation Bean class must not define the finalize() method.
56  *
57  * All the exceptions defined in the throws clause of the matching method of the session bean
58  * class must be defined in the throws clause of the method of the web service endpoint
59  * interface.
60  *
61  */

62 public class JAXRPCServiceImplBeanChk extends WSTest implements WSCheck {
63
64     /**
65      * @param descriptor the WebService deployment descriptor
66      * @return <code>Result</code> the results for this assertion
67      */

68     public Result check (WebServiceEndpoint descriptor) {
69    
70       Result result = getInitializedResult();
71       ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
72
73       boolean pass = true;
74
75       if (descriptor.implementedByWebComponent()) {
76
77           Class JavaDoc<?> bean = loadImplBeanClass(descriptor, result);
78           if (bean == null) {
79             result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
80                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
81             result.failed(smh.getLocalString
82               ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]",
83               new Object JavaDoc[] {"Could not Load the Service Implementation Bean class for the JAX-RPC Endpoint"}));
84  
85           }
86           else {
87         
88           // get hold of the SEI Class
89
String JavaDoc s = descriptor.getServiceEndpointInterface();
90
91           if ((s == null) || (s.length() == 0)){
92                // internal error, should never happen
93
result.addErrorDetails(smh.getLocalString
94                ("com.sun.enterprise.tools.verifier.tests.webservices.Error",
95                 "Error: Unexpected error occurred [ {0} ]",
96                 new Object JavaDoc[] {"SEI Class Name is Null"}));
97           }
98
99           Class JavaDoc<?> sei = loadSEIClass(descriptor, result);
100
101           if (sei == null) {
102              result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
103                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
104              result.failed(smh.getLocalString
105                 ("com.sun.enterprise.tools.verifier.tests.webservices.WSTest.SEIClassExists",
106                  "Error: Service Endpoint Interface class [ {0} ] not found.",
107                  new Object JavaDoc[] {descriptor.getServiceEndpointInterface()}));
108            }
109            else {
110             boolean implementsSEI = sei.isAssignableFrom(bean);
111             EndPointImplBeanClassChecker checker =
112             new EndPointImplBeanClassChecker(sei,bean,result,false);
113             if (implementsSEI) {
114               // result.passed
115
result.addGoodDetails(smh.getLocalString
116                                   ("tests.componentNameConstructor",
117                                    "For [ {0} ]",
118                                    new Object JavaDoc[] {compName.toString()}));
119                result.passed(smh.getLocalString (
120                           "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]",
121                            new Object JavaDoc[] {"The Service Impl Bean implements SEI"}));
122
123             }
124             else {
125          
126                // business methods of the bean should be public, not final and not static
127
// This check will happen as part of this call
128
Vector notImpl = checker.getSEIMethodsNotImplemented();
129                if (notImpl.size() > 0) {
130                  // result.fail, Set the not implemented methods into the result info??
131
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
132                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
133                  result.failed(smh.getLocalString
134                  ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]",
135                  new Object JavaDoc[] {"The Service Implementation Bean Does not Implement ALL SEI Methods"}));
136
137                }
138                else {
139                  // result.pass :All SEI methods implemented
140
result.addGoodDetails(smh.getLocalString
141                                   ("tests.componentNameConstructor",
142                                    "For [ {0} ]",
143                                    new Object JavaDoc[] {compName.toString()}));
144                  result.passed(smh.getLocalString (
145                           "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]",
146                            new Object JavaDoc[] {"The Service Impl Bean implements all Methods of the SEI"}));
147
148                }
149             }
150
151             // class should be public, not final and not abstract
152
// should not define finalize()
153
if (checker.check(compName)) {
154                 // result.passed stuff done inside the check() method nothing todo here
155
result.setStatus(Result.PASSED);
156             }
157             else {
158                 // result.fail : stuff done inside the check() method nothing todo here
159
result.setStatus(Result.FAILED);
160             }
161          }
162        }
163     }
164     else {
165          // result.notapplicable
166
result.addNaDetails(smh.getLocalString
167                      ("tests.componentNameConstructor", "For [ {0} ]",
168                       new Object JavaDoc[] {compName.toString()}));
169          result.notApplicable(smh.getLocalString
170                  ("com.sun.enterprise.tools.verifier.tests.webservices.notapp",
171                  "[{0}]", new Object JavaDoc[] {"Not Applicable since this is an EJB Service Endpoint"}));
172     }
173
174    return result;
175   }
176
177  }
178
179
Popular Tags