KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestExceptionHandleSupports.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.SFSBContainerTransacSupportsApp01;
32 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacSupportsApp02;
33 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionSupportsApp;
34 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionSupportsRollback;
35 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionSupportsRuntime;
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  * SFSBContainerTransactionSupportsApp,
48  * SFSBContainerTransacSupportsApp01,
49  * SFSBContainerTransacSupportsApp02
50  * SFSBContainerTransactionSupportsRollback and
51  * SFSBContainerTransactionSupportstRuntime 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 TestExceptionHandleSupports 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(SFSBContainerTransactionSupportsApp.class);
78     }
79
80     /**
81      * Creates a bean that throws always an application exception that extends
82      * RuntimeException and has the rollback element as false.
83      * @throws Exception if an error during the bean creation occurs.
84      */

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

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

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

114     @Override JavaDoc
115     public void createBeanRuntime() throws Exception JavaDoc {
116         super.createBeanRuntime(SFSBContainerTransactionSupportsRuntime.class);
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 false. So, the
137      * container must not rollback the transaction and must re-throw the
138      * exception.
139      * @input -
140      * @output the correct method execution.
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"})
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 not rollback the transaction and must throw the
153      * EJBException.
154      * @input -
155      * @output the correct method execution.
156      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
157      * @throws Exception if an error during the tests occurs.
158      */

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

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

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

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

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

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

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

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