KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.*;
28 import com.sun.enterprise.tools.verifier.tests.*;
29 import java.lang.reflect.*;
30
31 /*
32  * @class.setup_props: ;
33  */

34
35 /*
36  * @testName: check
37  * @assertion_ids: JSR109_WS_52;
38  * @test_Strategy:
39  * @class.testArgs: Additional arguments (if any) to be passed when execing the client
40  * @testDescription: handler-class Defines a fully qualified class name for the handler
41  * implementation.
42  */

43
44 // Make sure we are able to load the Handler classes
45
public class HandlerClassCheck extends WSClientTest implements WSClientCheck {
46
47     /**
48      * @param descriptor the WebServices descriptor
49      * @return <code>Result</code> the results for this assertion
50      */

51     public Result check (ServiceReferenceDescriptor descriptor) {
52
53     Result result = getInitializedResult();
54         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
55         ClassLoader JavaDoc loader = getVerifierContext().getClassLoader();
56
57         if (descriptor.hasHandlers()) {
58            List handlerChain = descriptor.getHandlerChain();
59            for (Iterator it = handlerChain.iterator(); it.hasNext();) {
60                 String JavaDoc hClass = ((WebServiceHandler)it.next()).getHandlerClass();
61                 Class JavaDoc cl = null;
62                 try {
63                   cl = Class.forName(hClass, false, getVerifierContext().getClassLoader());
64                   if ((cl != null) && ((javax.xml.rpc.handler.Handler JavaDoc.class).isAssignableFrom(cl))) {
65                     //result.pass
66
result.addGoodDetails(smh.getLocalString
67                                   ("tests.componentNameConstructor",
68                                    "For [ {0} ]",
69                                    new Object JavaDoc[] {compName.toString()}));
70                     result.passed(smh.getLocalString (getClass().getName() + ".passed",
71              "The Handler Class [{0}] exists and implements the javax.xml.rpc.handler.Handler Interface.",
72                      new Object JavaDoc[] {hClass}));
73
74                   }
75                   else {
76                      result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
77                          "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
78                         result.failed(smh.getLocalString (getClass().getName() + ".failed",
79                         "Handler Class [{0}] does not implement javax.xml.rpc.handler.Handler",
80                         new Object JavaDoc[] {hClass}));
81                     
82                   }
83                 }
84                 catch (ClassNotFoundException JavaDoc e) {
85                     // result.fail, handler class not found
86
result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
87                  "For [ {0} ]", new Object JavaDoc[] {compName.toString()}));
88                  result.failed(smh.getLocalString (
89                  "com.sun.enterprise.tools.verifier.tests.webservices.clfailed",
90                  "The [{0}] Class [{1}] could not be Loaded",
91                   new Object JavaDoc[] {"Handler Class", hClass}));
92
93                 }
94            }
95         }
96         else {
97          // result.NotApplicable
98
result.addNaDetails(smh.getLocalString
99                      ("tests.componentNameConstructor", "For [ {0} ]",
100                       new Object JavaDoc[] {compName.toString()}));
101           result.notApplicable(smh.getLocalString
102                 ( getClass().getName() + ".notapp",
103                  "Not Applicable since No handlers defined in this WebService"));
104         }
105
106         return result;
107     }
108  }
109
110
Popular Tags