KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > messageinflow > CheckActivationSpecSerializable


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

28
29 package com.sun.enterprise.tools.verifier.tests.connector.messageinflow;
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.InboundResourceAdapter;
37 import com.sun.enterprise.deployment.MessageListener;
38 import com.sun.enterprise.tools.verifier.tests.*;
39 import java.util.Iterator JavaDoc;
40 import java.util.Set JavaDoc;
41
42 /**
43  * Test that "activationspec-class" implements java.io.Serializable
44  *
45  * @author Anisha Malhotra
46  * @version
47  */

48 public class CheckActivationSpecSerializable
49     extends ConnectorTest
50     implements ConnectorCheck
51 {
52
53   /** <p>
54    * Test that "activationspec-class" implements java.io.Serializable
55    * </p>
56    *
57    * @param descriptor deployment descriptor for the rar file
58    * @return result object containing the result of the individual test
59    * performed
60    */

61   public Result check(ConnectorDescriptor descriptor) {
62
63     Result result = getInitializedResult();
64     ComponentNameConstructor compName =
65       getVerifierContext().getComponentNameConstructor();
66
67     if(!descriptor.getInBoundDefined())
68     {
69       result.addNaDetails(smh.getLocalString
70           ("tests.componentNameConstructor",
71            "For [ {0} ]",
72            new Object JavaDoc[] {compName.toString()}));
73       result.notApplicable(smh.getLocalString
74           ("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.notApp",
75            "Resource Adapter does not provide inbound communication"));
76       return result;
77     }
78     InboundResourceAdapter ra = descriptor.getInboundResourceAdapter();
79     Set JavaDoc msgListeners = ra.getMessageListeners();
80     boolean oneFailed = false;
81     Iterator JavaDoc iter = msgListeners.iterator();
82     while(iter.hasNext())
83     {
84       MessageListener msgListener = (MessageListener) iter.next();
85       String JavaDoc impl = msgListener.getActivationSpecClass();
86       Class JavaDoc implClass = null;
87       try
88       {
89         implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
90       }
91       catch(ClassNotFoundException JavaDoc e)
92       {
93         result.addErrorDetails(smh.getLocalString
94             ("tests.componentNameConstructor",
95              "For [ {0} ]",
96              new Object JavaDoc[] {compName.toString()}));
97         result.failed(smh.getLocalString
98             ("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.nonexist",
99              "Error: The class [ {0} ] as defined under activationspec-class in the deployment descriptor does not exist",
100              new Object JavaDoc[] {impl}));
101         return result;
102       }
103       if(!isImplementorOf(implClass, "java.io.Serializable"))
104       {
105         oneFailed = true;
106         result.addErrorDetails(smh.getLocalString
107             ("tests.componentNameConstructor",
108              "For [ {0} ]",
109              new Object JavaDoc[] {compName.toString()}));
110         result.failed(smh.getLocalString(getClass().getName() + ".failed",
111               "Error: activationspec-class [ {0} ] does not implement java.io.Serializable",
112               new Object JavaDoc[] {impl}));
113         return result;
114       }
115     }
116     if(!oneFailed)
117     {
118       result.addGoodDetails(smh.getLocalString
119           ("tests.componentNameConstructor",
120            "For [ {0} ]",
121            new Object JavaDoc[] {compName.toString()}));
122       result.passed(smh.getLocalString(getClass().getName() + ".passed",
123             "Success: all activationspec-class implement java.io.Serializable"));
124     }
125     return result;
126   }
127 }
128
Popular Tags