KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestExceptionHandleDefault.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.EJBTransactionRolledbackException JavaDoc;
30
31 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacDefaultApp01;
32 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacDefaultApp02;
33 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionDefaultApp;
34 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionDefaultRollback;
35 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionDefaultRuntime;
36 import org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase;
37 import org.testng.annotations.BeforeMethod;
38 import org.testng.annotations.Test;
39
40 /**
41  * Verifies if the container-managed transaction in the session bean is
42  * following the JSR 220. The container must handle the different types of
43  * exception in the transaction context. The items covered in this test are:
44  * 14.3.1
45  * @reference JSR 220-FINAL RELEASE
46  * @requirement Application Server must be running; the bean .
47  * SFSBContainerTransactionDefaultApp,
48  * SFSBContainerTransacDefaultApp01,
49  * SFSBContainerTransacDefaultApp02
50  * SFSBContainerTransactionDefaultRollback and
51  * SFSBContainerTransactionDefaultRuntime must be deployed .
52  * @setup gets the reference of the beans , cleans the database and close all
53  * transactions.
54  * @author Gisele Pinheiro Souza
55  * @author Eduardo Studzinski Estima de Castro
56  */

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

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

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

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

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

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

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

130     @Test(groups = {"application exception tests"})
131     @Override JavaDoc
132     public void testNotUsingClientTransWithAppException() throws Exception JavaDoc {
133         super.testNotUsingClientTransWithAppException();
134     }
135
136     /**
137      * Inserts a table in an database and after throws an application exception
138      * that extends Exception and has the rollback element as true. So, the
139      * container must rollback the transaction and must re-throw the exception.
140      * @input -
141      * @output the exception when the test makes a select in the database to
142      * find the table created.
143      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
144      * @throws Exception if an error during the tests occurs.
145      */

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

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

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

195     @Test(expectedExceptions = SQLException JavaDoc.class)
196     @Override JavaDoc
197     public void testNotUsingClientTransWithAppRuntimeRollbackException() throws Exception JavaDoc {
198         super.testNotUsingClientTransWithAppRuntimeRollbackException();
199     }
200
201     /**
202      * Inserts a table in an database and after throws an application exception
203      * that extends Exception and has the rollback element as false. The test
204      * uses the client transaction, so, the container must not mark the client
205      * transaction for rollback and must re-throw the exception.
206      * @input -
207      * @output the correct method execution.
208      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
209      * @throws Exception if an error during the tests occurs.
210      */

211     @Override JavaDoc
212     @Test(groups = {"application exception tests"})
213     public void testUsingClientTransWithAppException() throws Exception JavaDoc {
214         super.testUsingClientTransWithAppException();
215     }
216
217     /**
218      * Inserts a table in an database and after throws an application exception
219      * that extends Exception and has the rollback element as true. The test
220      * uses the client transaction, so, the container must mark the client
221      * transaction for rollback and must re-throw the exception.
222      * @input - *
223      * @output the exception when the test makes a select in the database to
224      * find the table created.
225      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
226      * @throws Exception if an error during the tests occurs.
227      */

228     @Test(groups = {"application rollback exception tests"}, expectedExceptions = SQLException JavaDoc.class)
229     public void tesUsingClientTransWithAppRollbackException() throws Exception JavaDoc {
230         super.testUsingClientTransWithAppRollbackException(false);
231     }
232
233     /**
234      * Inserts a table in an database and after throws an application exception
235      * that extends RuntimeException and has the rollback element as false. The
236      * test uses the client transaction, so, the container must not mark the
237      * client transaction for rollback and must re-throw the exception.
238      * @input -
239      * @output the correct method execution.
240      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
241      * @throws Exception if an error during the tests occurs.
242      */

243     @Test(groups = {"runtime exception tests"})
244     public void testUsingClientTransWithRuntimeException() throws Exception JavaDoc {
245         super.testUsingClientTransWithRuntimeException(EJBTransactionRolledbackException JavaDoc.class, false);
246     }
247
248     /**
249      * Inserts a table in an database and after throws an application exception
250      * that extends RuntimeException and has the rollback element as false. The
251      * test uses the client transaction, so, the container must not mark the
252      * client transaction for rollback and must re-throw the exception.
253      * @input -
254      * @output the correct method execution.
255      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
256      * @throws Exception if an error during the tests occurs.
257      */

258     @Override JavaDoc
259     @Test
260     public void testUsingClientTransWithAppRuntimeException() throws Exception JavaDoc {
261         super.testUsingClientTransWithAppRuntimeException();
262     }
263
264     /**
265      * Inserts a table in an database and after throws an application exception
266      * that extends RuntimeException and has the rollback element as false. The
267      * test uses the client transaction, so, the container must not mark the
268      * client transaction for rollback and must re-throw the exception.
269      * @input -
270      * @output the correct method execution.
271      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
272      * @throws Exception if an error during the tests occurs.
273      */

274     @Test(expectedExceptions = SQLException JavaDoc.class)
275     public void testUsingClientTransWithAppRuntimeRollbackException() throws Exception JavaDoc {
276         super.testUsingClientTransWithAppRuntimeRollbackException(false);
277     }
278
279 }
280
Popular Tags