KickJava   Java API By Example, From Geeks To Geeks.

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


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.entity.cmp2;
24
25 import java.lang.reflect.Method JavaDoc;
26 import com.sun.enterprise.deployment.*;
27 import com.sun.enterprise.tools.verifier.Result;
28 import com.sun.enterprise.tools.verifier.tests.*;
29
30
31 /**
32  * Finder method implementation test
33  * EJB 2.0 Spec 9.7.1 Entity bean class must not implement the ejbFind<METHOD>
34  *
35  * @author Jerome Dochez
36  * @version
37  */

38 public class FindMethodsAbstract extends QueryMethodTest {
39     
40     /**
41      * <p>
42      * Run an individual test against a finder method (single or multi)
43      * </p>
44      *
45      * @param method is the finder method reference
46      * @param descriptor is the entity bean descriptor
47      * @param targetClass is the class to apply to tests to
48      * @param result is where to place the result
49      *
50      * @return true if the test passes
51      */

52     protected boolean runIndividualQueryTest(Method JavaDoc method, EjbCMPEntityDescriptor descriptor, Class JavaDoc targetClass, Result result) {
53         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
54         // single or multi finder
55
String JavaDoc methodName = method.getName();
56         String JavaDoc ejbMethodName = "ejb" + Character.toUpperCase(methodName.charAt(0)) + methodName.substring(1);
57         Method JavaDoc ejbMethod = getMethod(targetClass, methodName, method.getParameterTypes());
58         if (ejbMethod != null) {
59         result.addErrorDetails(smh.getLocalString
60                        ("tests.componentNameConstructor",
61                     "For [ {0} ]",
62                     new Object JavaDoc[] {compName.toString()}));
63             result.addErrorDetails(smh.getLocalString
64         ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.FindMethodsAbstract.failed",
65                 "Error : [ {0} ] is defined in bean class [ {1} ]",
66         new Object JavaDoc[] {ejbMethodName , targetClass.getName()}));
67             return false;
68         } else {
69         result.addGoodDetails(smh.getLocalString
70                        ("tests.componentNameConstructor",
71                     "For [ {0} ]",
72                     new Object JavaDoc[] {compName.toString()}));
73             result.addGoodDetails(smh.getLocalString
74         ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.FindMethodsAbstract.passed",
75                 "[ {0} ] is not defined in bean class [ {1} ]",
76         new Object JavaDoc[] {ejbMethodName , targetClass.getName()}));
77             return true;
78         }
79     }
80 }
81
Popular Tags