KickJava   Java API By Example, From Geeks To Geeks.

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


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.deployment.deploy.shared.FileArchive;
27 import com.sun.enterprise.tools.verifier.*;
28 import com.sun.enterprise.tools.verifier.tests.*;
29 import java.io.*;
30
31 /*
32  * @class.setup_props: ;
33  */

34
35 /*
36  * @testName: check
37  * @assertion_ids: JSR109_WS_15; JSR109_WS_25;
38  * @test_Strategy:
39  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
40  * @testDescription: The developer is responsible for packaging, either by containment or
41  * reference, the WSDL file, Service Endpoint Interface class, Service Implementation Bean
42  * class, and their dependent classes, JAX-RPC mapping file along with a Web services
43  * deployment descriptor in a J2EE module.
44  *
45  * The wsdl-file element specifies a location of the WSDL description of a set of Web
46  * services. The location is relative to the root of the module and must be specified
47  * by the developer.
48  */

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

56     public Result check (WebServiceEndpoint descriptor) {
57
58     Result result = getInitializedResult();
59         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
60
61 // boolean pass = true;
62

63 // File f = Verifier.getArchiveFile(descriptor.getBundleDescriptor().
64
// getModuleDescriptor().getArchiveUri());
65
// JarFile jarFile = null;
66
InputStream deploymentEntry=null;
67
68         // wsdl file
69
String JavaDoc wsdlUri = descriptor.getWebService().getWsdlFileUri();
70
71         try {
72 // if (f == null) {
73
String JavaDoc uri = getAbstractArchiveUri(descriptor);
74 // try {
75
FileArchive arch = new FileArchive();
76                  arch.open(uri);
77                  deploymentEntry = arch.getEntry(wsdlUri);
78 // }catch (IOException e) { throw e;}
79
// }
80
// else {
81
//
82
// jarFile = new JarFile(f);
83
// ZipEntry deploymentEntry1 =
84
// jarFile.getEntry(wsdlUri);
85
// deploymentEntry = jarFile.getInputStream(deploymentEntry1);
86
// }
87
if (deploymentEntry == null) {
88                //result.fail,
89
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
90                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
91                 result.failed(smh.getLocalString (getClass().getName() + ".failed",
92                 "WSDL file does not exist in the archive at uri [{0}].",
93                 new Object JavaDoc[] {wsdlUri}));
94
95 // pass = false;
96
}
97             else {
98                //result.pass
99
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
100                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
101                result.passed(smh.getLocalString (getClass().getName() + ".passed",
102                           "WSDL file exists in the archive at uri [{0}].",
103                            new Object JavaDoc[] {wsdlUri}));
104
105             }
106         }catch (Exception JavaDoc e) {
107           // result.fail
108
result.addErrorDetails(smh.getLocalString
109                ("com.sun.enterprise.tools.verifier.tests.webservices.Error",
110                 "Error: Unexpected error occurred [ {0} ]",
111                 new Object JavaDoc[] {e.getMessage()}));
112 // pass = false;
113
}
114         finally {
115            try {
116            if (deploymentEntry != null)
117                deploymentEntry.close();
118            }catch(IOException e) {}
119         }
120
121         return result;
122     }
123  }
124
125
Popular Tags