KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > elements > EjbResAuthElement


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

23 package com.sun.enterprise.tools.verifier.tests.ejb.elements;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
27 import java.util.*;
28 import com.sun.enterprise.deployment.*;
29 import com.sun.enterprise.tools.verifier.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32 /**
33  * The resource-ref element res-auth subelement must be "Application" or
34  * "Container".
35  */

36 public class EjbResAuthElement extends EjbTest implements EjbCheck {
37
38
39
40     /**
41      * The resource-ref element res-auth subelement must be "Application" or
42      * "Container".
43      *
44      * @param descriptor the Enterprise Java Bean deployment descriptor
45      *
46      * @return <code>Result</code> the results for this assertion
47      */

48     public Result check(EjbDescriptor descriptor) {
49
50     Result result = getInitializedResult();
51     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52
53     boolean oneFailed = false;
54     if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
55         for (Iterator itr = descriptor.getResourceReferenceDescriptors().iterator(); itr.hasNext();) {
56         ResourceReferenceDescriptor nextResourceReference = (ResourceReferenceDescriptor) itr.next();
57         // The resource-ref element res-auth subelement must be "Application" or
58
// "Container".
59
if ((nextResourceReference.getAuthorization().equals(ResourceReferenceDescriptor.APPLICATION_AUTHORIZATION)) ||
60             (nextResourceReference.getAuthorization().equals(ResourceReferenceDescriptor.CONTAINER_AUTHORIZATION))) {
61             result.addGoodDetails(smh.getLocalString
62                       ("tests.componentNameConstructor",
63                        "For [ {0} ]",
64                        new Object JavaDoc[] {compName.toString()}));
65             result.addGoodDetails
66             (smh.getLocalString
67              (getClass().getName() + ".passed",
68               "Resource-ref element res-auth sub-element value [ {0} ] is valid within bean [ {1} ]",
69               new Object JavaDoc[] {nextResourceReference.getAuthorization(),descriptor.getName()}));
70         } else {
71             oneFailed = true;
72             result.addErrorDetails(smh.getLocalString
73                        ("tests.componentNameConstructor",
74                         "For [ {0} ]",
75                         new Object JavaDoc[] {compName.toString()}));
76             result.addErrorDetails
77             (smh.getLocalString
78              (getClass().getName() + ".failed",
79               "Error: Resource-ref element res-auth sub-element value [ {0} ] is not valid within bean [ {1} ]",
80               new Object JavaDoc[] {nextResourceReference.getAuthorization(),descriptor.getName()}));
81         }
82         }
83         if (!oneFailed){
84         result.setStatus(Result.PASSED);
85         } else {
86         result.setStatus(Result.FAILED);
87         }
88     } else {
89         result.addNaDetails(smh.getLocalString
90                 ("tests.componentNameConstructor",
91                  "For [ {0} ]",
92                  new Object JavaDoc[] {compName.toString()}));
93         result.notApplicable(smh.getLocalString
94                  (getClass().getName() + ".notApplicable",
95                   "There are no resource reference elements defined within this bean [ {0} ]",
96                   new Object JavaDoc[] {descriptor.getName()}));
97     }
98
99
100     return result;
101
102     }
103 }
104
Popular Tags