KickJava   Java API By Example, From Geeks To Geeks.

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


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_30;
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 * jaxrpc-mapping-file The file name is a relative path within the module.
46 */

47 public class MappingFileCheck extends WSTest implements WSCheck {
48
49     /**
50      * @param descriptor the WebServices descriptor
51      * @return <code>Result</code> the results for this assertion
52      */

53     public Result check (WebServiceEndpoint descriptor) {
54
55         Result result = getInitializedResult();
56         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
57         String JavaDoc mappingFile = descriptor.getWebService().getMappingFileUri();
58         if (getVerifierContext().getSchemaVersion().compareTo("1.1") > 0) {
59             if (mappingFile != null) {
60                 addWarningDetails(result, compName);
61                 result.warning(smh.getLocalString (getClass().getName() + ".warning",
62                         "The mapping file as specified in location [ {0} ] is not required.",
63                         new Object JavaDoc[] {mappingFile}));
64                 return result;
65             }
66         } else {
67             InputStream deploymentEntry=null;
68             try {
69                 String JavaDoc uri = getAbstractArchiveUri(descriptor);
70                 try {
71                     FileArchive arch = new FileArchive();
72                     arch.open(uri);
73                     deploymentEntry = arch.getEntry(mappingFile);
74                 }catch (IOException e) { throw e;}
75                 if (deploymentEntry == null) {
76                     //result.fail, mapping file does not exist at that location
77
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
78                             "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
79                     result.failed(smh.getLocalString (getClass().getName() + ".failed",
80                             "The mapping file does not exist at the specified location [{0}] in the archive.",
81                             new Object JavaDoc[] {mappingFile}));
82
83                 }
84             }catch (Exception JavaDoc e) {
85                 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
86                         "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
87                 result.failed(smh.getLocalString (getClass().getName() + ".failed",
88                         "The mapping file does not exist at the specified location [{0}] in the archive.",
89                         new Object JavaDoc[] {mappingFile}));
90             }
91             finally {
92                 try {
93                     if (deploymentEntry != null)
94                         deploymentEntry.close();
95                 }catch(IOException e) {}
96             }
97         }
98         if(result.getStatus() != Result.FAILED || result.getStatus() != Result.WARNING) {
99             addGoodDetails(result, compName);
100             result.passed(smh.getLocalString (getClass().getName() + ".passed",
101                     "mapping file requirements are satisfied"));
102         }
103         return result;
104     }
105 }
106
Popular Tags