KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > managed > CheckConnectionImplClass


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 /*
24  * CheckConnectionImplClass.java
25  *
26  * Created on August 29, 2002
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector.managed;
30
31 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest;
32 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck;
33 import com.sun.enterprise.tools.verifier.Result;
34 import com.sun.enterprise.tools.verifier.*;
35 import com.sun.enterprise.deployment.ConnectorDescriptor;
36 import com.sun.enterprise.deployment.ConnectionDefDescriptor;
37 import com.sun.enterprise.deployment.OutboundResourceAdapter;
38 import com.sun.enterprise.tools.verifier.tests.*;
39 import java.util.Iterator JavaDoc;
40 import java.util.Set JavaDoc;
41
42 /**
43  * Test for each connection-definition, that "connection-impl-class"
44  * implements "connection-interface".
45  * interface in the rar file
46  *
47  * @author Anisha Malhotra
48  * @version
49  */

50 public class CheckConnectionImplClass
51     extends ConnectorTest
52     implements ConnectorCheck
53 {
54
55   /** <p>
56    * Test for each connection-definition, that "connection-impl-class"
57    * implements "connection-interface".
58    * </p>
59    *
60    * @ paramm descriptor deployment descriptor for the rar file
61    * @return result object containing the result of the individual test
62    * performed
63    */

64   public Result check(ConnectorDescriptor descriptor) {
65
66     Result result = getInitializedResult();
67     ComponentNameConstructor compName =
68       getVerifierContext().getComponentNameConstructor();
69     // test NA for inboundRA
70
if(!descriptor.getOutBoundDefined())
71     {
72       result.addNaDetails(smh.getLocalString
73           ("tests.componentNameConstructor",
74            "For [ {0} ]",
75            new Object JavaDoc[] {compName.toString()}));
76       result.notApplicable(smh.getLocalString
77           ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA",
78            "Resource Adapter does not provide outbound communication"));
79       return result;
80     }
81     OutboundResourceAdapter outboundRA =
82       descriptor.getOutboundResourceAdapter();
83     if(outboundRA == null)
84     {
85       return null;
86     }
87     boolean oneFailed = false;
88     Set JavaDoc connDefs = outboundRA.getConnectionDefs();
89     Iterator JavaDoc iter = connDefs.iterator();
90     while(iter.hasNext())
91     {
92       ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor)
93         iter.next();
94       String JavaDoc connectionInterface = connDefDesc.getConnectionIntf();
95       String JavaDoc connectionImpl = connDefDesc.getConnectionImpl();
96       Class JavaDoc implClass = null;
97       try
98       {
99       implClass = Class.forName(connectionImpl, false, getVerifierContext().getClassLoader());
100       }
101       catch(ClassNotFoundException JavaDoc e)
102       {
103         result.addErrorDetails(smh.getLocalString
104             ("tests.componentNameConstructor",
105              "For [ {0} ]",
106              new Object JavaDoc[] {compName.toString()}));
107         result.failed(smh.getLocalString
108             (getClass().getName() + ".nonexist",
109              "Error: The class [ {0} ] as defined under connection-impl-class in the deployment descriptor does not exist",
110              new Object JavaDoc[] {connectionImpl}));
111         return result;
112       }
113       if(!isImplementorOf(implClass, connectionInterface))
114       {
115         oneFailed = true;
116         result.addErrorDetails(smh.getLocalString
117             ("tests.componentNameConstructor",
118              "For [ {0} ]",
119              new Object JavaDoc[] {compName.toString()}));
120         result.failed(smh.getLocalString(getClass().getName() + ".failed",
121               "Error: connection-impl-class [ {0} ] does not implement connection-interface [ {1} ].",
122               new Object JavaDoc[] {implClass.getName(), connectionInterface}));
123         return result;
124       }
125     }
126     if(!oneFailed)
127     {
128       result.addGoodDetails(smh.getLocalString
129           ("tests.componentNameConstructor",
130            "For [ {0} ]",
131            new Object JavaDoc[] {compName.toString()}));
132       result.passed(smh.getLocalString(getClass().getName() + ".passed",
133             "Success: all connection-impl-class implement their corresponding connection-interface"));
134     }
135     return result;
136   }
137 }
138
Popular Tags