KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestSFAccessInterceptor00.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.SFSBAccessInterceptorTest00;
38 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptoraccess.SFSBAccessSessionCtxInterceptor00;
39 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptoraccess.SFSBAccessSessionCtxInterceptor01;
40 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptoraccess.SFSBAccessUserTxInterceptor00;
41 import org.objectweb.easybeans.tests.common.exception.CustomException00;
42 import org.objectweb.easybeans.tests.interceptors.business.base.access.BaseAccessOperationsInterceptor00;
43 import org.testng.annotations.BeforeClass;
44 import org.testng.annotations.Test;
45
46 /**
47  * Verifies if interceptors in an external class can access the perform the
48  * operations specified by the JSR-220.
49  * @reference JSR 220 - EJB 3.0 Core - 4.4.1
50  * @requirement Application Server must be running; the beans
51  * org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SFSB*AccessInterceptor*
52  * must be deployed.
53  * (Ant task: install.jar.tests.interceptor.business)
54  * @setup gets the reference of SFSBAccessInterceptorTest00, SFSBAccessTimerInterceptor00
55  * @author Eduardo Studzinski Estima de Castro
56  * @author Gisele Pinheiro Souza
57  */

58 public class TestSFAccessInterceptor00 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(SFSBAccessInterceptorTest00.class, ItfAccessJNDI.class);
67         ItfAccessEJB bean01 = getBeanRemoteInstance(SFSBAccessInterceptorTest00.class, ItfAccessEJB.class);
68         ItfAccessResourceManager bean02 = getBeanRemoteInstance(SFSBAccessInterceptorTest00.class,
69                 ItfAccessResourceManager.class);
70         ItfAccessEntityManager bean03 = getBeanRemoteInstance(SFSBAccessInterceptorTest00.class,
71                 ItfAccessEntityManager.class);
72         ItfAccessEMFactory bean04 = getBeanRemoteInstance(SFSBAccessInterceptorTest00.class, ItfAccessEMFactory.class);
73         ItfAccessSessionContext bean05 = getBeanRemoteInstance(SFSBAccessInterceptorTest00.class,
74                 ItfAccessSessionContext.class);
75
76         ItfAccessSessionContext bean07 = getBeanRemoteInstance(SFSBAccessSessionCtxInterceptor00.class,
77                 ItfAccessSessionContext.class);
78         ItfAccessSessionContext bean08 = getBeanRemoteInstance(SFSBAccessSessionCtxInterceptor01.class,
79                 ItfAccessSessionContext.class);
80         super.setBeans(bean00, bean01, bean02, bean03, bean04, bean05, null, bean07, bean08);
81     }
82
83     /**
84      * Verifies if the interceptor can access the "java:comp/env" via JNDI. This
85      * operation is allowed, so there isn't an expected
86      * exception.
87      * @input -
88      * @output no exceptions.
89      * @throws Exception if a problem occurs.
90      */

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

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

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

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

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

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

174     @Override JavaDoc
175     @Test(groups = {"SessionContext access"})
176     public void testSessionContext01() {
177         try {
178             super.testSessionContext01();
179         } catch (Exception JavaDoc e) {
180             checkCause(e, IllegalStateException JavaDoc.class);
181         }
182     }
183
184     /**
185      * Verifies if an interceptor can access the "getUserTransaction()" of a SessionContext instance.
186      * The specification defines that if a bean instance attempts to invoke a method and that access is not allowed, the container
187      * must throw the java.lang.IllegalStateException.
188      * @input -
189      * @output javax.ejb.EJBException with a java.lang.IllegalStateException as cause.
190      */

191     @Override JavaDoc
192     @Test(groups = {"SessionContext access"})
193     public void testSessionContext02(){
194         try {
195             super.testSessionContext02();
196         } catch (Exception JavaDoc e) {
197             checkCause(e, IllegalStateException JavaDoc.class);
198         }
199     }
200
201     /**
202      * Verifies if an interceptor can access the user transaction.
203      * The specification denies the use of this service, the reference must be null and
204      * an exception must be thrown.
205      * @input -
206      * @output CustomException00
207      * @throws Exception if a problem occurs.
208      */

209     @Override JavaDoc
210     @Test(groups = {"UserTransaction access"}, expectedExceptions = CustomException00.class)
211     @SuppressWarnings JavaDoc("unused")
212     public void testUserTransaction00() throws Exception JavaDoc {
213         ItfAccessUserTransaction bean = getBeanRemoteInstance(SFSBAccessUserTxInterceptor00.class,
214                 ItfAccessUserTransaction.class);
215         bean.accessUserTransaction(null);
216     }
217
218 }
219
Popular Tags