KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > entity > cmp2 > SelectMethodTest


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 /*
24  * SelectMethodTest.java
25  *
26  * Created on December 14, 2000, 4:36 PM
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2;
30
31 import java.lang.reflect.Method JavaDoc;
32 import com.sun.enterprise.deployment.*;
33 import com.sun.enterprise.tools.verifier.Result;
34 import com.sun.enterprise.tools.verifier.tests.*;
35
36 /**
37  *
38  * @author dochez
39  * @version
40  */

41 abstract public class SelectMethodTest extends CMPTest {
42
43     protected abstract boolean runIndividualSelectTest(Method JavaDoc m, EjbCMPEntityDescriptor descriptor, Result result);
44     
45     /**
46      *
47      * @param descriptor the Enterprise Java Bean deployment descriptor
48      *
49      * @return <code>Result</code> the results for this assertion
50      */

51     public Result check(EjbCMPEntityDescriptor descriptor) {
52         
53         boolean allIsWell = true;
54         Result result = getInitializedResult();
55     boolean found = false;
56     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
57
58         Class JavaDoc ejbClass = loadEjbClass(descriptor, result);
59         if (ejbClass!=null) {
60             Method JavaDoc[] methods = ejbClass.getDeclaredMethods();
61         if (methods != null) {
62         for (int i=0;i<methods.length;i++) {
63             String JavaDoc methodName = methods[i].getName();
64             if (methodName.startsWith("ejbSelect")) {
65             found = true;
66             if (!runIndividualSelectTest(methods[i], (EjbCMPEntityDescriptor) descriptor, result))
67                 allIsWell=false;
68             }
69         }
70         if (found == false) {
71             result.addNaDetails(smh.getLocalString
72                        ("tests.componentNameConstructor",
73                     "For [ {0} ]",
74                     new Object JavaDoc[] {compName.toString()}));
75             result.notApplicable(smh.getLocalString
76                       ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.SelectMethodTest.nptApplicable",
77                        "Not Applicable : No select methods found",
78                        new Object JavaDoc[] {}));
79         }
80         if (result.getStatus() != Result.NOT_APPLICABLE) {
81             if (allIsWell)
82                 result.setStatus(Result.PASSED);
83             else
84                 result.setStatus(Result.FAILED);
85             }
86         }
87     }
88     return result;
89     }
90 }
91
Popular Tags