KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestExceptionHandleMandatory.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.SFSBContainerTransacMandatoryApp01;
32 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacMandatoryApp02;
33 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransacMandatoryRollback;
34 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionMandatoryApp;
35 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.transaction.SFSBContainerTransactionMandatoryRuntime;
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  * SFSBContainerTransactionMandatoryApp,
48  * SFSBContainerTransacMandatoryApp01,
49  * SFSBContainerTransacMandatoryApp02
50  * SFSBContainerTransactionMandatoryRollback and
51  * SFSBContainerTransactionMandatoryRuntime 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 TestExceptionHandleMandatory 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(SFSBContainerTransactionMandatoryApp.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(SFSBContainerTransacMandatoryApp01.class);
89
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(SFSBContainerTransacMandatoryApp02.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(SFSBContainerTransacMandatoryRollback.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(SFSBContainerTransactionMandatoryRuntime.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 false. The test
124      * uses the client transaction, so, the container must not mark the client
125      * transaction for rollback and must re-throw the exception.
126      * @input -
127      * @output the correct method execution.
128      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
129      * @throws Exception if an error during the tests occurs.
130      */

131     @Test
132     @Override JavaDoc
133     public void testUsingClientTransWithAppException() throws Exception JavaDoc{
134        super.testUsingClientTransWithAppException();
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 true. The test
140      * uses the client transaction, so, the container must mark the client
141      * transaction for rollback and must re-throw the exception.
142      * @input - *
143      * @output the exception when the test makes a select in the database to
144      * find the table created.
145      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
146      * @throws Exception if an error during the tests occurs.
147      */

148     @Test(expectedExceptions = SQLException JavaDoc.class)
149     public void testUsingClientTransWithAppRollbackException() throws Exception JavaDoc{
150         super.testUsingClientTransWithAppRollbackException(false);
151     }
152
153     /**
154      * Inserts a table in an database and after throws an application exception
155      * that extends RuntimeException and has the rollback element as false. The test
156      * uses the client transaction, so, the container must not mark the client
157      * transaction for rollback and must re-throw the exception.
158      * @input -
159      * @output the correct method execution.
160      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
161      * @throws Exception if an error during the tests occurs.
162      */

163     @Test(expectedExceptions = SQLException JavaDoc.class)
164     public void testUsingClientTransWithAppRuntimeRollbackException() throws Exception JavaDoc{
165         super.testUsingClientTransWithAppRuntimeRollbackException(false);
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. The test
171      * uses the client transaction, so, the container must not mark the client
172      * transaction for rollback and must re-throw the 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 testUsingClientTransWithAppRuntimeException() throws Exception JavaDoc{
181         super.testUsingClientTransWithAppRuntimeException();
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 false. The test
187      * uses the client transaction, so, the container must not mark the client
188      * transaction for rollback and must re-throw the exception.
189      * @input -
190      * @output the correct method execution.
191      * @see org.objectweb.easybeans.tests.transaction.containermanaged.base.TestExceptionHandleBase
192      * @throws Exception if an error during the tests occurs.
193      */

194     @Test(groups = {"runtime exception tests"})
195     public void testUsingClientTransWithRuntimeException() throws Exception JavaDoc {
196         super.testUsingClientTransWithRuntimeException(EJBTransactionRolledbackException JavaDoc.class, false);
197     }
198 }
199
Popular Tags