KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.IOException JavaDoc;
29 import java.lang.reflect.*;
30 import java.util.*;
31
32 /*
33  * @class.setup_props: ;
34  */

35
36 /*
37  * @testName: check
38  * @assertion_ids: JSR109_WS_49;
39  * @test_Strategy:
40  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
41  * @testDescription: The service-interface element declares the fully qualified class name of
42  * the JAX-RPC Service interface the client depends on. In most cases the value will be
43  * javax.xml.rpc.Service. A JAX-RPC generated Service Interface class may also be specified.
44  */

45
46 public class ServiceRefCheck extends WSClientTest implements WSClientCheck {
47
48     /**
49      * @param descriptor the WebServices descriptor
50      * @return <code>Result</code> the results for this assertion
51      */

52     public Result check (ServiceReferenceDescriptor descriptor) {
53
54     Result result = getInitializedResult();
55         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
56         boolean pass = true;
57
58         if (descriptor.hasGenericServiceInterface()) {
59            //result.pass , has generic service interface
60
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
61                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
62            result.passed(smh.getLocalString (getClass().getName() + ".passed",
63            "The JAX-RPC Service interface the client depends on is the Generic Service Interface."));
64
65            
66         }
67         else if (descriptor.hasGeneratedServiceInterface()) {
68            String JavaDoc intf = descriptor.getServiceInterface();
69            try {
70              Class JavaDoc cl = Class.forName(intf, false, getVerifierContext().getClassLoader());
71                // result.pass
72
result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
73                                    "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
74              result.passed(smh.getLocalString (getClass().getName() + ".passed1",
75              "The JAX-RPC Service interface the client depends on is a Generated Service Interface [{0}].",
76               new Object JavaDoc[] {intf}));
77
78            }catch (ClassNotFoundException JavaDoc e) {
79             //result.fail; Generated service interface class does not exist
80
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
81             "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
82             result.failed(smh.getLocalString (getClass().getName() + ".failed",
83             "The JAX-RPC Service interface the client depends on [{0}] could not be loaded.",
84             new Object JavaDoc[] {intf}));
85
86             pass = false;
87           }
88         }
89         else {
90           //result.internal error, its neither type, or error in XML
91
result.addErrorDetails(smh.getLocalString
92                ("com.sun.enterprise.tools.verifier.tests.webservices.Error",
93                 "Error: Unexpected error occurred [ {0} ]",
94                 new Object JavaDoc[] {"Service Interface Neither Generic nor Generated"}));
95         }
96
97         return result;
98     }
99  }
100
101
Popular Tags