KickJava   Java API By Example, From Geeks To Geeks.

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


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.ResourceRef;
38 import com.sun.enterprise.tools.common.dd.DefaultResourcePrincipal;
39 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
40
41 /** ejb [0,n]
42  * resource-ref [0,n]
43  * res-ref-name [String]
44  * jndi-name [String]
45  * default-resource-principal ?
46  * name [String]
47  * password [String]
48  *
49  * The resource-ref element holds the runtime bindings for a resource
50  * reference declared in the ejb-jar.xml
51  * @author Irfan Ahmed
52  */

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