KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.ias.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 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 import com.sun.enterprise.tools.common.dd.ejb.SunEjbJar;
36 import com.sun.enterprise.tools.common.dd.ejb.Ejb;
37 import com.sun.enterprise.tools.common.dd.ResourceEnvRef;
38 import com.sun.enterprise.tools.common.dd.DefaultResourcePrincipal;
39 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor;
40
41 /** ejb [0,n]
42  * resource-env-ref [0,n]
43  * resource-env-ref-name [String]
44  * jndi-name [String]
45  *
46  * The resource-env-ref holds all the runtime bindings for a resource
47  * environment reference
48  *
49  *
50  * @author Irfan Ahmed
51  */

52 public class ASEjbResEnvRef extends EjbTest implements EjbCheck {
53
54     public Ejb testCase = null;
55     public ResourceEnvRef resRefs[];
56     public Result result;
57     public ComponentNameConstructor compName;
58     
59     public void getEjb(EjbDescriptor desc, SunEjbJar iasJar)
60     {
61         testCase = super.getEjb(desc.getName(),iasJar);
62         result = getInitializedResult();
63         compName = new ComponentNameConstructor(desc);
64         resRefs = testCase.getResourceEnvRef();
65     }
66     
67     public Result check(EjbDescriptor descriptor)
68     {
69         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
70         boolean oneFailed = false;
71         
72         if(ejbJar!=null)
73         {
74             getEjb(descriptor,ejbJar);
75             if(resRefs.length > 0)
76             {
77                 for(int j=0;j<resRefs.length;j++)
78                 {
79                     String JavaDoc refName = resRefs[j].getResourceEnvRefName();
80                     try
81                     {
82                         descriptor.getJmsDestinationReferenceByName(refName);
83                         result.passed(smh.getLocalString(getClass().getName()+".passed",
84                             "PASSED [AS-EJB resource-env-ref] : res-env-ref-name {0} is verified with ejb-jar.xml",
85                             new Object JavaDoc[]{refName}));
86                     }
87                     catch(IllegalArgumentException JavaDoc iaex)
88                     {
89                         Verifier.debug(iaex);
90                         result.failed(smh.getLocalString(getClass().getName()+".failed",
91                             "FAILED [AS-EJB resource-env-ref] : The res-env-ref-name {0} is not defined in ejb-jar.xml for this bean",
92                             new Object JavaDoc[]{refName}));
93                     }
94                 }
95             }
96             else
97             {
98                  result.notApplicable(smh.getLocalString
99                          (getClass().getName() + ".notApplicable",
100                           "{0} Does not define any resource-env-ref Elements",
101                           new Object JavaDoc[] {descriptor.getName()}));
102             }
103         }
104         else
105         {
106             result.addErrorDetails(smh.getLocalString
107                  (getClass().getName() + ".notRun",
108                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
109         }
110         return result;
111     }
112 }
113
Popular Tags