KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > interceptors > business > stateful > containermanaged > TestSFAccessInterceptor01


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

25 package org.objectweb.easybeans.tests.interceptors.business.stateful.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 org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessEJB;
31 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessEMFactory;
32 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessEntityManager;
33 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessJNDI;
34 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessResourceManager;
35 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessSessionContext;
36 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessUserTransaction;
37 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptoraccess.SFSBAccessInterceptorTest01;
38 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptoraccess.SFSBAccessSessionCtxInterceptor02;
39 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptoraccess.SFSBAccessUserTxInterceptor01;
40 import org.objectweb.easybeans.tests.common.exception.CustomException00;
41 import org.objectweb.easybeans.tests.interceptors.business.base.access.BaseAccessOperationsInterceptor00;
42 import org.testng.annotations.BeforeClass;
43 import org.testng.annotations.Test;
44
45 /**
46  * Verifies if interceptors in the bean class can access the perform the
47  * operations specified by the JSR-220.
48  * @reference JSR 220 - EJB 3.0 Core - 4.4.1
49  * @requirement Application Server must be running; the beans
50  * org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSB*AccessInterceptor*
51  * must be deployed.
52  * (Ant task: install.jar.tests.interceptor.business)
53  * @setup gets the reference of SLSBAccessInterceptorTest01,
54  * SLSBAccessTimerInterceptor01
55  * @author Eduardo Studzinski Estima de Castro
56  * @author Gisele Pinheiro Souza
57  */

58 public class TestSFAccessInterceptor01 extends BaseAccessOperationsInterceptor00 {
59
60     /**
61      * Gets bean instances used in the tests.
62      * @throws Exception if there is a problem with the bean initialization.
63      */

64     @BeforeClass
65     public void startUp() throws Exception JavaDoc {
66         ItfAccessJNDI bean00 = getBeanRemoteInstance(SFSBAccessInterceptorTest01.class, ItfAccessJNDI.class);
67         ItfAccessEJB bean01 = getBeanRemoteInstance(SFSBAccessInterceptorTest01.class, ItfAccessEJB.class);
68         ItfAccessResourceManager bean02 = getBeanRemoteInstance(SFSBAccessInterceptorTest01.class,
69                 ItfAccessResourceManager.class);
70         ItfAccessEntityManager bean03 = getBeanRemoteInstance(SFSBAccessInterceptorTest01.class,
71                 ItfAccessEntityManager.class);
72         ItfAccessEMFactory bean04 = getBeanRemoteInstance(SFSBAccessInterceptorTest01.class, ItfAccessEMFactory.class);
73         ItfAccessSessionContext bean05 = getBeanRemoteInstance(SFSBAccessInterceptorTest01.class,
74                 ItfAccessSessionContext.class);
75
76         ItfAccessSessionContext bean07 = getBeanRemoteInstance(SFSBAccessSessionCtxInterceptor02.class,
77                 ItfAccessSessionContext.class);
78         super.setBeans(bean00, bean01, bean02, bean03, bean04, bean05, null, bean07, null);
79     }
80
81     /**
82      * Verifies if the interceptor can access the "java:comp/env" via JNDI. This
83      * operation is allowed, so there isn't an expected
84      * exception.
85      * @input -
86      * @output no exceptions.
87      * @throws Exception if a problem occurs.
88      */

89     @Override JavaDoc
90     @Test(groups = {"java:comp/env access"})
91     public void testJNDI00() throws Exception JavaDoc {
92         super.testJNDI00();
93     }
94
95     /**
96      * Verifies if the interceptor can access an EJB. This
97      * operation is allowed, so there isn't an expected
98      * exception.
99      * @input -
100      * @output no exceptions.
101      * @throws Exception if a problem occurs.
102      */

103     @Override JavaDoc
104     @Test(groups = {"EJB access"})
105     public void testEJB00() throws Exception JavaDoc {
106         super.testEJB00();
107     }
108
109     /**
110      * Verifies if the interceptor can access the resource manager. This
111      * operation is allowed, so there isn't an expected
112      * exception.
113      * @input -
114      * @output no exceptions.
115      * @throws Exception if a problem occurs.
116      */

117     @Override JavaDoc
118     @Test(groups = {"Resource access"})
119     public void testResource00() throws Exception JavaDoc {
120         super.testResource00();
121     }
122
123     /**
124      * Verifies if the interceptor can access the entity manager. This
125      * operation is allowed, so there isn't an expected
126      * exception.
127      * @input -
128      * @output no exceptions.
129      * @throws Exception if a problem occurs.
130      */

131     @Override JavaDoc
132     @Test(groups = {"Entity Manager access"})
133     public void testEntityManager00() throws Exception JavaDoc {
134         super.testEntityManager00();
135     }
136
137     /**
138      * Verifies if the interceptor can access the entity factory. This
139      * operation is allowed, so there isn't an expected
140      * exception.
141      * @input -
142      * @output no exceptions.
143      * @throws Exception if a problem occurs.
144      */

145     @Override JavaDoc
146     @Test(groups = {"Entity Factory access"})
147     public void testEntityFactory00() throws Exception JavaDoc {
148         super.testEntityFactory00();
149     }
150
151     /**
152      * Verifies if the interceptor can access the session context. This
153      * operation is allowed, so there isn't an expected
154      * exception.
155      * @input -
156      * @output no exceptions.
157      * @throws Exception if a problem occurs.
158      */

159     @Override JavaDoc
160     @Test(groups = {"SessionContext access"})
161     public void testSessionContext00() throws Exception JavaDoc {
162         super.testSessionContext00();
163     }
164
165     /**
166      * Verifies if an interceptor can access the "getTimerService()" of a SessionContext instance.
167      * The specification defines that if a bean instance attempts to invoke a method and that access is not allowed, the container
168      * must throw an javax.ejb.EJBException with the java.lang.IllegalStateException as cause.
169      * @input -
170      * @output java.lang.IllegalStateException.
171      * @throws Exception if a problem occurs.
172      */

173     @Override JavaDoc
174     @Test(groups = {"SessionContext access"})
175     public void testSessionContext01() throws Exception JavaDoc {
176         try{
177         super.testSessionContext01();
178         }catch (Exception JavaDoc e){
179             checkCause(e, IllegalStateException JavaDoc.class);
180         }
181     }
182
183     /**
184      * Verifies if an interceptor can access the user transaction.
185      * The specification denies the use of this service, the reference must be null and
186      * an exception must be thrown.
187      * @input -
188      * @output CustomException00
189      * @throws Exception if a problem occurs.
190      */

191     @Override JavaDoc
192     @Test(groups = {"UserTransaction access"}, expectedExceptions = CustomException00.class)
193     @SuppressWarnings JavaDoc("unused")
194     public void testUserTransaction00() throws Exception JavaDoc {
195         ItfAccessUserTransaction bean = getBeanRemoteInstance(SFSBAccessUserTxInterceptor01.class,
196                 ItfAccessUserTransaction.class);
197         bean.accessUserTransaction(null);
198     }
199
200 }
201
Popular Tags