KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.logging.Level JavaDoc;
29
30 import com.sun.enterprise.deployment.*;
31 import com.sun.enterprise.tools.verifier.*;
32 import com.sun.enterprise.tools.verifier.tests.*;
33
34
35 /**
36  * The ejb-name element within the method element must be the name of one
37  * of the enterprise beans declared in the deployment descriptor.
38  */

39 public class EjbNameMethodElement extends EjbTest implements EjbCheck {
40
41
42     /**
43      * The ejb-name element within the method element must be the name of one
44      * of the enterprise beans declared in the deployment descriptor.
45      *
46      * @param descriptor the Enterprise Java Bean deployment descriptor
47      *
48      * @return <code>Result</code> the results for this assertion
49      */

50     public Result check(EjbDescriptor descriptor) {
51
52     Result result = getInitializedResult();
53     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
54
55     // get ejb's methods
56

57     // DOL doesn't save "ejb-name" element inside of method element
58
// so i can't seem to get at raw representation of XML data needed
59
// for this test,
60
// <ejb-name> within <method> element is the name of the ejb
61
// descriptor where you got the method descriptor from,
62
// so you can't trip negative assertion and test should always pass
63
// once plugged into new DOL, where access to raw XML is
64
// available, then this test can be properly modified,
65
// then i would use DOL similar to this:
66
//Set methods = descriptor.getMethodDescriptors();
67

68     //for (Iterator itr = methods.iterator(); itr.hasNext();) {
69

70     //MethodDescriptor methodDescriptor = (MethodDescriptor) itr.next();
71

72     boolean found = false;
73     for (Iterator itr2 =
74          descriptor.getEjbBundleDescriptor().getEjbs().iterator();
75          itr2.hasNext();) {
76         EjbDescriptor ejbDescriptor = (EjbDescriptor) itr2.next();
77         logger.log(Level.FINE, getClass().getName() + ".debug1",
78                 new Object JavaDoc[] {ejbDescriptor.getName()});
79         
80         // now iterate over all methods to ensure that ejb-name exist
81
//if (methodDescriptor.getName().equals(ejbDescriptor.getName())) {
82

83         // for now, do this test, which should always pass, since DOL lacks
84
// raw XML data representation
85
// <ejb-name> within <method> element is the name of the ejb
86
// descriptor where you got the method descriptor from
87
if (descriptor.getName().equals(ejbDescriptor.getName())) {
88         found = true;
89         if (result.getStatus() != Result.FAILED){
90             result.setStatus(Result.PASSED);
91             // for now, pass in details string via addGoodDetails
92
// until DOL raw data issue gets resolved
93
result.addGoodDetails(smh.getLocalString
94                       ("tests.componentNameConstructor",
95                        "For [ {0} ]",
96                        new Object JavaDoc[] {compName.toString()}));
97             result.addGoodDetails
98             (smh.getLocalString
99              (getClass().getName() + ".passed",
100               "[ {0} ] is valid and contained within jar.",
101               new Object JavaDoc[] {descriptor.getName()}));
102         }
103         }
104     }
105     if (!found) {
106         result.addErrorDetails(smh.getLocalString
107                    ("tests.componentNameConstructor",
108                     "For [ {0} ]",
109                     new Object JavaDoc[] {compName.toString()}));
110         result.addErrorDetails(smh.getLocalString
111             ("tests.componentNameConstructor",
112             "For [ {0} ]",
113             new Object JavaDoc[] {compName.toString()}));
114         result.failed
115         (smh.getLocalString
116          (getClass().getName() + ".failed",
117           "Error: [ {0} ] is not the name of one of the EJB's within jar.",
118           new Object JavaDoc[] {descriptor.getName()}));
119         //(methodDescriptor.getName() pending DOL update
120
}
121     //}
122
return result;
123
124     }
125
126 }
127
Popular Tags