KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > ias > ASEntBeanName


1 package com.sun.enterprise.tools.verifier.tests.ejb.ias;
2
3 /*
4  * The contents of this file are subject to the terms
5  * of the Common Development and Distribution License
6  * (the License). You may not use this file except in
7  * compliance with the License.
8  *
9  * You can obtain a copy of the license at
10  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
11  * glassfish/bootstrap/legal/CDDLv1.0.txt.
12  * See the License for the specific language governing
13  * permissions and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL
16  * Header Notice in each file and include the License file
17  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
18  * If applicable, add the following below the CDDL Header,
19  * with the fields enclosed by brackets [] replaced by
20  * you own identifying information:
21  * "Portions Copyrighted [year] [name of copyright owner]"
22  *
23  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24  */

25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import java.util.*;
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.deployment.EjbSessionDescriptor;
30 import com.sun.enterprise.tools.verifier.*;
31 import com.sun.enterprise.tools.verifier.tests.*;
32
33 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
34
35 import com.sun.enterprise.tools.common.dd.ejb.SunEjbJar;
36 import com.sun.enterprise.tools.common.dd.ejb.EnterpriseBeans;
37 /** enterprise-bean
38  * name ? [String]
39  *
40  * This is the name of the enterprise bean module
41  * @author Irfan Ahmmed
42  */

43 public class ASEntBeanName extends EjbTest implements EjbCheck {
44
45
46
47     /**
48      * @param descriptor the Enterprise Java Bean deployment descriptor
49      * @return <code>Result</code> the results for this assertion
50      */

51     public Result check(EjbDescriptor descriptor) {
52
53     Result result = getInitializedResult();
54     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
55
56         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
57         String JavaDoc ejbName = null;
58         
59         if(descriptor.getEjbBundleDescriptor().getTestsDone().contains(getClass().getName()))
60         {
61             result.setStatus(Result.NOT_RUN);
62             result.addGoodDetails(smh.getLocalString("enterpriseBeans.allReadyRun",
63                 "NOT RUN [AS-EJB enterprise-beans] name test is a JAR Level Test. This test has already been run once"));
64             return result;
65         }
66         descriptor.getEjbBundleDescriptor().setTestsDone(getClass().getName());
67         
68         if(ejbJar!=null)
69         {
70             EnterpriseBeans entBean = ejbJar.getEnterpriseBeans();
71             String JavaDoc entBeanName = entBean.getName();
72             if(entBeanName == null)
73             {
74                 result.setStatus(Result.NOT_APPLICABLE);
75                 result.addNaDetails(smh.getLocalString
76                        ("tests.componentNameConstructor",
77                     "For [ {0} ]",
78                     new Object JavaDoc[] {compName.toString()}));
79                 result.notApplicable(smh.getLocalString
80                  (getClass().getName() + ".notApplicable",
81                   "{0} Does not define any enterprise bean name",
82                   new Object JavaDoc[] {ejbName}));
83                 return result;
84             }
85             if(entBeanName!=null && entBeanName.length()==0)
86             {
87                 result.addErrorDetails(smh.getLocalString
88                                    ("tests.componentNameConstructor",
89                                     "For [ {0} ]",
90                                     new Object JavaDoc[] {compName.toString()}));
91                 result.warning(smh.getLocalString
92                      (getClass().getName() + ".warning",
93                       "WARNING [AS-EJB enterprise-beans] : name should not be empty."));
94                 return result;
95             }
96             else
97             {
98                 result.addGoodDetails(smh.getLocalString
99                   ("tests.componentNameConstructor",
100                    "For [ {0} ]",
101                    new Object JavaDoc[] {compName.toString()}));
102                 result.passed(smh.getLocalString
103          (getClass().getName() + ".passed",
104           "PASSED [AS-EJB enterprise-beans] : name is {0}",
105           new Object JavaDoc[] {entBeanName}));
106                 return result;
107             }
108         }
109         else
110         {
111             result.addErrorDetails(smh.getLocalString
112                                    ("tests.componentNameConstructor",
113                                     "For [ {0} ]",
114                                     new Object JavaDoc[] {compName.toString()}));
115             result.addErrorDetails(smh.getLocalString
116                  (getClass().getName() + ".notRun",
117                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
118             return result;
119         }
120     }
121 }
122
123
Popular Tags