KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > transaction > containermanaged > stateful > TestExceptionHandleRequiredNew


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: TestExceptionHandleRequiredNew.java 980 2006-07-28 13:20:32Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.transaction.containermanaged.stateful;
26
27 import java.sql.SQLException JavaDoc;
28
29 import javax.ejb.EJBException JavaDoc;
30
31 import org.objectweb.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction;
32 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacRequiredNewApp01;
33 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacRequiredNewApp02;
34 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacRequiredNewRollback;
35 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacRequiredNewRuntime;
36 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionRequiredNewApp;
37 import org.objectweb.easybeans.tests.transaction.containermanaged.base.ExceptionHandleUtil;
38 import org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase;
39 import org.testng.annotations.BeforeMethod;
40 import org.testng.annotations.Test;
41
42 /**
43  * Verifies if the container-managed transaction in the session bean is
44  * following the JSR 220. The container must handle the different types of
45  * exception in the transaction context. The items covered in this test are:
46  * 14.3.1
47  * @reference JSR 220-FINAL RELEASE
48  * @requirement Application Server must be running; the bean .
49  * SFSBContainerTransactionRequiresNewApp,
50  * SFSBContainerTransacRequiresNewApp01,
51  * SFSBContainerTransacRequiresNewApp02
52  * SFSBContainerTransactionRequiresNewRollback and
53  * SFSBContainerTransactionRequiresNewRuntime must be deployed .
54  * @setup gets the reference of the beans , cleans the database and close all
55  * transactions.
56  * @author Gisele Pinheiro Souza
57  * @author Eduardo Studzinski Estima de Castro
58  */

59 public class TestExceptionHandleRequiredNew extends TestExceptionHandleBase {
60
61     /**
62      * Creates the bean intances, closes the transactions and cleans the
63      * database.
64      * @throws Exception if an error during the bean creation occurs.
65      */

66     @BeforeMethod
67     @Override JavaDoc
68     public void setup() throws Exception JavaDoc {
69         super.setup();
70     }
71
72     /**
73      * Creates a bean that throws always an application exception that extends
74      * Exception and has the rollback element as false.
75      * @throws Exception if an error during the bean creation occurs.
76      */

77     @Override JavaDoc
78     public void createBeanApp() throws Exception JavaDoc {
79         super.createBeanApp(SFSBContainerTransactionRequiredNewApp.class);
80     }
81
82     /**
83      * Creates a bean that throws always an application exception that extends
84      * RuntimeException and has the rollback element as false.
85      * @throws Exception if an error during the bean creation occurs.
86      */

87     @Override JavaDoc
88     public void createBeanApp01() throws Exception JavaDoc {
89         super.createBeanApp01(SFSBContainerTransacRequiredNewApp01.class);
90     }
91
92     /**
93      * Creates a bean that throws always an application exception that extends
94      * RuntimeException and has the rollback element as true.
95      * @throws Exception if an error during the bean creation occurs.
96      */

97     @Override JavaDoc
98     public void createBeanApp02() throws Exception JavaDoc {
99         super.createBeanApp02(SFSBContainerTransacRequiredNewApp02.class);
100     }
101
102     /**
103      * Creates a bean that throws always an application exception that extends
104      * Exception and has the rollback element as true.
105      * @throws Exception if an error during the bean creation occurs.
106      */

107     @Override JavaDoc
108     public void createBeanRollback() throws Exception JavaDoc {
109         super.createBeanRollback(SFSBContainerTransacRequiredNewRollback.class);
110     }
111
112     /**
113      * Creates a bean that throws always aa runtime exception.
114      * @throws Exception if an error during the bean creation occurs.
115      */

116     @Override JavaDoc
117     public void createBeanRuntime() throws Exception JavaDoc {
118         super.createBeanRuntime(SFSBContainerTransacRequiredNewRuntime.class);
119     }
120
121     /**
122      * Inserts a table in an database and after throws an application exception
123      * that extends Exception and has the rollback element as true. So, the
124      * container must rollback the transaction and must re-throw the exception.
125      * @input -
126      * @output the exception when the test makes a select in the database to
127      * find the table created.
128      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
129      * @throws Exception if an error during the tests occurs.
130      */

131     @Test(groups = {"application rollback exception tests"}, expectedExceptions = SQLException JavaDoc.class)
132     @Override JavaDoc
133     public void testNotUsingClientTransWithAppRollbackException() throws Exception JavaDoc {
134         super.testNotUsingClientTransWithAppRollbackException();
135     }
136
137     /**
138      * Inserts a table in an database and after throws an application exception
139      * that extends Exception and has the rollback element as false. So, the
140      * container must not rollback the transaction and must re-throw the
141      * exception.
142      * @input -
143      * @output the correct method execution.
144      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
145      * @throws Exception if an error during the tests occurs.
146      */

147     @Test(groups = {"application exception tests"})
148     @Override JavaDoc
149     public void testNotUsingClientTransWithAppException() throws Exception JavaDoc {
150         super.testNotUsingClientTransWithAppException();
151     }
152
153     /**
154      * Inserts a table in an database and after throws a runtime exception. So,
155      * the container must rollback the transaction, discards the bean and throws
156      * an EJBException.
157      * @input -
158      * @output the exception when the test makes a select in the database to
159      * find the table created.
160      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
161      * @throws Exception if an error during the tests occurs.
162      */

163     @Test(groups = {"runtime exception tests"}, expectedExceptions = SQLException JavaDoc.class)
164     @Override JavaDoc
165     public void testNotUsingClientTransWithRuntimeException() throws Exception JavaDoc {
166         super.testNotUsingClientTransWithRuntimeException();
167     }
168
169     /**
170      * Inserts a table in an database and after throws an application exception
171      * that extends RuntimeException and has the rollback element as true. So,
172      * the container must rollback the transaction and must re-throw the
173      * exception.
174      * @input -
175      * @output the exception when the test makes a select in the database to
176      * find the table created.
177      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
178      * @throws Exception if an error during the tests occurs.
179      */

180     @Test(expectedExceptions = SQLException JavaDoc.class)
181     @Override JavaDoc
182     public void testNotUsingClientTransWithAppRuntimeRollbackException() throws Exception JavaDoc {
183         super.testNotUsingClientTransWithAppRuntimeRollbackException();
184     }
185
186     /**
187      * Inserts a table in an database and after throws an application exception
188      * that extends RuntimeException and has the rollback element as false. So,
189      * the container must not rollback the transaction and must re-throw the
190      * exception.
191      * @input -
192      * @output the exception when the test makes a select in the database to
193      * find the table created.
194      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
195      * @throws Exception if an error during the tests occurs.
196      */

197     @Test
198     @Override JavaDoc
199     public void testNotUsingClientTransWithAppRuntimeException() throws Exception JavaDoc {
200         super.testNotUsingClientTransWithAppRuntimeException();
201     }
202
203     /**
204      * Inserts a table in an database and after throws an application exception
205      * that extends Exception and has the rollback element as true. A client
206      * transaction is used, but the container must starts a new one.So, the
207      * container must rollback the transaction and must re-throw the exception.
208      * @input -
209      * @output the exception when the test makes a select in the database to
210      * find the table created.
211      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
212      * @throws Exception if an error during the tests occurs.
213      */

214     @Test(groups = {"application rollback exception tests"}, expectedExceptions = SQLException JavaDoc.class)
215     public void testUsingClientTransWithAppRollbackException() throws Exception JavaDoc {
216         super.testUsingClientTransWithAppRollbackException(true);
217     }
218
219     /**
220      * Inserts a table in an database and after throws an application exception
221      * that extends Exception and has the rollback element as false. A client
222      * transaction is used, but the container must starts a new one.So, the
223      * container must not rollback the transaction and must re-throw the
224      * exception.
225      * @input -
226      * @output the exception when the test makes a select in the database to
227      * find the table created.
228      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
229      * @throws Exception if an error during the tests occurs.
230      */

231     @Override JavaDoc
232     @Test(groups = {"application exception tests"})
233     public void testUsingClientTransWithAppException() throws Exception JavaDoc {
234         super.testUsingClientTransWithAppException();
235     }
236
237     /**
238      * Inserts a table in an database and after throws a runtime exception. So,
239      * the container must rollback the transaction, discards the bean and throws
240      * an EJBException. A client transaction is used, but the transaction must
241      * be resumed.
242      * @input -
243      * @output the exception when the test makes a select in the database to
244      * find the table created.
245      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
246      * @throws Exception if an error during the tests occurs.
247      */

248     @Test(groups = {"runtime exception tests"}, expectedExceptions = SQLException JavaDoc.class)
249     public void testUsingClientTransWithRuntimeException() throws Exception JavaDoc {
250         super.testUsingClientTransWithRuntimeException(EJBException JavaDoc.class, true);
251         // verifies if the table was created in the DATABASE_1
252
ExceptionHandleUtil.verifyTable(DATABASE_1, ItfContainerTransaction.TABLE);
253     }
254
255     /**
256      * Inserts a table in an database and after throws an application exception
257      * that extends RuntimeException and has the rollback element as true. A
258      * client transaction is used, but the container must starts a new one.So,
259      * the container must rollback the transaction and must re-throw the
260      * exception.
261      * @input -
262      * @output the exception when the test makes a select in the database to
263      * find the table created.
264      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
265      * @throws Exception if an error during the tests occurs.
266      */

267     @Test(expectedExceptions = SQLException JavaDoc.class)
268     public void testUsingClientTransWithAppRuntimeRollbackException() throws Exception JavaDoc {
269         super.testUsingClientTransWithAppRuntimeRollbackException(true);
270     }
271
272     /**
273      * Inserts a table in an database and after throws an application exception
274      * that extends RuntimeException and has the rollback element as false. A
275      * client transaction is used, but the container must starts a new one.So,
276      * the container must not rollback the transaction and must re-throw the
277      * exception.
278      * @input -
279      * @output the exception when the test makes a select in the database to
280      * find the table created.
281      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
282      * @throws Exception if an error during the tests occurs.
283      */

284     @Override JavaDoc
285     @Test
286     public void testUsingClientTransWithAppRuntimeException() throws Exception JavaDoc {
287         super.testUsingClientTransWithAppRuntimeException();
288
289     }
290
291 }
292
Popular Tags