KickJava   Java API By Example, From Geeks To Geeks.

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


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;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.deployment.EjbEntityDescriptor;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32
33 /**
34  * Entity Bean's Persistence management test.
35  * If the enterprise bean is a Entity Bean, the Bean provider must use
36  * the "persistence-type" element to declare whether the persistence
37  * management is performed by the enterprise bean or the container.
38  */

39 public class PersistenceType extends EjbTest implements EjbCheck {
40
41
42     /**
43      * Entity Bean's Persistence management test.
44      * If the enterprise bean is a Entity Bean, the Bean provider must use
45      * the "persistence-type" element to declare whether the persistence
46      * management is performed by the enterprise bean or the container.
47      *
48      * @param descriptor the Enterprise Java Bean deployment descriptor
49      *
50      * @return <code>Result</code> the results for this assertion
51      */

52     public Result check(EjbDescriptor descriptor) {
53
54     Result result = getInitializedResult();
55     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
56
57     if (descriptor instanceof EjbEntityDescriptor) {
58         String JavaDoc persistence =
59         ((EjbEntityDescriptor)descriptor).getPersistenceType();
60         if (EjbEntityDescriptor.BEAN_PERSISTENCE.equals(persistence) ||
61         EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistence)) {
62         result.addGoodDetails(smh.getLocalString
63                       ("tests.componentNameConstructor",
64                        "For [ {0} ]",
65                        new Object JavaDoc[] {compName.toString()}));
66         result.passed(smh.getLocalString
67                   (getClass().getName() + ".passed",
68                    "[ {0} ] is valid persistence type.",
69                    new Object JavaDoc[] {persistence}));
70         } else {
71         result.addErrorDetails(smh.getLocalString
72                        ("tests.componentNameConstructor",
73                     "For [ {0} ]",
74                     new Object JavaDoc[] {compName.toString()}));
75         result.failed(smh.getLocalString
76                   (getClass().getName() + ".failed",
77                    "Error: [ {0} ] is not valid persistence type within bean [ {1} ].",
78                    new Object JavaDoc[] {persistence, descriptor.getName()}));
79         }
80         return result;
81     } else {
82         result.addNaDetails(smh.getLocalString
83                 ("tests.componentNameConstructor",
84                  "For [ {0} ]",
85                  new Object JavaDoc[] {compName.toString()}));
86         result.notApplicable(smh.getLocalString
87                  (getClass().getName() + ".notApplicable",
88                   "[ {0} ] expected \n {1} bean, but called with {2} bean.",
89                   new Object JavaDoc[] {getClass(),"Entity","Session"}));
90         return result;
91     }
92     }
93 }
94
Popular Tags