KickJava   Java API By Example, From Geeks To Geeks.

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


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_16; JSR109_WS_17;
38  * @test_Strategy:
39  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
40  * @testDescription: The Web services deployment descriptor location within the EJB-JAR file
41  * is META-INF/webservices.xml.
42  *
43  * A Web services deployment descriptor is located in a WAR at WEB-INF/webservices.xml.
44  */

45
46 public class WSXMLLocCheck extends WSTest implements WSCheck {
47
48     // webservices.xml
49
private String JavaDoc ejbWSXmlLoc = "META-INF/webservices.xml";
50     private String JavaDoc jaxrpcWSXmlLoc = "WEB-INF/webservices.xml";
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         try {
69 // if (f == null) {
70
String JavaDoc uri = getAbstractArchiveUri(descriptor);
71 // try {
72
FileArchive arch = new FileArchive();
73                  arch.open(uri);
74                  if (descriptor.implementedByEjbComponent()) {
75                     deploymentEntry = arch.getEntry(ejbWSXmlLoc);
76                  }
77                  else if (descriptor.implementedByWebComponent()) {
78                     deploymentEntry = arch.getEntry(jaxrpcWSXmlLoc);
79                  }
80                  else {
81                     throw new Exception JavaDoc("Niether implemented by EJB nor by WEB Component");
82                  }
83 // }catch (IOException e) { throw e;}
84
// }
85
// else {
86
//
87
// jarFile = new JarFile(f);
88
// ZipEntry deploymentEntry1 = null;
89
// if (descriptor.implementedByEjbComponent()) {
90
// deploymentEntry1 = jarFile.getEntry(ejbWSXmlLoc);
91
// }
92
// else if (descriptor.implementedByWebComponent()) {
93
// deploymentEntry1 = jarFile.getEntry(jaxrpcWSXmlLoc);
94
// }
95
// else {
96
// throw new Exception("Niether implemented by EJB nor by WEB Component");
97
// }
98
// deploymentEntry = jarFile.getInputStream(deploymentEntry1);
99
// }
100
if (deploymentEntry != null) {
101               // webservices XML exists
102
// result.pass
103
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
104                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
105               result.passed(smh.getLocalString (getClass().getName() + ".passed",
106                           "The webservices.xml file for [{0}] is located at the correct place.",
107                            new Object JavaDoc[] {compName.toString()}));
108
109             }
110             else {
111              // ws xml is does not exist
112
//result.fail
113
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
114                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
115              result.failed(smh.getLocalString (getClass().getName() + ".failed",
116                "The webservices.xml file for [{0}] is not located in WEB-INF/META-INF directory as applicable.",
117                 new Object JavaDoc[] {compName.toString()}));
118
119 // pass = false;
120
}
121         }catch (Exception JavaDoc e) {
122             //result.fail
123
result.addErrorDetails(smh.getLocalString
124                ("com.sun.enterprise.tools.verifier.tests.webservices.Error",
125                 "Error: Unexpected error occurred [ {0} ]",
126                 new Object JavaDoc[] {e.getMessage()}));
127 // pass = false;
128
}
129         finally {
130
131            try {
132            if (deploymentEntry != null)
133                deploymentEntry.close();
134            }catch (IOException e) {}
135         }
136
137         return result;
138     }
139  }
140
141
Popular Tags