KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestExceptionHandleRequired.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.SFSBContainerTransacRequiredApp01;
32 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacRequiredApp02;
33 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionRequiredApp;
34 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionRequiredRollback;
35 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionRequiredRuntime;
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  * SFSBContainerTransactionRequiredApp,
48  * SFSBContainerTransacRequiredApp01,
49  * SFSBContainerTransacRequiredApp02
50  * SFSBContainerTransactionRequiredRollback and
51  * SFSBContainerTransactionRequiredRuntime 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 TestExceptionHandleRequired 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      * Creates a bean that throws always an application exception that extends
71      * Exception and has the rollback element as false.
72      * @throws Exception if an error during the bean creation occurs.
73      */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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