KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestNotSupportedException.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 * SFSBContainerTransactionNotSupportedApp,
42 * SFSBContainerTransactionNotSupportedRollback and
43 * SFSBContainerTransactionNotSupportedRuntime must be deployed for
44 * testing stateful session bean. And, the bean
45 * SLSBContainerTransactionNotSupportedApp,
46 * SLSBContainerTransactionNotSupportedRollback and
47 * SLSBContainerTransactionNotSupportedRuntime 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 TestNotSupportedException 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 REQUIRED. The attribute
60      * transaction NOT_SUPPORTED does not has a transaction context, so there is not
61      * transaction to be managed.The method throws a runtime exception.
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 testCallOtherBeanReq() throws Exception JavaDoc {
68           super.testCallOtherBeanReq();
69     }
70
71     /**
72      * Verifies if the container does not use the same transaction when the
73      * other bean has the transaction attribute NOT_SUPPORTED. The attribute
74      * transaction NOT_SUPPORTED does not has a transaction context, so there is not
75      * transaction to be managed.The method throws a runtime exception.
76      * @input -
77      * @output the method execution without error
78      * @throws Exception if an error during the tests occurs.
79      */

80     @Override JavaDoc
81     public void testCallOtherBeanNotSup() throws Exception JavaDoc {
82         super.testCallOtherBeanNotSup();
83         verifyCallOtherBean();
84     }
85
86     /**
87      * Verifies if the container made the rollback. The transaction attribute is
88      * not_supports, so there is not transaction context.
89      * @throws Exception if an error occurs.
90      */

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