001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TestInvocation00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.interceptors.invocationcontext;
025:
026: import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
027:
028: import org.ow2.easybeans.tests.common.ejbs.base.ItfOneMethod00;
029: import org.ow2.easybeans.tests.common.ejbs.base.invocationcontext.ItfInvocation00;
030: import org.ow2.easybeans.tests.common.ejbs.base.invocationcontext.ItfInvocationParameter01;
031: import org.ow2.easybeans.tests.common.ejbs.base.invocationcontext.ItfInvocationParameterTest;
032: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext00;
033: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext01;
034: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext02;
035: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationContext03;
036: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationParameter00;
037: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationParameter01;
038: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext.SLSBInvocationParameterTest;
039: import org.ow2.easybeans.tests.common.interceptors.invocationcontext.BeanDescriptor;
040: import org.ow2.easybeans.tests.common.interceptors.invocationcontext.ComplexObject00;
041: import org.testng.annotations.Test;
042:
043: /**
044: * Verifies if the invocation context is following the JSR 220 spec.
045: * @reference JSR 220 - EJB 3.0 Core - 12.5
046: * @requirement Application Server must be running; the bean
047: * org.ow2.easybeans.tests.common.ejbs.stateless.SLSB*Invocation*
048: * must be deployed.
049: * (Ant task: install.jar.tests.interceptor.invocationcontext)
050: * @setup gets the reference of SLSBInvocation*
051: * @author Eduardo Studzinski Estima de Castro
052: * @author Gisele Pinheiro Souza
053: */
054: public class TestInvocation00 {
055:
056: /**
057: * Constant value.
058: */
059: public static final int VALUE = 5000;
060:
061: /**
062: * Verifies if the InvocationContext in interceptor classes maintains the
063: * same bean reference.
064: * @input First parameter of the method must be a BeanDescriptor
065: * @output Comparation Result the BeanDescriptor created by the Client and
066: * the BeanDescriptor created into the Interceptor Method.
067: * @throws Exception if there is a problem with the test.
068: */
069: @Test(groups={"invocationContext"})
070: public void testInvocation00() throws Exception {
071: testInvocation(SLSBInvocationContext00.class);
072: }
073:
074: /**
075: * Verifies if the InvocationContext in interceptor method of a bean class
076: * maintains the same bean reference.
077: * @input First parameter of the method must be a BeanDescriptor
078: * @output Comparation Result the BeanDescriptor created by the Interceptor
079: * and the BeanDescriptor created into the bean method.
080: * @throws Exception if there is a problem with the test.
081: */
082: @Test(groups={"invocationContext"})
083: public void testInvocation01() throws Exception {
084: testInvocation(SLSBInvocationContext01.class);
085: }
086:
087: /**
088: * Verifies if the InvocationContext in interceptor method of a bean class
089: * maintains the same bean reference.
090: * @param beanClass bean class
091: * @throws Exception Exception if there is a problem with the test.
092: */
093: private void testInvocation(final Class beanClass) throws Exception {
094: ItfInvocation00 icBean = getBeanRemoteInstance(beanClass,
095: ItfInvocation00.class);
096: icBean.check();
097: }
098:
099: /**
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 {
109: ItfInvocationParameterTest bean = getBeanRemoteInstance(
110: SLSBInvocationParameterTest.class,
111: ItfInvocationParameterTest.class);
112: bean.testNull(SLSBInvocationParameter00.class);
113: }
114:
115: /**
116: * Verifies if the intercepted method parameters can be modified to a null
117: * reference. The interceptor method is on the bean class.
118: * @input First parameter of the method must be a ComplexObject00
119: * @output Comparation result between the objects passed as parameters and
120: * the objects returned by the method.
121: * @throws Exception if there is a problem with the test.
122: */
123: @Test(groups={"invocationContext","get/setParameters"})
124: public void testParameters01() throws Exception {
125: ItfInvocationParameterTest bean = getBeanRemoteInstance(
126: SLSBInvocationParameterTest.class,
127: ItfInvocationParameterTest.class);
128: bean.testNull(SLSBInvocationParameter01.class);
129: }
130:
131: /**
132: * Verifies if the intercepted method parameters can be returned WITHOUT
133: * modifications. The interceptor is a external class.
134: * @input First parameter of the method must be a ComplexObject00
135: * @output Comparation result between the objects passed as parameters and
136: * the objects returned by the method.
137: * @throws Exception if there is a problem with the test.
138: */
139: @Test(groups={"invocationContext","get/setParameters"})
140: public void testParameters02() throws Exception {
141: ItfInvocationParameterTest bean = getBeanRemoteInstance(
142: SLSBInvocationParameterTest.class,
143: ItfInvocationParameterTest.class);
144: bean.testWithoutModification(SLSBInvocationParameter00.class);
145: }
146:
147: /**
148: * Verifies if the intercepted method parameters can be returned WITHOUT
149: * modifications. The interceptor is a external class.
150: * @input First parameter of the method must be a ComplexObject00
151: * @output Comparation result between the objects passed as parameters and
152: * the objects returned by the method.
153: * @throws Exception if there is a problem with the test.
154: */
155: @Test(groups={"invocationContext","get/setParameters"})
156: public void testParameters03() throws Exception {
157: ItfInvocationParameterTest bean = getBeanRemoteInstance(
158: SLSBInvocationParameterTest.class,
159: ItfInvocationParameterTest.class);
160: bean.testWithoutModification(SLSBInvocationParameter01.class);
161: }
162:
163: /**
164: * Verifies if the intercepted method parameters can be returned WITH
165: * modifications. The interceptor is a external class.
166: * @input First parameter of the method must be a ComplexObject00
167: * @output Comparation result between the objects passed as parameters and
168: * the objects returned by the method.
169: * @throws Exception if there is a problem with the test.
170: */
171: @SuppressWarnings("boxing")
172: @Test(groups={"invocationContext","get/setParameters"})
173: public void testParameters04() throws Exception {
174: ItfInvocationParameterTest bean = getBeanRemoteInstance(
175: SLSBInvocationParameterTest.class,
176: ItfInvocationParameterTest.class);
177: bean.testWithModification(SLSBInvocationParameter00.class);
178: }
179:
180: /**
181: * Verifies if the intercepted method parameters can be returned WITH
182: * modifications. The interceptor is a external class.
183: * @input First parameter of the method must be a ComplexObject00
184: * @output Comparation result between the objects passed as parameters and
185: * the objects returned by the method.
186: * @throws Exception if there is a problem with the test.
187: */
188: @SuppressWarnings("boxing")
189: @Test(groups={"invocationContext","get/setParameters"})
190: public void testParameters05() throws Exception {
191: ItfInvocationParameterTest bean = getBeanRemoteInstance(
192: SLSBInvocationParameterTest.class,
193: ItfInvocationParameterTest.class);
194: bean.testWithModification(SLSBInvocationParameter01.class);
195: }
196:
197: /**
198: * Verifies if the context data is working following the specification.
199: * @throws Exception if there is a problem with the test.
200: */
201: @Test(groups={"invocationContext","getContextData"})
202: public void testContextData00() throws Exception {
203: ItfInvocationParameter01 icBean = getBeanRemoteInstance(
204: SLSBInvocationContext02.class,
205: ItfInvocationParameter01.class);
206: icBean.getObjects(null, null);
207: }
208:
209: /**
210: * Verifies if the context data is working following the specification.
211: * @throws Exception if there is a problem with the test.
212: */
213: @Test(groups={"invocationContext","getContextData"})
214: @SuppressWarnings("boxing")
215: public void testContextData01() throws Exception {
216: ItfInvocationParameter01 icBean = getBeanRemoteInstance(
217: SLSBInvocationContext02.class,
218: ItfInvocationParameter01.class);
219: icBean.getObjects(new ComplexObject00(), new BeanDescriptor());
220: }
221:
222: /**
223: * Verifies if the context data is working following the specification.
224: * @throws Exception if there is a problem with the test.
225: */
226: @Test(groups={"invocationContext","getContextData"})
227: @SuppressWarnings("boxing")
228: public void testContextData02() throws Exception {
229: ItfInvocationParameter01 icBean = getBeanRemoteInstance(
230: SLSBInvocationContext02.class,
231: ItfInvocationParameter01.class);
232: icBean.getObjects(new ComplexObject00(), new BeanDescriptor());
233: }
234:
235: /**
236: * Verifies if the proceed is returning null with a void interceptor method.
237: * @throws Exception if there is a problem with the test.
238: */
239: @Test(groups={"invocationContext","proceed"})
240: public void testProceed00() throws Exception {
241: ItfOneMethod00 icBean = getBeanRemoteInstance(
242: SLSBInvocationContext03.class, ItfOneMethod00.class);
243: icBean.doOne(null);
244: }
245: }
|