|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| package org.objectweb.easybeans.tests.interceptors.business.base; |
|
26 |
| |
|
27 |
| import static org.objectweb.easybeans.tests.common.asserts.Assert.assertEquals; |
|
28 |
| |
|
29 |
| import java.util.ArrayList; |
|
30 |
| import java.util.List; |
|
31 |
| |
|
32 |
| import org.objectweb.easybeans.tests.common.ejbs.base.ItfMethodInterceptor; |
|
33 |
| import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBMethodInterceptorTest; |
|
34 |
| import org.objectweb.easybeans.tests.common.interceptors.business.PackageInterceptor; |
|
35 |
| import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder01Interceptor; |
|
36 |
| import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder02Interceptor; |
|
37 |
| import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder03Interceptor; |
|
38 |
| import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder04Interceptor; |
|
39 |
| import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder05Interceptor; |
|
40 |
| import org.objectweb.easybeans.tests.common.interceptors.business.PrivateInterceptor; |
|
41 |
| import org.objectweb.easybeans.tests.common.interceptors.business.ProtectedInterceptor; |
|
42 |
| import org.testng.annotations.Test; |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| public class BaseMethodInterceptor { |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| private ItfMethodInterceptor<Integer> mtBean; |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
2
| @Test(groups = {"withoutInterceptor"})
|
|
63 |
| public void interceptorMethodTest00() { |
|
64 |
| |
|
65 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
66 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
67 |
| |
|
68 |
| |
|
69 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
70 |
| |
|
71 |
| |
|
72 |
2
| arResult = mtBean.withoutInterceptor(arResult);
|
|
73 |
| |
|
74 |
| |
|
75 |
2
| assertEquals(arExpected, arResult, "");
|
|
76 |
| } |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
2
| @Test(groups = {"withInterceptor"})
|
|
85 |
| public void interceptorMethodTest02() { |
|
86 |
| |
|
87 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
88 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
89 |
| |
|
90 |
| |
|
91 |
2
| arExpected.add(PrintOrder01Interceptor.ORDER);
|
|
92 |
| |
|
93 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
94 |
| |
|
95 |
| |
|
96 |
2
| arResult = mtBean.withOneMethodInterceptor(arResult);
|
|
97 |
| |
|
98 |
| |
|
99 |
2
| assertEquals(arExpected, arResult, "The interceptor is not running or it is running in the incorrect order.");
|
|
100 |
| } |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
2
| @Test(groups = {"withInterceptor"})
|
|
109 |
| public void interceptorMethodTest03() { |
|
110 |
| |
|
111 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
112 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
113 |
| |
|
114 |
| |
|
115 |
2
| arExpected.add(PrintOrder01Interceptor.ORDER);
|
|
116 |
| |
|
117 |
2
| arExpected.add(PrintOrder02Interceptor.ORDER);
|
|
118 |
| |
|
119 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
120 |
| |
|
121 |
| |
|
122 |
2
| arResult = mtBean.withTwoMethodInterceptors(arResult);
|
|
123 |
| |
|
124 |
| |
|
125 |
2
| assertEquals(arExpected, arResult, "The interceptors are not called in the correct order.");
|
|
126 |
| } |
|
127 |
| |
|
128 |
| |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
2
| @Test(groups = {"withInterceptor", "withInheritance"})
|
|
135 |
| public void interceptorMethodTest04() { |
|
136 |
| |
|
137 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
138 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
139 |
| |
|
140 |
| |
|
141 |
2
| arExpected.add(PrintOrder01Interceptor.ORDER);
|
|
142 |
| |
|
143 |
2
| arExpected.add(PrintOrder02Interceptor.ORDER);
|
|
144 |
| |
|
145 |
2
| arExpected.add(PrintOrder03Interceptor.ORDER);
|
|
146 |
| |
|
147 |
2
| arExpected.add(PrintOrder04Interceptor.ORDER);
|
|
148 |
| |
|
149 |
2
| arExpected.add(PrintOrder05Interceptor.ORDER);
|
|
150 |
| |
|
151 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
152 |
| |
|
153 |
| |
|
154 |
2
| arResult = mtBean.withFiveMethodInterceptors(arResult);
|
|
155 |
| |
|
156 |
| |
|
157 |
2
| assertEquals(arExpected, arResult, "The interceptors are not running in the correct order."
|
|
158 |
| + " Maybe there is a problem with the interceptors inheritance."); |
|
159 |
| } |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
| |
|
167 |
| |
|
168 |
2
| @Test(groups = {"withInterceptor", "withInheritance"})
|
|
169 |
| public void interceptorMethodTest05() { |
|
170 |
| |
|
171 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
172 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
173 |
| |
|
174 |
| |
|
175 |
2
| arExpected.add(PrintOrder05Interceptor.ORDER);
|
|
176 |
| |
|
177 |
2
| arExpected.add(PrintOrder04Interceptor.ORDER);
|
|
178 |
| |
|
179 |
2
| arExpected.add(PrintOrder03Interceptor.ORDER);
|
|
180 |
| |
|
181 |
2
| arExpected.add(PrintOrder02Interceptor.ORDER);
|
|
182 |
| |
|
183 |
2
| arExpected.add(PrintOrder01Interceptor.ORDER);
|
|
184 |
| |
|
185 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
186 |
| |
|
187 |
| |
|
188 |
2
| arResult = mtBean.withFiveMethodInterceptorsInverse(arResult);
|
|
189 |
| |
|
190 |
| |
|
191 |
2
| assertEquals(arExpected, arResult, "The interceptors are not running in the correct order."
|
|
192 |
| + " Maybe there is a problem with the interceptors inheritance."); |
|
193 |
| } |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
| |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
2
| @Test(groups = {"withInterceptor"})
|
|
203 |
| public void interceptorMethodTest06() { |
|
204 |
| |
|
205 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
206 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
207 |
| |
|
208 |
| |
|
209 |
2
| arExpected.add(PrivateInterceptor.ORDER);
|
|
210 |
| |
|
211 |
2
| arExpected.add(PrivateInterceptor.ORDER);
|
|
212 |
| |
|
213 |
2
| arExpected.add(PrivateInterceptor.ORDER);
|
|
214 |
| |
|
215 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
216 |
| |
|
217 |
| |
|
218 |
2
| arResult = mtBean.withPrivateInterceptors(arResult);
|
|
219 |
| |
|
220 |
| |
|
221 |
2
| assertEquals(arExpected, arResult, "The interceptors with private method are not running in the correct order.");
|
|
222 |
| } |
|
223 |
| |
|
224 |
| |
|
225 |
| |
|
226 |
| |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
| |
|
231 |
2
| @Test(groups = {"withInterceptor"})
|
|
232 |
| public void interceptorMethodTest07() { |
|
233 |
| |
|
234 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
235 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
236 |
| |
|
237 |
| |
|
238 |
2
| arExpected.add(ProtectedInterceptor.ORDER);
|
|
239 |
| |
|
240 |
2
| arExpected.add(ProtectedInterceptor.ORDER);
|
|
241 |
| |
|
242 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
243 |
| |
|
244 |
| |
|
245 |
2
| arResult = mtBean.withProtectedInterceptors(arResult);
|
|
246 |
| |
|
247 |
| |
|
248 |
2
| assertEquals(arExpected, arResult,
|
|
249 |
| "The interceptors with protected method are not running in the correct order."); |
|
250 |
| } |
|
251 |
| |
|
252 |
| |
|
253 |
| |
|
254 |
| |
|
255 |
| |
|
256 |
| |
|
257 |
| |
|
258 |
| |
|
259 |
| |
|
260 |
2
| @Test(groups = {"withInterceptor", "withInheritance"})
|
|
261 |
| public void interceptorMethodTest08() { |
|
262 |
| |
|
263 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
264 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
265 |
| |
|
266 |
| |
|
267 |
2
| arExpected.add(PrivateInterceptor.ORDER);
|
|
268 |
| |
|
269 |
2
| arExpected.add(ProtectedInterceptor.ORDER);
|
|
270 |
| |
|
271 |
2
| arExpected.add(PrintOrder01Interceptor.ORDER);
|
|
272 |
| |
|
273 |
2
| arExpected.add(PrivateInterceptor.ORDER);
|
|
274 |
| |
|
275 |
2
| arExpected.add(PrintOrder03Interceptor.ORDER);
|
|
276 |
| |
|
277 |
2
| arExpected.add(PrivateInterceptor.ORDER);
|
|
278 |
| |
|
279 |
2
| arExpected.add(ProtectedInterceptor.ORDER);
|
|
280 |
| |
|
281 |
2
| arExpected.add(ProtectedInterceptor.ORDER);
|
|
282 |
| |
|
283 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
284 |
| |
|
285 |
| |
|
286 |
2
| arResult = mtBean.withPrivateProtectedPublicInterceptors(arResult);
|
|
287 |
| |
|
288 |
| |
|
289 |
2
| assertEquals(arExpected, arResult, "The interceptors are not running in the correct order.");
|
|
290 |
| } |
|
291 |
| |
|
292 |
| |
|
293 |
| |
|
294 |
| |
|
295 |
| |
|
296 |
| |
|
297 |
| |
|
298 |
| |
|
299 |
2
| @Test(groups = {"withInterceptor", "withInheritance"})
|
|
300 |
| public void interceptorMethodTest09() { |
|
301 |
| |
|
302 |
2
| List<Integer> arResult = new ArrayList<Integer>();
|
|
303 |
2
| List<Integer> arExpected = new ArrayList<Integer>();
|
|
304 |
| |
|
305 |
| |
|
306 |
2
| arExpected.add(PackageInterceptor.ORDER);
|
|
307 |
| |
|
308 |
2
| arExpected.add(PackageInterceptor.ORDER);
|
|
309 |
| |
|
310 |
2
| arExpected.add(PackageInterceptor.ORDER);
|
|
311 |
| |
|
312 |
2
| arExpected.add(PackageInterceptor.ORDER);
|
|
313 |
| |
|
314 |
| |
|
315 |
2
| arExpected.add(SLSBMethodInterceptorTest.ORDER);
|
|
316 |
| |
|
317 |
| |
|
318 |
2
| arResult = mtBean.withPackageInterceptors(arResult);
|
|
319 |
| |
|
320 |
| |
|
321 |
2
| assertEquals(arExpected, arResult, "The interceptors are not running in the correct order.");
|
|
322 |
| } |
|
323 |
| |
|
324 |
| |
|
325 |
| |
|
326 |
| |
|
327 |
| |
|
328 |
18
| public void setBean(final ItfMethodInterceptor<Integer> bean){
|
|
329 |
18
| this.mtBean = bean;
|
|
330 |
| } |
|
331 |
| } |