KickJava   Java API By Example, From Geeks To Geeks.

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


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.EjbDescriptor;
27 import com.sun.enterprise.deployment.EjbSessionDescriptor;
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  * Session Bean's Transaction demarcation test.
34  * If the enterprise bean is a Session Bean, the Bean provider must use
35  * the "transaction-type" element to declare whether the transaction
36  * demarcation is performed by the enterprise bean or the container.
37  */

38 public class TransactionType extends EjbTest implements EjbCheck {
39
40
41     /**
42      * Session Bean's Transaction demarcation test.
43      * If the enterprise bean is a Session Bean, the Bean provider must use
44      * the "transaction-type" element to declare whether the transaction
45      * demarcation is performed by the enterprise bean or the container.
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     if (descriptor instanceof EjbSessionDescriptor) {
57         String JavaDoc transactionType = descriptor.getTransactionType();
58         if (EjbSessionDescriptor.BEAN_TRANSACTION_TYPE.equals(transactionType) ||
59         EjbSessionDescriptor.CONTAINER_TRANSACTION_TYPE.equals(transactionType)) {
60         result.addGoodDetails(smh.getLocalString
61                       ("tests.componentNameConstructor",
62                        "For [ {0} ]",
63                        new Object JavaDoc[] {compName.toString()}));
64                         
65         result.passed(smh.getLocalString
66                   (getClass().getName() + ".passed",
67                    "[ {0} ] is valid transactionType.",
68                    new Object JavaDoc[] {transactionType}));
69         } else {
70         result.addErrorDetails(smh.getLocalString
71                        ("tests.componentNameConstructor",
72                     "For [ {0} ]",
73                     new Object JavaDoc[] {compName.toString()}));
74         result.failed(smh.getLocalString
75                   (getClass().getName() + ".failed",
76                    "Error: [ {0} ] is not valid transactionType within bean [ {1} ].",
77                    new Object JavaDoc[] {transactionType, descriptor.getName()}));
78         }
79         return result;
80     } else {
81         result.addNaDetails(smh.getLocalString
82                 ("tests.componentNameConstructor",
83                  "For [ {0} ]",
84                  new Object JavaDoc[] {compName.toString()}));
85         result.notApplicable(smh.getLocalString
86                  (getClass().getName() + ".notApplicable",
87                   "[ {0} ] expected {1} bean, but called with {2} bean.",
88                   new Object JavaDoc[] {getClass(),"Session","Entity"}));
89         return result;
90     }
91     }
92 }
93
Popular Tags