KickJava   Java API By Example, From Geeks To Geeks.

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


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

24
25 import com.sun.enterprise.deployment.EjbDescriptor;
26 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
27 import com.sun.enterprise.tools.verifier.Result;
28
29 /** ejb [0,n]
30  * resource-env-ref [0,n]
31  * resource-env-ref-name [String]
32  * jndi-name [String]
33  *
34  * The jndi-name tag specifies the jndi name to which the resource environment reference
35  * name is binded.
36  *
37  * The value of this elemnet should not be null
38  *
39  * @author Irfan Ahmed
40  */

41
42 public class ASEjbREnvRefJndiName extends ASEjbResEnvRef {
43     public Result result;
44     public ComponentNameConstructor compName;
45
46     public Result check(EjbDescriptor descriptor)
47     {
48         result = getInitializedResult();
49         compName = getVerifierContext().getComponentNameConstructor();
50         try
51         {
52             int ejbResEnvReference = getCountNodeSet("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/resource-env-ref");
53             if (ejbResEnvReference>0)
54             {
55                 for (int i=1;i<=ejbResEnvReference;i++)
56                 {
57                     String JavaDoc refName = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/resource-env-ref["+i+"]/resource-env-ref-name");
58                     String JavaDoc refJndiName = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/resource-env-ref["+i+"]/jndi-name");
59                     /* Bug: 4954967. JNDI name does not have any restriction of starting with "jms/"
60                        only checking for null is sufficient for this test. */

61                     if(refJndiName == null || refJndiName.equals("")) {
62                         result.failed(smh.getLocalString
63                                 ("tests.componentNameConstructor",
64                                         "For [ {0} ]",
65                                         new Object JavaDoc[] {compName.toString()}));
66                         result.failed(smh.getLocalString(getClass().getName()+".failed",
67                             "FAILED [AS-EJB res-env-ref] : res-ref with res-ref-name {0} is not defined in the ejb-jar.xml",
68                             new Object JavaDoc[]{refName}));
69                     } else {
70                         result.passed(smh.getLocalString
71                                 ("tests.componentNameConstructor",
72                                         "For [ {0} ]",
73                                         new Object JavaDoc[] {compName.toString()}));
74                         result.passed(smh.getLocalString(getClass().getName()+".passed",
75                             "PASSED [AS-EJB res-env-ref] : jndi-name {0} is valid", new Object JavaDoc[]{refJndiName}));
76                     }
77                 }
78             }else
79             {
80                 addNaDetails(result, compName);
81                 result.notApplicable(smh.getLocalString
82                          (getClass().getName() + ".notApplicable",
83                                  "NOT-APPLICABLE: {0} Does not define any resource-env-ref Elements",
84                                  new Object JavaDoc[] {descriptor.getName()}));
85             }
86         }catch(Exception JavaDoc ex)
87         {
88             result.addErrorDetails(smh.getLocalString
89                     ("tests.componentNameConstructor",
90                             "For [ {0} ]",
91                             new Object JavaDoc[] {compName.toString()}));
92             result.failed(smh.getLocalString(getClass().getName()+".notRun",
93                     "NOT RUN [AS-EJB] Could not create descriptor Object."));
94
95         }
96         return result;
97     }
98 }
99
Popular Tags