KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestSLAccessInterceptor00.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.ExceptionHelper.checkCause;
28 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
29
30 import javax.ejb.EJBException JavaDoc;
31
32 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessEJB;
33 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessEMFactory;
34 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessEntityManager;
35 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessJNDI;
36 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessResourceManager;
37 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessSessionContext;
38 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessUserTransaction;
39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptoraccess.SLSBAccessInterceptorTest00;
40 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptoraccess.SLSBAccessSessionCtxInterceptor00;
41 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptoraccess.SLSBAccessSessionCtxInterceptor01;
42 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptoraccess.SLSBAccessUserTxInterceptor00;
43 import org.objectweb.easybeans.tests.common.exception.CustomException00;
44 import org.objectweb.easybeans.tests.interceptors.business.base.access.BaseAccessOperationsInterceptor00;
45 import org.testng.annotations.BeforeClass;
46 import org.testng.annotations.Test;
47
48 /**
49  * Verifies if interceptors in an external class can perform the operations
50  * specified by the JSR-220.
51  * @reference JSR 220 - EJB 3.0 Core - 4.5.2 - Table 2
52  * @requirement (Ant task: install.jar.tests.interceptor.business)
53  * @setup gets the reference of SLSBAccessInterceptorTest00,
54  * SLSBAccessTimerInterceptor00
55  * (Ant task: install.jar.tests.interceptor.business)
56  * @author Eduardo Studzinski Estima de Castro
57  * @author Gisele Pinheiro Souza
58  */

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

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

104     @Override JavaDoc
105     @Test(groups = {"EJB access"})
106     public void testEJB00() throws Exception JavaDoc {
107         super.testEJB00();
108     }
109
110     /**
111      * Verifies if the interceptor can access the resource manager. This
112      * operation is allowed, so there isn't an expected 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 operation
125      * is allowed, so there isn't an expected exception.
126      * @input -
127      * @output no exceptions.
128      * @throws Exception if a problem occurs.
129      */

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

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

156     @Override JavaDoc
157     @Test(groups = {"SessionContext access"})
158     public void testSessionContext00() throws Exception JavaDoc {
159         super.testSessionContext00();
160     }
161
162     /**
163      * Verifies if an interceptor can access the "getTimerService()" of a
164      * SessionContext instance. This operation is allowed, so there isn't an
165      * expected exception.
166      * @input -
167      * @output No exceptions.
168      * @throws Exception if a problem occurs.
169      */

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

186     @Override JavaDoc
187     @Test(groups = {"SessionContext access"})
188     public void testSessionContext02() throws Exception JavaDoc {
189         try {
190             super.testSessionContext02();
191         } catch (EJBException JavaDoc e) {
192             checkCause(e, IllegalStateException JavaDoc.class);
193         }
194     }
195
196     /**
197      * Verifies if an interceptor can access the user transaction. The
198      * specification denies the use of this service, the container must throw
199      * the javax.naming.NameNotFoundException
200      * @input -
201      * @output javax.naming.NameNotFoundException
202      * @throws Exception if a problem occurs.
203      */

204     @Override JavaDoc
205     @Test(groups = {"UserTransaction access"}, expectedExceptions = CustomException00.class)
206     @SuppressWarnings JavaDoc("unused")
207     public void testUserTransaction00() throws Exception JavaDoc {
208         ItfAccessUserTransaction bean = getBeanRemoteInstance(SLSBAccessUserTxInterceptor00.class,
209                 ItfAccessUserTransaction.class);
210         bean.accessUserTransaction(null);
211     }
212
213 }
214
Popular Tags