KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > transaction > containermanaged > base > TestNeverException


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TestNeverException.java 980 2006-07-28 13:20:32Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.transaction.containermanaged.base;
26
27 import static org.testng.Assert.fail;
28
29 import java.sql.SQLException JavaDoc;
30
31 import org.objectweb.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction;
32 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.transaction.ItfTransactionMisc00;
33
34 /**
35 * Verifies if the container-managed transaction in the session bean is
36 * following the JSR 220. The container must handle the different types of
37 * exception in the transaction context. The items covered in this test are:
38 * 13.3
39 * @reference JSR 220-PROPOSED FINAL
40 * @requirement Application Server must be running; the bean .
41 * SFSBContainerTransactionNeverApp,
42 * SFSBContainerTransactionNeverRollback and
43 * SFSBContainerTransactionNeverRuntime must be deployed for
44 * testing stateful session bean. And, the bean
45 * SLSBContainerTransactionNeverApp,
46 * SLSBContainerTransactionNeverRollback and
47 * SLSBContainerTransactionNeverRuntime must be deployed for
48 * testing stateless session bean.
49 * @setup gets the reference of the bean and binds the databases specified in
50 * the EmbeddedTest.
51 * @author Gisele Pinheiro Souza
52 * @author Eduardo Studzinski Estima de Castro
53 */

54 public abstract class TestNeverException extends TestContainerTransactionException{
55
56
57     /**
58      * Verifies if the container does not use the same transaction when the
59      * other bean has the transaction attribute NOT_SUPPORTED. The attribute
60      * transaction NEVER does not has a transaction context, so there is not
61      * transaction to be managed.
62      * @input -
63      * @output the method execution without error
64      * @throws Exception if an error during the tests occurs.
65      */

66     @Override JavaDoc
67     public void testCallOtherBeanNotSup() throws Exception JavaDoc {
68         super.testCallOtherBeanNotSup();
69         verifyCallOtherBean();
70     }
71
72     /**
73      * Verifies if the container does not use the same transaction when the
74      * other bean has the transaction attribute REQUIRED. The attribute
75      * transaction NEVER does not has a transaction context, so there is not
76      * transaction to be managed.
77      * @input -
78      * @output the method execution without error
79      * @throws Exception if an error during the tests occurs.
80      */

81     @Override JavaDoc
82     public void testCallOtherBeanReq() throws Exception JavaDoc {
83         super.testCallOtherBeanReq();
84         verifyCallOtherBean();
85     }
86
87     /**
88      * Verifies if the container did not make a rollback. The transaction
89      * attribute never does not have a transaction context.
90      * @throws Exception if an error occurs.
91      */

92     private void verifyCallOtherBean() throws Exception JavaDoc{
93         // verifies if the transaction in the bean was rolled back.
94
try {
95             ExceptionHandleUtil.verifyTable(DATABASE_1, ItfContainerTransaction.TABLE);
96         } catch (SQLException JavaDoc e) {
97             fail("The container made a rollback in the transaction.");
98         }
99         // verifies if the table in the second bean was destroyed. This table
100
// must not to be destroyed because the two beans are not using the same
101
// transaction.
102
try {
103             ExceptionHandleUtil.verifyTable(DATABASE_2, ItfTransactionMisc00.TABLE);
104         } catch (SQLException JavaDoc e) {
105             fail("The container made a rollback in the transaction.");
106         }
107     }
108 }
109
Popular Tags