KickJava   Java API By Example, From Geeks To Geeks.

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


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  * CheckActivationSpecOverridesEquals .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.lang.reflect.Method JavaDoc;
40 import java.util.Iterator JavaDoc;
41 import java.util.Set JavaDoc;
42
43 /**
44  * Test for each message-listener , that "activationspec-class"
45  * does not override the equals method.
46  *
47  * @author Anisha Malhotra
48  * @version
49  */

50 public class CheckActivationSpecOverridesEquals
51 extends ConnectorTest
52 implements ConnectorCheck
53 {
54
55   /** <p>
56    * Test for each message-listener , that "activationspec-class"
57    * does not override the equals method.
58    * </p>
59    *
60    * @param 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     if(!descriptor.getInBoundDefined())
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.messageinflow.notApp",
77            "Resource Adapter does not provide inbound communication"));
78       return result;
79     }
80     InboundResourceAdapter ra = descriptor.getInboundResourceAdapter();
81     Set JavaDoc msgListeners = ra.getMessageListeners();
82     boolean oneFailed = false;
83     Iterator JavaDoc iter = msgListeners.iterator();
84     while(iter.hasNext())
85     {
86       MessageListener msgListener = (MessageListener) iter.next();
87       String JavaDoc impl = msgListener.getActivationSpecClass();
88       Class JavaDoc implClass = null;
89       try
90       {
91         implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
92       }
93       catch(ClassNotFoundException JavaDoc e)
94       {
95         result.addErrorDetails(smh.getLocalString
96             ("tests.componentNameConstructor",
97              "For [ {0} ]",
98              new Object JavaDoc[] {compName.toString()}));
99         result.failed(smh.getLocalString
100             ("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.nonexist",
101              "Error: The class [ {0} ] as defined under activationspec-class in the deployment descriptor does not exist",
102              new Object JavaDoc[] {impl}));
103         return result;
104       }
105       try
106       {
107         Method JavaDoc equalsMethod = implClass.getMethod("equals",
108             new Class JavaDoc[] {implClass});
109         oneFailed = true;
110         result.addErrorDetails(smh.getLocalString
111             ("tests.componentNameConstructor",
112              "For [ {0} ]",
113              new Object JavaDoc[] {compName.toString()}));
114         result.failed(smh.getLocalString(getClass().getName() + ".failed",
115               "Error: activationspec-class [ {0} ] overrides the equals method",
116               new Object JavaDoc[] {impl}));
117         return result;
118       }
119       catch(NoSuchMethodException JavaDoc e)
120       {
121         // implClass does not override equals.
122
}
123       catch(SecurityException JavaDoc e)
124       {
125       }
126     }
127     if(!oneFailed)
128     {
129       result.addGoodDetails(smh.getLocalString
130           ("tests.componentNameConstructor",
131            "For [ {0} ]",
132            new Object JavaDoc[] {compName.toString()}));
133       result.passed(smh.getLocalString(getClass().getName() + ".passed",
134             "Success: all activationspec-class do not override the equals method"));
135     }
136     return result;
137   }
138 }
139
Popular Tags