KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > webservices > 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.webservices;
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 // Make sure we are able to load the Handler classes
32
/*
33  * @class.setup_props: ;
34  */

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

44 public class HandlerClassCheck extends WSTest implements WSCheck {
45
46     /**
47      * @param descriptor the WebServices descriptor
48      * @return <code>Result</code> the results for this assertion
49      */

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