KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > session > TransactionTypeBeanManaged


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.session;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import com.sun.enterprise.deployment.*;
27 import com.sun.enterprise.tools.verifier.*;
28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31
32 /**
33  * Session Bean's bean-managed transaction demarcation test.
34  *
35  * The enterprise bean with bean-managed transaction demarcation must
36  * be a Session bean.
37  */

38 public class TransactionTypeBeanManaged extends EjbTest implements EjbCheck {
39
40
41     /**
42      * Session Bean's bean-managed transaction demarcation test.
43      *
44      * The enterprise bean with bean-managed transaction demarcation must
45      * be a Session bean.
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(EjbDescriptor descriptor) {
52
53     Result result = getInitializedResult();
54     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
55
56     String JavaDoc transactionType = descriptor.getTransactionType();
57     if (EjbSessionDescriptor.BEAN_TRANSACTION_TYPE.equals(transactionType)) {
58         if (descriptor instanceof EjbSessionDescriptor) {
59         result.addGoodDetails(smh.getLocalString
60                       ("tests.componentNameConstructor",
61                        "For [ {0} ]",
62                        new Object JavaDoc[] {compName.toString()}));
63         result.passed(smh.getLocalString
64                   (getClass().getName() + ".passed",
65                    "[ {0} ] is valid transactionType within Session bean [ {1} ]",
66                    new Object JavaDoc[] {transactionType, descriptor.getName()}));
67         } else if (descriptor instanceof EjbEntityDescriptor) {
68         result.addErrorDetails(smh.getLocalString
69                        ("tests.componentNameConstructor",
70                     "For [ {0} ]",
71                     new Object JavaDoc[] {compName.toString()}));
72         result.failed(smh.getLocalString
73                   (getClass().getName() + ".failedException",
74                    "Error: [ {0} ] is not valid transactionType within entity bean [ {1} ]",
75                    new Object JavaDoc[] {transactionType, descriptor.getName()}));
76         }
77         return result;
78     } else if (EjbSessionDescriptor.CONTAINER_TRANSACTION_TYPE.equals(transactionType)) {
79         result.addNaDetails(smh.getLocalString
80                 ("tests.componentNameConstructor",
81                  "For [ {0} ]",
82                  new Object JavaDoc[] {compName.toString()}));
83         result.notApplicable(smh.getLocalString
84                  (getClass().getName() + ".notApplicable",
85                   "Expected [ {0} ] transaction demarcation, but [ {1} ] bean has [ {2} ] transaction demarcation.",
86                   new Object JavaDoc[] {EjbSessionDescriptor.BEAN_TRANSACTION_TYPE,descriptor.getName(),EjbSessionDescriptor.CONTAINER_TRANSACTION_TYPE}));
87         return result;
88     } else {
89         result.addNaDetails(smh.getLocalString
90                 ("tests.componentNameConstructor",
91                  "For [ {0} ]",
92                  new Object JavaDoc[] {compName.toString()}));
93         result.notApplicable(smh.getLocalString
94                  (getClass().getName() + ".notApplicable",
95                   "Expected [ {0} ] transaction demarcation, but [ {1} ] bean has [ {2} ] transaction demarcation.",
96                   new Object JavaDoc[] {EjbSessionDescriptor.BEAN_TRANSACTION_TYPE,descriptor.getName(),transactionType}));
97         return result;
98     }
99     }
100 }
101
Popular Tags