KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime.resource;
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.tests.ejb.EjbCheck;
29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
30 import com.sun.enterprise.tools.verifier.Result;
31 import com.sun.enterprise.tools.verifier.Verifier;
32
33 /** ejb [0,n]
34  * resource-env-ref [0,n]
35  * resource-env-ref-name [String]
36  * jndi-name [String]
37  *
38  * The resource-env-ref holds all the runtime bindings for a resource
39  * environment reference
40  *
41  *
42  * @author Irfan Ahmed
43  */

44
45 public class ASEjbResEnvRef extends EjbTest implements EjbCheck
46  {
47     public Result result;
48     public ComponentNameConstructor compName;
49     public Result check(EjbDescriptor descriptor)
50     {
51         result = getInitializedResult();
52         compName = getVerifierContext().getComponentNameConstructor();
53         try {
54         int ejbResEnvReference = getCountNodeSet("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/resource-env-ref");
55         if (ejbResEnvReference>0)
56         {
57             for (int i=1;i<=ejbResEnvReference;i++)
58             {
59                 String JavaDoc refName = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/resource-env-ref["+i+"]/resource-env-ref-name");
60                 try
61                 {
62                     descriptor.getJmsDestinationReferenceByName(refName);
63                     result.passed(smh.getLocalString
64                             ("tests.componentNameConstructor",
65                                     "For [ {0} ]",
66                                     new Object JavaDoc[] {compName.toString()}));
67                     result.passed(smh.getLocalString(getClass().getName()+".passed",
68                             "PASSED [AS-EJB resource-env-ref] : res-env-ref-name {0} is verified with ejb-jar.xml",
69                             new Object JavaDoc[]{refName}));
70                 }catch(IllegalArgumentException JavaDoc iaex)
71                 {
72                     Verifier.debug(iaex);
73                     result.failed(smh.getLocalString
74                             ("tests.componentNameConstructor",
75                                     "For [ {0} ]",
76                                     new Object JavaDoc[] {compName.toString()}));
77                     result.failed(smh.getLocalString(getClass().getName()+".failed",
78                             "FAILED [AS-EJB resource-env-ref] : The res-env-ref-name {0} is not defined in ejb-jar.xml for this bean",
79                             new Object JavaDoc[]{refName}));
80                 }
81             }
82          }
83         else
84         {
85             addNaDetails(result, compName);
86             result.notApplicable(smh.getLocalString
87                     (getClass().getName() + ".notApplicable",
88                             " NOT-APPLICABLE: {0} Does not define any resource-env-ref Elements",
89                             new Object JavaDoc[] {descriptor.getName()}));
90         }
91         } catch(Exception JavaDoc ex){
92             result.addErrorDetails(smh.getLocalString
93                     ("tests.componentNameConstructor",
94                             "For [ {0} ]",
95                             new Object JavaDoc[] {compName.toString()}));
96             result.failed(smh.getLocalString(getClass().getName()+".notRun",
97                     "NOT RUN [AS-EJB] Could not create descriptor Object."));
98         }
99         return result;
100     }
101 }
102
Popular Tags