KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > messagebean > MessageBeanTest


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
25 package com.sun.enterprise.tools.verifier.tests.ejb.messagebean;
26
27 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
28 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
29 import com.sun.enterprise.deployment.EjbDescriptor;
30 import com.sun.enterprise.tools.verifier.Result;
31 import com.sun.enterprise.tools.verifier.*;
32 import java.lang.ClassLoader JavaDoc;
33 import com.sun.enterprise.tools.verifier.tests.*;
34
35 /**
36  * Superclass for all the Message Bean tests
37  *
38  * @author Jerome Dochez
39  * @version
40  */

41 abstract public class MessageBeanTest extends EjbTest {
42     
43     /**
44      * Run a verifier test against an individual declared message
45      * drive bean component
46      *
47      * @param descriptor the Enterprise Java Bean deployment descriptor
48      *
49      * @return <code>Result</code> the results for this assertion
50      */

51     abstract public Result check(EjbMessageBeanDescriptor descriptor);
52     ComponentNameConstructor compName = null;
53
54     /**
55      *
56      * Container-managed persistent fields test, iterates over all declared
57      * cmp fields and invoke the runIndividualCmpFieldTest nethod
58      *
59      * @param descriptor the Enterprise Java Bean deployment descriptor
60      *
61      * @return <code>Result</code> the results for this assertion
62      */

63     public Result check(EjbDescriptor descriptor) {
64         
65         if (descriptor instanceof EjbMessageBeanDescriptor) {
66             return check((EjbMessageBeanDescriptor) descriptor);
67         } else {
68             Result result = getInitializedResult();
69         compName = getVerifierContext().getComponentNameConstructor();
70         result.addNaDetails(smh.getLocalString
71                    ("tests.componentNameConstructor",
72                     "For [ {0} ]",
73                     new Object JavaDoc[] {compName.toString()}));
74         result.notApplicable(smh.getLocalString
75         ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.MessageBeanTest.notApplicable",
76          "Test apply only to message-driven Bean components"));
77             return result;
78         }
79     }
80     
81     /**
82      * <p>
83      * load the declared message bean class from the archive
84      * </p>
85      *
86      * @param descriptor deployment descriptor for the message bean
87      * @param result result to use if failure
88      * @return the message bean class
89      */

90     protected Class JavaDoc loadMessageBeanClass(EjbMessageBeanDescriptor descriptor, Result result) {
91         try {
92         compName = getVerifierContext().getComponentNameConstructor();
93             Context context = getVerifierContext();
94         ClassLoader JavaDoc jcl = context.getClassLoader();
95             return Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
96         } catch (ClassNotFoundException JavaDoc e) {
97             Verifier.debug(e);
98         result.addErrorDetails(smh.getLocalString
99                    ("tests.componentNameConstructor",
100                     "For [ {0} ]",
101                     new Object JavaDoc[] {compName.toString()}));
102         result.failed(smh.getLocalString
103            ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.classnotfoundexception",
104                "Cannot load declared message-driven bean component [ {0} ]"));
105             return null;
106         }
107     }
108 }
109
Popular Tags