KickJava   Java API By Example, From Geeks To Geeks.

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


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 import javax.xml.namespace.QName JavaDoc;
25 import com.sun.enterprise.deployment.WebServiceEndpoint;
26 import com.sun.enterprise.tools.verifier.Result;
27 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
28 /*
29  * @class.setup_props: ;
30  */

31
32 /*
33  * @testName: check
34  * @assertion_ids:
35  * @test_Strategy:
36  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
37  * @testDescription:
38  * Requirement from Web Service for J2EE, Version 1.0
39  * Section 7.1.2
40  * " Port s QName. In addition to specifying the WSDL document,
41  * the developer must also specify the WSDL port QName in the
42  * wsdl-port element for each Port defined in the deployment descriptor.
43  * Requirement from Web Service for J2EE, Version 1.0
44  * 7.1.5 Web Services Deployment Descriptor DTD
45  * <!-- The port-component element associates a WSDL port with a
46  * Web service interface and implementation. It defines the name
47  * of the port as a component, optional description, optional display name,
48  * optional iconic representations, WSDL port QName, Service Endpoint Interface,
49  * Service Implementation Bean. Used in: webservices -->
50  * <!ELEMENT port-component (description?, display-name?, small-icon?, large-icon?,
51  * port-component-name, wsdl-port, service-endpoint-interface, service-impl-bean, handler*)>
52  */

53
54 public class WSWsdlPort extends WSTest implements WSCheck {
55     /**
56      * @param descriptor the WebServices descriptor
57      * @return <code>Result</code> the results for this assertion
58      */

59     public Result check (WebServiceEndpoint descriptor) {
60         
61     Result result = getInitializedResult();
62         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
63         boolean pass = true;
64         try {
65
66           javax.xml.namespace.QName JavaDoc wsdlport = descriptor.getWsdlPort();
67           // check to see that wsdl-port is specified in the service endpoint.
68
if ( wsdlport != null) {
69              // get the local part
70
String JavaDoc localpart = wsdlport.getLocalPart();
71              // String namespaceuri = wsdlport.getNamespaceURI();
72

73              if ( localpart == null || localpart.equals("") ) {
74                 // Error: localpart is not specified
75
pass = false;
76              }
77              
78               //if ( namespaceuri == null || namespaceuri.equals("")) {
79
//pass = false;
80
//}
81

82           } else {
83             // Error: wsdl-port is missing for this endpoint
84
pass = false;
85           }
86
87           if (pass) {
88               result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
89                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
90               result.passed(smh.getLocalString (getClass().getName() + ".passed",
91                           "The wsdl-port in the webservices.xml file for [{0}] is specified for the endpoint",
92                            new Object JavaDoc[] {compName.toString()}));
93             }
94             else {
95              result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
96                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
97              result.failed(smh.getLocalString (getClass().getName() + ".failed",
98                "The wsdl-port in the webservices.xml file for [{0}] is not correctly specified for the endpoint",
99                 new Object JavaDoc[] {compName.toString()}));
100             }
101         }catch (Exception JavaDoc e) {
102             //result.fail
103
result.addErrorDetails(smh.getLocalString
104                ("com.sun.enterprise.tools.verifier.tests.webservices.Error",
105                 "Error: Unexpected error occurred [ {0} ]",
106                 new Object JavaDoc[] {e.getMessage()}));
107         }
108         return result;
109     }
110 }
111
Popular Tags