KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.sun.enterprise.deployment.EjbDescriptor;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
32 /** ejb [1,n]
33  * name [String]
34  *
35  * This is the name of the enterprise java bean.
36  * @author
37  */

38 public class ASEjbName extends EjbTest implements EjbCheck {
39
40     /**
41      * @param descriptor the Enterprise Java Bean deployment descriptor
42      * @return <code>Result</code> the results for this assertion
43      */

44     public Result check(EjbDescriptor descriptor) {
45
46         boolean oneFailed = false;
47     Result result = getInitializedResult();
48     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
49         try{
50             String JavaDoc ejbName = descriptor.getName();
51             if(ejbName.length()==0){
52                 addErrorDetails(result, compName);
53                 result.failed(smh.getLocalString
54                     (getClass().getName() + ".failed",
55                     "failed [AS-EJB ejb] : ejb-name cannot not be empty. It should be a valid ejb-name as defined in ejb-jar.xml"));
56             } else {
57                 EjbDescriptor testDesc = descriptor.getEjbBundleDescriptor().getEjbByName(ejbName);
58                 if(testDesc!=null && testDesc.getName().equals(ejbName))
59                 {
60                     addGoodDetails(result, compName);
61                     result.passed(smh.getLocalString(getClass().getName() + ".passed",
62                         "PASSED [AS-EJB ejb] : ejb-name is {0} and verified with ejb-jar.xml",
63                         new Object JavaDoc[] {ejbName}));
64                 }
65                 else
66                 {
67                     addErrorDetails(result, compName);
68                     result.failed(smh.getLocalString(getClass().getName() + ".failed1",
69                         "FAILED [AS-EJB ejb] : ejb-name {0} is not found in ejb-jar.xml. It should exist in ejb-jar.xml also.",
70                         new Object JavaDoc[] {ejbName}));
71                 }
72             }
73         } catch(Exception JavaDoc ex){
74             oneFailed = true;
75             addErrorDetails(result, compName);
76             result.addErrorDetails(smh.getLocalString
77                  (getClass().getName() + ".notRun",
78                   "NOT RUN [AS-EJB] : Could not create descriptor object"));
79         }
80         return result;
81     }
82 }
83
Popular Tags