KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2;
25
26 import com.sun.enterprise.deployment.*;
27 import com.sun.enterprise.deployment.RelationRoleDescriptor;
28 import com.sun.enterprise.deployment.CMRFieldInfo;
29 import com.sun.enterprise.tools.verifier.Result;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32 /**
33  * Container-managed fields declaration test.
34  * CMR fields accessor methods names must the field name with the first
35  * letter uppercased and prefixed with get and set
36  *
37  * @author Jerome Dochez
38  * @author Sheetal Vartak
39  * @version
40  */

41 public class CmrFieldAccessor extends CmrFieldTest {
42
43     /**
44      * run an individual verifier test of a declated cmr field of the class
45      *
46      * @param entity the descriptor for the entity bean containing the cmp-field
47      * @param rrd the descriptor for the declared cmr field
48      * @param c the class owning the cmp field
49      * @param result the result object to use to put the test results in
50      *
51      * @return true if the test passed
52      */

53     protected boolean runIndividualCmrTest(Descriptor entity, RelationRoleDescriptor rrd, Class JavaDoc c, Result result) {
54     boolean oneFailed = false;
55     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
56         CMRFieldInfo info = rrd.getCMRFieldInfo();
57         if (info == null) {
58          addErrorDetails(result, compName);
59         result.addErrorDetails(smh.getLocalString
60                     ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CMPTest.isAccessorDeclared.failed1",
61                             "Error : no CMR Field declared ",
62                     new Object JavaDoc[] {}));
63         return false;
64         }
65         oneFailed = isAccessorDeclared(info.name, info.type, c, result);
66         if (oneFailed == false) {
67             // do nothing, appropriate message has been added in
68
// isAccessorDeclared().
69
}else {
70          result.addGoodDetails(smh.getLocalString
71                        ("tests.componentNameConstructor",
72                     "For [ {0} ]",
73                     new Object JavaDoc[] {compName.toString()}));
74         result.addGoodDetails(smh.getLocalString
75                     ("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CMPTest.isAccessorDeclared.passed",
76                             "CMR Field is properly declared ",
77                     new Object JavaDoc[] {}));
78         }
79         return oneFailed;
80     }
81 }
82
Popular Tags