KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > interceptors > invocationcontext > TestInvocation00


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

25 package org.objectweb.easybeans.tests.interceptors.invocationcontext;
26
27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
28
29 import org.objectweb.easybeans.tests.common.ejbs.base.ItfOneMethod00;
30 import org.objectweb.easybeans.tests.common.ejbs.base.invocationcontext.ItfInvocation00;
31 import org.objectweb.easybeans.tests.common.ejbs.base.invocationcontext.ItfInvocationParameter01;
32 import org.objectweb.easybeans.tests.common.ejbs.base.invocationcontext.ItfInvocationParameterTest;
33 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext00;
34 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext01;
35 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext02;
36 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext03;
37 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationParameter00;
38 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationParameter01;
39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationParameterTest;
40 import org.objectweb.easybeans.tests.common.interceptors.invocationcontext.BeanDescriptor;
41 import org.objectweb.easybeans.tests.common.interceptors.invocationcontext.ComplexObject00;
42 import org.testng.annotations.Test;
43
44 /**
45  * Verifies if the invocation context is following the JSR 220 spec.
46  * @reference JSR 220 - EJB 3.0 Core - 12.5
47  * @requirement Application Server must be running; the bean
48  * org.objectweb.easybeans.tests.common.ejbs.stateless.SLSB*Invocation*
49  * must be deployed.
50  * (Ant task: install.jar.tests.interceptor.invocationcontext)
51  * @setup gets the reference of SLSBInvocation*
52  * @author Eduardo Studzinski Estima de Castro
53  * @author Gisele Pinheiro Souza
54  */

55 public class TestInvocation00 {
56
57     /**
58      * Constant value.
59      */

60     public static final int VALUE = 5000;
61
62     /**
63      * Verifies if the InvocationContext in interceptor classes maintains the
64      * same bean reference.
65      * @input First parameter of the method must be a BeanDescriptor
66      * @output Comparation Result the BeanDescriptor created by the Client and
67      * the BeanDescriptor created into the Interceptor Method.
68      * @throws Exception if there is a problem with the test.
69      */

70     @Test(groups = {"invocationContext"})
71     public void testInvocation00() throws Exception JavaDoc {
72         testInvocation(SLSBInvocationContext00.class);
73     }
74
75     /**
76      * Verifies if the InvocationContext in interceptor method of a bean class
77      * maintains the same bean reference.
78      * @input First parameter of the method must be a BeanDescriptor
79      * @output Comparation Result the BeanDescriptor created by the Interceptor
80      * and the BeanDescriptor created into the bean method.
81      * @throws Exception if there is a problem with the test.
82      */

83     @Test(groups = {"invocationContext"})
84     public void testInvocation01() throws Exception JavaDoc {
85         testInvocation(SLSBInvocationContext01.class);
86     }
87
88     /**
89      * Verifies if the InvocationContext in interceptor method of a bean class
90      * maintains the same bean reference.
91      * @param beanClass bean class
92      * @throws Exception Exception if there is a problem with the test.
93      */

94     private void testInvocation(final Class JavaDoc beanClass) throws Exception JavaDoc {
95         ItfInvocation00 icBean = getBeanRemoteInstance(beanClass, ItfInvocation00.class);
96         icBean.check();
97     }
98
99     /**
100      * Verifies if the intercepted method parameters can be modified to a null
101      * reference. The interceptor method is on the bean class.
102      * @input First parameter of the method must be a ComplexObject00
103      * @output Comparation result between the objects passed as parameters and
104      * the objects returned by the method.
105      * @throws Exception if there is a problem with the test.
106      */

107     @Test(groups = {"invocationContext", "get/setParameters"})
108     public void testParameters00() throws Exception JavaDoc {
109         ItfInvocationParameterTest bean = getBeanRemoteInstance(SLSBInvocationParameterTest.class,
110                 ItfInvocationParameterTest.class);
111         bean.testNull(SLSBInvocationParameter00.class);
112     }
113
114     /**
115      * Verifies if the intercepted method parameters can be modified to a null
116      * reference. The interceptor method is on the bean class.
117      * @input First parameter of the method must be a ComplexObject00
118      * @output Comparation result between the objects passed as parameters and
119      * the objects returned by the method.
120      * @throws Exception if there is a problem with the test.
121      */

122     @Test(groups = {"invocationContext", "get/setParameters"})
123     public void testParameters01() throws Exception JavaDoc {
124         ItfInvocationParameterTest bean = getBeanRemoteInstance(SLSBInvocationParameterTest.class,
125                 ItfInvocationParameterTest.class);
126         bean.testNull(SLSBInvocationParameter01.class);
127     }
128
129     /**
130      * Verifies if the intercepted method parameters can be returned WITHOUT
131      * modifications. The interceptor is a external class.
132      * @input First parameter of the method must be a ComplexObject00
133      * @output Comparation result between the objects passed as parameters and
134      * the objects returned by the method.
135      * @throws Exception if there is a problem with the test.
136      */

137     @Test(groups = {"invocationContext", "get/setParameters"})
138     public void testParameters02() throws Exception JavaDoc {
139         ItfInvocationParameterTest bean = getBeanRemoteInstance(SLSBInvocationParameterTest.class,
140                 ItfInvocationParameterTest.class);
141         bean.testWithoutModification(SLSBInvocationParameter00.class);
142     }
143
144     /**
145      * Verifies if the intercepted method parameters can be returned WITHOUT
146      * modifications. The interceptor is a external class.
147      * @input First parameter of the method must be a ComplexObject00
148      * @output Comparation result between the objects passed as parameters and
149      * the objects returned by the method.
150      * @throws Exception if there is a problem with the test.
151      */

152     @Test(groups = {"invocationContext", "get/setParameters"})
153     public void testParameters03() throws Exception JavaDoc {
154         ItfInvocationParameterTest bean = getBeanRemoteInstance(SLSBInvocationParameterTest.class,
155                 ItfInvocationParameterTest.class);
156         bean.testWithoutModification(SLSBInvocationParameter01.class);
157     }
158
159     /**
160      * Verifies if the intercepted method parameters can be returned WITH
161      * modifications. The interceptor is a external class.
162      * @input First parameter of the method must be a ComplexObject00
163      * @output Comparation result between the objects passed as parameters and
164      * the objects returned by the method.
165      * @throws Exception if there is a problem with the test.
166      */

167     @SuppressWarnings JavaDoc("boxing")
168     @Test(groups = {"invocationContext", "get/setParameters"})
169     public void testParameters04() throws Exception JavaDoc {
170         ItfInvocationParameterTest bean = getBeanRemoteInstance(SLSBInvocationParameterTest.class,
171                 ItfInvocationParameterTest.class);
172         bean.testWithModification(SLSBInvocationParameter00.class);
173     }
174
175     /**
176      * Verifies if the intercepted method parameters can be returned WITH
177      * modifications. The interceptor is a external class.
178      * @input First parameter of the method must be a ComplexObject00
179      * @output Comparation result between the objects passed as parameters and
180      * the objects returned by the method.
181      * @throws Exception if there is a problem with the test.
182      */

183     @SuppressWarnings JavaDoc("boxing")
184     @Test(groups = {"invocationContext", "get/setParameters"})
185     public void testParameters05() throws Exception JavaDoc {
186         ItfInvocationParameterTest bean = getBeanRemoteInstance(SLSBInvocationParameterTest.class,
187                 ItfInvocationParameterTest.class);
188         bean.testWithModification(SLSBInvocationParameter01.class);
189     }
190
191     /**
192      * Verifies if the context data is working following the specification.
193      * @throws Exception if there is a problem with the test.
194      */

195     @Test(groups = {"invocationContext", "getContextData"})
196     public void testContextData00() throws Exception JavaDoc {
197         ItfInvocationParameter01 icBean = getBeanRemoteInstance(SLSBInvocationContext02.class,
198                 ItfInvocationParameter01.class);
199         icBean.getObjects(null, null);
200     }
201
202     /**
203      * Verifies if the context data is working following the specification.
204      * @throws Exception if there is a problem with the test.
205      */

206     @Test(groups = {"invocationContext", "getContextData"})
207     @SuppressWarnings JavaDoc("boxing")
208     public void testContextData01() throws Exception JavaDoc {
209         ItfInvocationParameter01 icBean = getBeanRemoteInstance(SLSBInvocationContext02.class,
210                 ItfInvocationParameter01.class);
211         icBean.getObjects(new ComplexObject00(), new BeanDescriptor());
212     }
213
214     /**
215      * Verifies if the context data is working following the specification.
216      * @throws Exception if there is a problem with the test.
217      */

218     @Test(groups = {"invocationContext", "getContextData"})
219     @SuppressWarnings JavaDoc("boxing")
220     public void testContextData02() throws Exception JavaDoc {
221         ItfInvocationParameter01 icBean = getBeanRemoteInstance(SLSBInvocationContext02.class,
222                 ItfInvocationParameter01.class);
223         icBean.getObjects(new ComplexObject00(), new BeanDescriptor());
224     }
225
226     /**
227      * Verifies if the proceed is returning null with a void interceptor method.
228      * @throws Exception if there is a problem with the test.
229      */

230     @Test(groups = {"invocationContext", "proceed"})
231     public void testProceed00() throws Exception JavaDoc {
232         ItfOneMethod00 icBean = getBeanRemoteInstance(SLSBInvocationContext03.class, ItfOneMethod00.class);
233         icBean.doOne(null);
234     }
235 }
236
Popular Tags