KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestWrongSpecification.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.enhancer.ClassesEnhancer.EXT_CLASS;
28 import static org.objectweb.easybeans.tests.common.enhancer.ClassesEnhancer.enhanceNewClassLoader;
29
30 import java.io.File JavaDoc;
31 import java.util.ArrayList JavaDoc;
32 import java.util.List JavaDoc;
33
34 import org.objectweb.easybeans.deployment.annotations.exceptions.InterceptorsValidationException;
35 import org.objectweb.easybeans.tests.common.ejbs.base.ItfOneMethod00;
36 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.ItfWithInterceptor;
37 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBFinalExternalInterceptor;
38 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBFinalInternalInterceptor;
39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBItfWithInterceptor;
40 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBStaticExternalInterceptor;
41 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBStaticInternalInterceptor;
42 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBTwoArInvokeExternalInterceptor;
43 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBTwoAroundInvokeError;
44 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBVoidExternalInterceptor;
45 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.wrongspecification.SLSBWithArgsInterceptor;
46 import org.objectweb.easybeans.tests.common.enhancer.ClassesEnhancer.TYPE;
47 import org.objectweb.easybeans.tests.common.interceptors.business.wrongspecification.ArgsConstructorInterceptor;
48 import org.objectweb.easybeans.tests.common.interceptors.business.wrongspecification.FinalMethodInterceptor;
49 import org.objectweb.easybeans.tests.common.interceptors.business.wrongspecification.StaticMethodInterceptor;
50 import org.objectweb.easybeans.tests.common.interceptors.business.wrongspecification.TwoAroundInvokeInterceptor;
51 import org.objectweb.easybeans.tests.common.interceptors.business.wrongspecification.VoidInterceptor;
52 import org.testng.annotations.Test;
53
54
55 /**
56  * These tests verify business interceptors that were developed without
57  * following the JSR 220 spec.
58  * @reference JSR 220 - EJB 3.0 Core - 12
59  * @author Eduardo Studzinski Estima de Castro
60  * @author Gisele Pinheiro Souza
61  */

62 public class TestWrongSpecification {
63
64    /**
65      * This test should cause an enhancer exception. Verifies if an interceptor
66      * class with two @AroundInvoke doesn't compile.
67      * @input -
68      * @output -
69      * @throws Exception if there is an enhancer exception.
70      */

71     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
72     public void testWrongSpec00() throws Exception JavaDoc {
73         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
74
75         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
76         lstFiles.add(SLSBTwoArInvokeExternalInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
77         lstFiles.add(TwoAroundInvokeInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
78         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
79     }
80
81     /**
82      * Verifies if an interceptor class with args doesn't compile.
83      * @input -
84      * @output -
85      * @throws Exception if there is an enhancer exception.
86      */

87     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
88     public void testWrongSpec01() throws Exception JavaDoc {
89         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
90
91         lstFiles.add(SLSBWithArgsInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
92         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
93         lstFiles.add(ArgsConstructorInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
94         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
95     }
96
97     /**
98      * This test should cause an enhancer exception. Verifies if a bean class
99      * with two &#64;AroundInvoke doesn't compile.
100      * @input -
101      * @output -
102      * @throws Exception if there is an enhancer exception.
103      */

104     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
105     public void testWrongSpec02() throws Exception JavaDoc {
106         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
107
108         lstFiles.add(SLSBTwoAroundInvokeError.class.getName().replace(".", File.separator) + EXT_CLASS);
109         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
110         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
111     }
112
113     /**
114      * This test should cause an enhancer exception. Verifies if an interceptor
115      * that the return type is void doesn't compile.
116      * @input -
117      * @output -
118      * @throws Exception if there is an enhancer exception.
119      */

120     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
121     public void testWrongSpec03() throws Exception JavaDoc {
122         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
123
124         lstFiles.add(SLSBVoidExternalInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
125         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
126         lstFiles.add(VoidInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
127
128         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
129
130
131     }
132
133     /**
134      * Verifies if an interceptor class with a static method modifier compile.
135      * @input -
136      * @output -
137      * @throws Exception if there is an enhancer exception.
138      */

139     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
140       public void testWrongSpec04() throws Exception JavaDoc {
141         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
142
143         lstFiles.add(SLSBStaticExternalInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
144         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
145         lstFiles.add(StaticMethodInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
146         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
147     }
148
149     /**
150      * Verifies if an interceptor class with a final method modifier compile.
151      * @input -
152      * @output -
153      * @throws Exception if there is an enhancer exception.
154      */

155     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
156     public void testWrongSpec05() throws Exception JavaDoc {
157         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
158
159         lstFiles.add(SLSBFinalExternalInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
160         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
161         lstFiles.add(FinalMethodInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
162
163         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
164     }
165
166     /**
167      * This method should cause an exception. Verifies if an
168      * &#64;AroundInvoke declared into an interface compiles.
169      * @input -
170      * @output -
171      * @throws Exception if there is an enhancer exception.
172      */

173     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
174     public void testWrongSpec06() throws Exception JavaDoc {
175         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
176
177         lstFiles.add(ItfWithInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
178         lstFiles.add(SLSBItfWithInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
179         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
180     }
181
182     /**
183      * Verifies if a bean class with a static interceptor method compiles.
184      * @input -
185      * @output -
186      * @throws Exception if there is an enhancer exception.
187      */

188     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
189     public void testWrongSpec07() throws Exception JavaDoc {
190         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
191
192         lstFiles.add(SLSBStaticInternalInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
193         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
194         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
195     }
196
197     /**
198      * Verifies if a bean class with a final interceptor method compiles.
199      * @input -
200      * @output -
201      * @throws Exception if there is an enhancer exception.
202      */

203     @Test(groups = {"withWrongSpecification"}, expectedExceptions = InterceptorsValidationException.class)
204     public void testWrongSpec08() throws Exception JavaDoc {
205         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
206
207         lstFiles.add(SLSBFinalInternalInterceptor.class.getName().replace(".", File.separator) + EXT_CLASS);
208         lstFiles.add(ItfOneMethod00.class.getName().replace(".", File.separator) + EXT_CLASS);
209         enhanceNewClassLoader(lstFiles, TYPE.INTERCEPTOR);
210     }
211 }
212
Popular Tags