KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > wsclients > PortCompRefSEIClassCheck


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.wsclients;
24
25 import com.sun.enterprise.deployment.*;
26 import com.sun.enterprise.tools.verifier.*;
27 import com.sun.enterprise.tools.verifier.tests.*;
28 import java.util.*;
29
30 /*
31  * @class.setup_props: ;
32  */

33
34 /*
35  * @testName: check
36  * @assertion_ids: JSR109_WS_57;
37  * @test_Strategy:
38  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
39  * @testDescription: The service-endpoint-interface element defines a fully qualified Java class
40  * that represents the Service Endpoint Interface of a WSDL port.
41  */

42
43 public class PortCompRefSEIClassCheck extends WSClientTest implements WSClientCheck {
44     ComponentNameConstructor compName;
45
46     /**
47      * @param descriptor the WebServices descriptor
48      * @return <code>Result</code> the results for this assertion
49      */

50     public Result check (ServiceReferenceDescriptor descriptor) {
51
52     Result result = getInitializedResult();
53         compName = getVerifierContext().getComponentNameConstructor();
54
55         boolean pass = true;
56
57         Collection ports = descriptor.getPortsInfo();
58
59         for (Iterator it=ports.iterator(); it.hasNext();) {
60             ServiceRefPortInfo ref = (ServiceRefPortInfo)it.next();
61             if (!loadSEIClass(ref,result)) {
62                //result.fail ref.getName(), ref.getServiceEndpointInterface
63
result.addErrorDetails(smh.getLocalString
64                                   ("tests.componentNameConstructor",
65                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
66                result.failed(smh.getLocalString
67                    (getClass().getName() + ".failed",
68                     "Error: Service Endpoint Interface class [ {0} ] not found.",
69                     new Object JavaDoc[] {ref.getServiceEndpointInterface()}));
70                
71                pass = false;
72             }
73             else {
74               //result.pass
75
result.addGoodDetails(smh.getLocalString
76                                   ("tests.componentNameConstructor",
77                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
78               result.passed(smh.getLocalString (getClass().getName() + ".passed",
79               "Service Endpoint Interface class [ {0} ] found.",
80               new Object JavaDoc[] {ref.getServiceEndpointInterface()}));
81
82             }
83         }
84
85         return result;
86     }
87
88    private boolean loadSEIClass(ServiceRefPortInfo ref, Result result) {
89
90      boolean pass = true;
91
92      if (ref.hasServiceEndpointInterface()) {
93         try {
94               Class.forName(ref.getServiceEndpointInterface(), false, getVerifierContext().getClassLoader());
95            } catch (ClassNotFoundException JavaDoc e) {
96                Verifier.debug(e);
97                pass = false;
98            }
99      }
100      else {
101        //result.not applicable (SEI not specified)
102
result.addNaDetails(smh.getLocalString
103                      ("tests.componentNameConstructor", "For [ {0} ]",
104                       new Object JavaDoc[] {compName.toString()}));
105        result.notApplicable(smh.getLocalString
106                  ( getClass().getName() + ".notapp",
107                  "Not applicable since Service reference does not specify an SEI."));
108
109      }
110     return pass;
111    }
112  }
113
114
Popular Tags