KickJava   Java API By Example, From Geeks To Geeks.

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


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  * CheckConnectionFactoryImplClass.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 "connectionfactory-impl-class"
44  * implements "connectionfactory-interface".
45  *
46  * @author Anisha Malhotra
47  * @version
48  */

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

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