KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > interceptors > business > stateless > containermanaged > TestSLExceptions00


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: TestSLExceptions00.java 978 2006-07-28 13:19:14Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.interceptors.business.stateless.containermanaged;
26
27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
28 import static org.objectweb.easybeans.tests.common.helper.ExceptionHelper.checkCause;
29
30 import javax.ejb.EJBException JavaDoc;
31
32 import org.objectweb.easybeans.tests.common.ejbs.base.ItfExceptions;
33 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptorexception.SLSBInterceptorExceptions00;
34 import org.objectweb.easybeans.tests.common.exception.CustomException00;
35 import org.objectweb.easybeans.tests.common.exception.CustomException01;
36 import org.objectweb.easybeans.tests.interceptors.business.base.exception.BaseExceptions00;
37 import org.testng.annotations.BeforeMethod;
38 import org.testng.annotations.Test;
39
40 /**
41  * Verifies if the interceptors and exceptions are working well.
42  * @reference JSR 220 - EJB 3.0 Core - Item: 12.3.2
43  * @requirement Application Server must be running; all test beans must be
44  * deployed.
45  * (Ant task: install.jar.tests.interceptor.business)
46  * @setup gets the reference of SLSBInterceptorExceptions00
47  * @author Eduardo Studzinski Estima de Castro
48  * @author Gisele Pinheiro Souza
49  */

50 public class TestSLExceptions00 extends BaseExceptions00{
51
52     /**
53      * Gets bean instance used in the tests.
54      * @throws Exception if there is a problem with the bean initialization.
55      */

56     @BeforeMethod
57     public void startUp() throws Exception JavaDoc {
58         ItfExceptions bean = getBeanRemoteInstance(SLSBInterceptorExceptions00.class, ItfExceptions.class);
59         super.setBean(bean);
60     }
61
62     /**
63      * Verifies if the interceptor can throw a customized exception.
64      * @throws Exception if there is an enhancer exception.
65      */

66     @Override JavaDoc
67     @Test(groups = {"Exceptions"}, expectedExceptions = CustomException00.class)
68     public void testException00() throws Exception JavaDoc {
69         super.testException00();
70     }
71
72     /**
73      * Verifies if the interceptor can throw a customized exception. The EJBException is expected and its cause must be a CustomException01.
74      * @throws Exception if there is an enhancer exception.
75      */

76     @Override JavaDoc
77     @Test(groups = {"Exceptions"})
78     public void testException01() throws Exception JavaDoc {
79         try{
80             super.testException01();
81         }catch(EJBException JavaDoc e){
82             checkCause(e, CustomException01.class);
83         }
84
85     }
86
87     /**
88      * Verifies if the interceptor can throw a customized exception. The EJBException is expected and its cause must be a CustomException01.
89      * @throws Exception if there is an enhancer exception.
90      */

91     @Override JavaDoc
92     @Test(groups = {"Exceptions"})
93     public void testException02() throws Exception JavaDoc {
94         try{
95             super.testException02();
96         }catch(EJBException JavaDoc e){
97             checkCause(e, CustomException01.class);
98         }
99     }
100
101     /**
102      * Verifies if the interceptor can throw a customized exception.
103      * @throws Exception if there is an enhancer exception.
104      */

105     @Override JavaDoc
106     @Test(groups = {"Exceptions"}, expectedExceptions = {CustomException00.class, CustomException01.class})
107     public void testException03() throws Exception JavaDoc {
108         super.testException03();
109     }
110 }
111
Popular Tags