KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > beanclass > EjbClassExist


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 package com.sun.enterprise.tools.verifier.tests.ejb.beanclass;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.tools.verifier.*;
28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
29 import java.util.logging.Level JavaDoc;
30
31 import com.sun.enterprise.tools.verifier.tests.*;
32
33 /**
34  * Bean class test.
35  * Verify that the bean class exist and is loadable.
36  */

37
38 public class EjbClassExist extends EjbTest implements EjbCheck {
39
40     /**
41      * Bean class test.
42      * Verify that the bean class exist and is loadable.
43      *
44      * @param descriptor the Enterprise Java Bean deployment descriptor
45      *
46      * @return <code>Result</code> the results for this assertion
47      */

48     public Result check(EjbDescriptor descriptor) {
49
50     Result result = getInitializedResult();
51     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52
53     // verify that the bean class exist and is loadable
54
try {
55         Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
56         result.addGoodDetails(smh.getLocalString
57                   ("tests.componentNameConstructor",
58                    "For [ {0} ]",
59                    new Object JavaDoc[] {compName.toString()}));
60         result.passed(smh.getLocalString
61               (getClass().getName() + ".passed",
62                "Bean class [ {0} ] exist and is loadable.",
63                new Object JavaDoc[] {descriptor.getEjbClassName()}));
64
65     } catch (NoClassDefFoundError JavaDoc e) {
66 // e.printStackTrace();
67
logger.log(Level.FINE, "Can't find class " + e.getMessage());
68         result.addErrorDetails(smh.getLocalString
69                    ("tests.componentNameConstructor",
70                     "For [ {0} ]",
71                     new Object JavaDoc[] {compName.toString()}));
72         result.failed(smh.getLocalString
73               (getClass().getName() + ".failed",
74                "Error: Bean class [ {0} ] does not exist or is not loadable.",
75                new Object JavaDoc[] {descriptor.getEjbClassName()}));
76     } catch (ClassNotFoundException JavaDoc e) {
77         Verifier.debug(e);
78         result.addErrorDetails(smh.getLocalString
79                    ("tests.componentNameConstructor",
80                     "For [ {0} ]",
81                     new Object JavaDoc[] {compName.toString()}));
82         result.failed(smh.getLocalString
83               (getClass().getName() + ".failed",
84                "Error: Bean class [ {0} ] does not exist or is not loadable.",
85                new Object JavaDoc[] {descriptor.getEjbClassName()}));
86     } catch (Exception JavaDoc e) {
87 // e.printStackTrace();
88
result.addErrorDetails(smh.getLocalString
89                    ("tests.componentNameConstructor",
90                     "For [ {0} ]",
91                     new Object JavaDoc[] {compName.toString()}));
92         result.failed(smh.getLocalString
93               (getClass().getName() + ".failed",
94                "Error: Bean class [ {0} ] does not exist or is not loadable.",
95                new Object JavaDoc[] {descriptor.getEjbClassName()}));
96     }
97     return result;
98     }
99 }
100
Popular Tags