KickJava   Java API By Example, From Geeks To Geeks.

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


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  * CheckConnectionFactoryImplSerializable.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 java.io.Serializable
45  *
46  * @author Anisha Malhotra
47  * @version
48  */

49 public class CheckConnectionFactoryImplSerializable
50     extends ConnectorTest
51     implements ConnectorCheck
52 {
53
54   /** <p>
55    * Test for each connection-definition, that "connectionfactory-impl-class"
56    * implements java.io.Serializable
57    * </p>
58    *
59    * @param 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 connectionImpl = connDefDesc.getConnectionFactoryImpl();
94       Class JavaDoc implClass = null;
95       try
96       {
97         implClass = Class.forName(connectionImpl, false, getVerifierContext().getClassLoader());
98       }
99       catch(ClassNotFoundException JavaDoc e)
100       {
101         result.addErrorDetails(smh.getLocalString
102             ("tests.componentNameConstructor",
103              "For [ {0} ]",
104              new Object JavaDoc[] {compName.toString()}));
105         result.failed(smh.getLocalString
106             (getClass().getName() + ".nonexist",
107              "Error: The class [ {0} ] as defined under connectionfactory-impl-class in the deployment descriptor does not exist",
108              new Object JavaDoc[] {connectionImpl}));
109         return result;
110       }
111       if(!isImplementorOf(implClass, "java.io.Serializable"))
112       {
113         oneFailed = true;
114         result.addErrorDetails(smh.getLocalString
115             ("tests.componentNameConstructor",
116              "For [ {0} ]",
117              new Object JavaDoc[] {compName.toString()}));
118         result.failed(smh.getLocalString(getClass().getName() + ".failed",
119               "Error: connectionfactory-impl-class [ {0} ] does not implement java.io.Serializable",
120               new Object JavaDoc[] {implClass.getName()}));
121         return result;
122       }
123     }
124     if(!oneFailed)
125     {
126       result.addGoodDetails(smh.getLocalString
127           ("tests.componentNameConstructor",
128            "For [ {0} ]",
129            new Object JavaDoc[] {compName.toString()}));
130       result.passed(smh.getLocalString(getClass().getName() + ".passed",
131             "Success: all connectionfactory-impl-class implement java.io.Serializable"));
132     }
133     return result;
134   }
135 }
136
Popular Tags