KickJava   Java API By Example, From Geeks To Geeks.

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


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 import com.sun.enterprise.tools.common.dd.ejb.SunEjbJar;
35 import com.sun.enterprise.tools.common.dd.ejb.EnterpriseBeans;
36 import com.sun.enterprise.tools.common.dd.ejb.Ejb;
37 /** ejb [1,n]
38  * name [String]
39  *
40  * This is the name of the enterprise java bean.
41  * @author Irfan Ahmmed
42  */

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

49     public Result check(EjbDescriptor descriptor) {
50
51     Result result = getInitializedResult();
52     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
53
54         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
55         String JavaDoc ejbName = null;
56         
57         if(ejbJar!=null)
58         {
59             Ejb testCase = getEjb(descriptor.getName(),ejbJar);
60             ejbName = testCase.getEjbName();
61             if(ejbName.length()==0)
62             {
63                 result.failed(smh.getLocalString
64                      (getClass().getName() + ".failed",
65                       "failed [AS-EJB ejb] : ejb-name cannot not be empty. It should be a valid ejb-name as defined in ejb-jar.xml"));
66             }
67             else
68             {
69                 EjbDescriptor testDesc = descriptor.getEjbBundleDescriptor().getEjbByName(ejbName);
70                 if(testDesc!=null && testDesc.getName().equals(ejbName))
71                 {
72                     result.passed(smh.getLocalString(getClass().getName() + ".passed",
73                         "PASSED [AS-EJB ejb] : ejb-name is {0} and verified with ejb-jar.xml",
74                         new Object JavaDoc[] {ejbName}));
75                 }
76                 else
77                 {
78                     result.failed(smh.getLocalString(getClass().getName() + ".failed",
79                         "FAILED [AS-EJB ejb] : ejb-name {0} is not found in ejb-jar.xml. It should exist in ejb-jar.xml also.",
80                         new Object JavaDoc[] {ejbName}));
81                 }
82             }
83         }
84         else
85         {
86             result.addErrorDetails(smh.getLocalString
87                  (getClass().getName() + ".notRun",
88                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
89         }
90         return result;
91     }
92 }
93
94
Popular Tags