KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > entity > primarykeyclass > EjbPrimaryKeyClass


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.primarykeyclass;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import java.util.*;
27 import com.sun.enterprise.tools.verifier.tests.ejb.RmiIIOPUtils;
28 import com.sun.enterprise.deployment.EjbEntityDescriptor;
29 import com.sun.enterprise.deployment.EjbDescriptor;
30 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
31 import com.sun.enterprise.tools.verifier.*;
32 import java.lang.ClassLoader JavaDoc;
33 import com.sun.enterprise.tools.verifier.tests.*;
34
35 /**
36  * Define primary key class test.
37  *
38  * Enterprise Bean's primary key class
39  * The Bean provider must specify a primary key class in the deployment
40  * descriptor.
41  *
42  */

43 public class EjbPrimaryKeyClass extends EjbTest implements EjbCheck {
44
45
46     /**
47      * Define primary key class test.
48      *
49      * Enterprise Bean's primary key class
50      * The Bean provider must specify a primary key class in the deployment
51      * descriptor.
52      *
53      * @param descriptor the Enterprise Java Bean deployment descriptor
54      *
55      * @return <code>Result</code> the results for this assertion
56      */

57     public Result check(EjbDescriptor descriptor) {
58
59     Result result = getInitializedResult();
60     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
61
62     if (descriptor instanceof EjbEntityDescriptor) {
63         boolean oneFailed = false;
64   
65         // retrieve the EJB primary key class
66
String JavaDoc primaryKeyType = ((EjbEntityDescriptor)descriptor).getPrimaryKeyClassName();
67       
68         if (!primaryKeyType.equals("")) {
69         result.addGoodDetails(smh.getLocalString
70                           ("tests.componentNameConstructor",
71                            "For [ {0} ]",
72                            new Object JavaDoc[] {compName.toString()}));
73         result.addGoodDetails(smh.getLocalString
74                       (getClass().getName() + ".debug1",
75                        "For EJB primary key class [ {0} ]",
76                        new Object JavaDoc[] {primaryKeyType}));
77         result.addGoodDetails(smh.getLocalString
78                       (getClass().getName() + ".passed",
79                        "A primary key class was defined in the deployment descriptor."));
80         } else {
81         oneFailed = true;
82         result.addErrorDetails(smh.getLocalString
83                           ("tests.componentNameConstructor",
84                            "For [ {0} ]",
85                            new Object JavaDoc[] {compName.toString()}));
86         result.addErrorDetails(smh.getLocalString
87                        (getClass().getName() + ".debug1",
88                     "For EJB primary key class [ {0} ]",
89                     new Object JavaDoc[] {primaryKeyType}));
90         result.addErrorDetails(smh.getLocalString
91                        (getClass().getName() + ".failed",
92                     "Error: A primary key class was not defined in the deployment descriptor."));
93         }
94
95         if (oneFailed) {
96         result.setStatus(result.FAILED);
97         } else {
98         result.setStatus(result.PASSED);
99         }
100   
101         return result;
102
103     } else {
104         result.addNaDetails(smh.getLocalString
105                           ("tests.componentNameConstructor",
106                            "For [ {0} ]",
107                            new Object JavaDoc[] {compName.toString()}));
108         result.notApplicable(smh.getLocalString
109                  (getClass().getName() + ".notApplicable",
110                   "[ {0} ] expected {1} bean, but called with {2} bean.",
111                   new Object JavaDoc[] {getClass(),"Entity","Session"}));
112         return result;
113     }
114     }
115 }
116
Popular Tags