KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime;
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 /** enterprise-bean
36  * name ? [String]
37  *
38  * This is the name of the enterprise bean module
39  * @author Irfan Ahmmed
40  */

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

47     public Result check(EjbDescriptor descriptor) {
48
49     Result result = getInitializedResult();
50     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
51
52         String JavaDoc entBeanName = null;
53         String JavaDoc ejbName = null;
54         try{
55             ejbName = descriptor.getName();
56             entBeanName = getXPathValue("sun-ejb-jar/enterprise-beans/name");
57             if(entBeanName == null){
58                 result.setStatus(Result.NOT_APPLICABLE);
59                 result.addNaDetails(smh.getLocalString
60                        ("tests.componentNameConstructor",
61                     "For [ {0} ]",
62                     new Object JavaDoc[] {compName.toString()}));
63                 result.notApplicable(smh.getLocalString
64                  (getClass().getName() + ".notApplicable",
65                   "{0} Does not define any enterprise bean name",
66                   new Object JavaDoc[] {ejbName}));
67                 return result;
68             }
69             
70             if(entBeanName!=null && entBeanName.length()==0){
71                 result.addErrorDetails(smh.getLocalString
72                                    ("tests.componentNameConstructor",
73                                     "For [ {0} ]",
74                                     new Object JavaDoc[] {compName.toString()}));
75                 result.warning(smh.getLocalString
76                      (getClass().getName() + ".warning",
77                       "WARNING [AS-EJB enterprise-beans] : name should not be empty."));
78                 return result;
79             }else{
80                 result.addGoodDetails(smh.getLocalString
81                   ("tests.componentNameConstructor",
82                    "For [ {0} ]",
83                    new Object JavaDoc[] {compName.toString()}));
84                 result.passed(smh.getLocalString
85          (getClass().getName() + ".passed",
86           "PASSED [AS-EJB enterprise-beans] : name is {0}",
87           new Object JavaDoc[] {entBeanName}));
88                 return result;
89             }
90         }catch(Exception JavaDoc ex){
91             result.addErrorDetails(smh.getLocalString
92                                    ("tests.componentNameConstructor",
93                                     "For [ {0} ]",
94                                     new Object JavaDoc[] {compName.toString()}));
95             result.addErrorDetails(smh.getLocalString
96                  (getClass().getName() + ".notRun",
97                   "NOT RUN [AS-EJB] : Could not create a descriptor object"));
98             return result;
99         }
100     }
101 }
102
Popular Tags