KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > scopedextender > ScopedChildNoParentDelegationTester


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.aop.scopedextender;
23
24 /**
25  *
26  * @author <a HREF="kabir.khan@jboss.com">Kabir Khan</a>
27  * @version $Revision: 1.1 $
28  */

29 public class ScopedChildNoParentDelegationTester implements ScopedChildNoParentDelegationTesterMBean
30 {
31    public void testLoaders() throws Exception JavaDoc
32    {
33       System.out.println("=============== ScopedChildNoParentDelegationTester - LOADERS ================");
34       ClassLoader JavaDoc mine = this.getClass().getClassLoader();
35       ClassLoader JavaDoc a3 = Child_A3.class.getClassLoader();
36       ClassLoader JavaDoc base = Base_Base.class.getClassLoader();
37       
38       if (mine != a3)
39       {
40          throw new RuntimeException JavaDoc("ClassLoaders for me and Child_A3 should be the same. Mine=" + mine + "; Child_A3=" + a3);
41       }
42       
43       if (mine != base)
44       {
45          throw new RuntimeException JavaDoc("ClassLoaders for me and Base_Base should be the same. Mine=" + mine + "; Base_Base=" + base);
46       }
47    }
48    
49    public void testMethod() throws Exception JavaDoc
50    {
51       TestUtil testUtil = new TestUtil();
52       System.out.println("=============== ScopedChildNoParentDelegationTester - METHOD ================");
53       Child_A3 a3 = new Child_A3();
54       
55       clear();
56       a3.a3();
57       String JavaDoc m = "Child_A3.a3";
58       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"a3", "a2", "a1", "base"}, ChildAspect.invoked);
59       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a3", "a2", "a1", "base"}, BaseAspect.invoked);
60       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a3", "a2", "a1", "base"}, BaseParentAspect.invoked);
61       
62       clear();
63       a3.overridden();
64       m = "Child_A3.overridden";
65       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"overridden"}, ChildAspect.invoked);
66       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"overridden"}, BaseAspect.invoked);
67       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"overridden"}, BaseParentAspect.invoked);
68       
69       
70       Child_A2 a2 = new Child_A2();
71       
72       clear();
73       a2.a2();
74       m = "Child_A2.a2";
75       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"a2", "a1", "base"}, ChildAspect.invoked);
76       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a2", "a1", "base"}, BaseAspect.invoked);
77       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a2", "a1", "base"}, BaseParentAspect.invoked);
78       
79       clear();
80       a2.overridden();
81       m = "Child_A2.overridden";
82       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"overridden"}, ChildAspect.invoked);
83       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"overridden"}, BaseAspect.invoked);
84       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"overridden"}, BaseParentAspect.invoked);
85       
86       //Base_Base overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
87
Base_Base base = new Base_Base();
88       
89       clear();
90       base.base();
91       m = "Base_Base.base";
92       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
93       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
94       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
95       
96       clear();
97       base.overridden();
98       m = "Base_Base.overridden";
99       testUtil.compare(m, "BaseAspect", new String JavaDoc[] {"overridden"}, BaseAspect.invoked);
100       testUtil.compare(m, "ChildAspect", new String JavaDoc[] {}, ChildAspect.invoked);
101       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"overridden"}, BaseParentAspect.invoked);
102       
103     
104       //Base_A1 overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
105
Base_A1 a1 = new Base_A1();
106
107       clear();
108       a1.a1();
109       m = "Base_A1.a1";
110       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a1", "base"}, BaseAspect.invoked);
111       testUtil.compare(m, "ChildAspect", new String JavaDoc[] {}, ChildAspect.invoked);
112       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a1", "base"}, BaseParentAspect.invoked);
113       
114       clear();
115       a1.overridden();
116       m = "Base_A1.overridden";
117       testUtil.compare(m, "BaseAspect", new String JavaDoc[] {"overridden"}, BaseAspect.invoked);
118       testUtil.compare(m, "ChildAspect", new String JavaDoc[] {}, ChildAspect.invoked);
119       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"overridden"}, BaseParentAspect.invoked);
120       
121       Child_B1 b1 = new Child_B1();
122       
123       clear();
124       b1.b1();
125       m = "Child_B1.b1";
126       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b1", "base"}, ChildAspect.invoked);
127       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b1", "base"}, BaseAspect.invoked);
128       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b1", "base"}, BaseParentAspect.invoked);
129       
130       clear();
131       b1.overridden();
132       m = "Child_B1.overridden";
133       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"overridden"}, ChildAspect.invoked);
134       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"overridden"}, BaseAspect.invoked);
135       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"overridden"}, BaseParentAspect.invoked);
136       
137       Child_B2 b2 = new Child_B2();
138       
139       clear();
140       b2.b2();
141       m = "Child_B2.b2";
142       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b2", "b1", "base"}, ChildAspect.invoked);
143       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b2", "b1", "base"}, BaseAspect.invoked);
144       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b2", "b1", "base"}, BaseParentAspect.invoked);
145       
146       clear();
147       b2.overridden();
148       m = "Child_B2.overridden";
149       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"overridden"}, ChildAspect.invoked);
150       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"overridden"}, BaseAspect.invoked);
151       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"overridden"}, BaseParentAspect.invoked);
152       
153       Child_B3 b3 = new Child_B3();
154       
155       clear();
156       b3.b3();
157       m = "Child_B3.b3";
158       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b3", "b2", "b1", "base"}, ChildAspect.invoked);
159       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b3", "b2", "b1", "base"}, BaseAspect.invoked);
160       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b3", "b2", "b1", "base"}, BaseParentAspect.invoked);
161       
162       clear();
163       b3.overridden();
164       m = "Child_B3.overridden";
165       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"overridden"}, ChildAspect.invoked);
166       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"overridden"}, BaseAspect.invoked);
167       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"overridden"}, BaseParentAspect.invoked);
168
169       
170       BaseNotBaseWoven bnbw = new BaseNotBaseWoven();
171       clear();
172       m = "BaseNotBaseWoven.notWovenInBase";
173       bnbw.notWovenInBase();
174       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"notWovenInBase"}, ChildAspect.invoked);
175       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{}, BaseAspect.invoked);
176       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"notWovenInBase"}, BaseParentAspect.invoked);
177       
178       if (testUtil.getErrors() != null)
179       {
180          throw new RuntimeException JavaDoc(testUtil.getErrors());
181       }
182    }
183
184    public void testConstructor() throws Exception JavaDoc
185    {
186       TestUtil testUtil = new TestUtil();
187       System.out.println("=============== ScopedChildNoParentDelegationTester - CTOR ================");
188
189       clear();
190       Child_A3 a3 = new Child_A3();
191       testUtil.compare(a3.getClass().getName(), "ChildAspect", new String JavaDoc[]{a3.getClass().getName()}, ChildAspect.invoked);
192       testUtil.compare(a3.getClass().getName(), "BaseAspect", new String JavaDoc[]{a3.getClass().getName()}, BaseAspect.invoked);
193       testUtil.compare(a3.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{a3.getClass().getName()}, BaseParentAspect.invoked);
194       
195       clear();
196       Child_A2 a2 = new Child_A2();
197       testUtil.compare(a2.getClass().getName(), "ChildAspect", new String JavaDoc[]{a2.getClass().getName()}, ChildAspect.invoked);
198       testUtil.compare(a2.getClass().getName(), "BaseAspect", new String JavaDoc[]{a2.getClass().getName()}, BaseAspect.invoked);
199       testUtil.compare(a2.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{a2.getClass().getName()}, BaseParentAspect.invoked);
200       
201       //Base_Base overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
202
clear();
203       Base_Base base = new Base_Base();
204       testUtil.compare(base.getClass().getName(), "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
205       testUtil.compare(base.getClass().getName(), "BaseAspect", new String JavaDoc[]{base.getClass().getName()}, BaseAspect.invoked);
206       testUtil.compare(base.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{base.getClass().getName()}, BaseParentAspect.invoked);
207       
208     
209       //Base_A1 overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
210
clear();
211       Base_A1 a1 = new Base_A1();
212       testUtil.compare(a1.getClass().getName(), "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
213       testUtil.compare(a1.getClass().getName(), "BaseAspect", new String JavaDoc[]{a1.getClass().getName()}, BaseAspect.invoked);
214       testUtil.compare(a1.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{a1.getClass().getName()}, BaseParentAspect.invoked);
215       
216       clear();
217       Child_B1 b1 = new Child_B1();
218       testUtil.compare(b1.getClass().getName(), "ChildAspect", new String JavaDoc[]{b1.getClass().getName()}, ChildAspect.invoked);
219       testUtil.compare(b1.getClass().getName(), "BaseAspect", new String JavaDoc[]{b1.getClass().getName()}, BaseAspect.invoked);
220       testUtil.compare(b1.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{b1.getClass().getName()}, BaseParentAspect.invoked);
221       
222       clear();
223       Child_B2 b2 = new Child_B2();
224       testUtil.compare(b2.getClass().getName(), "ChildAspect", new String JavaDoc[]{b2.getClass().getName()}, ChildAspect.invoked);
225       testUtil.compare(b2.getClass().getName(), "BaseAspect", new String JavaDoc[]{b2.getClass().getName()}, BaseAspect.invoked);
226       testUtil.compare(b2.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{b2.getClass().getName()}, BaseParentAspect.invoked);
227       
228       clear();
229       Child_B3 b3 = new Child_B3();
230       testUtil.compare(b3.getClass().getName(), "ChildAspect", new String JavaDoc[]{b3.getClass().getName()}, ChildAspect.invoked);
231       testUtil.compare(b3.getClass().getName(), "BaseAspect", new String JavaDoc[]{b3.getClass().getName()}, BaseAspect.invoked);
232       testUtil.compare(b3.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{b3.getClass().getName()}, BaseParentAspect.invoked);
233       
234       clear();
235       BaseNotBaseWoven bnbw = new BaseNotBaseWoven();
236       testUtil.compare(bnbw.getClass().getName(), "ChildAspect", new String JavaDoc[]{bnbw.getClass().getName()}, ChildAspect.invoked);
237       testUtil.compare(bnbw.getClass().getName(), "BaseAspect", new String JavaDoc[]{}, BaseAspect.invoked);
238       testUtil.compare(bnbw.getClass().getName(), "BaseParentAspect", new String JavaDoc[]{bnbw.getClass().getName()}, BaseParentAspect.invoked);
239       
240       if (testUtil.getErrors() != null)
241       {
242          throw new RuntimeException JavaDoc(testUtil.getErrors());
243       }
244    }
245
246    public void testField() throws Exception JavaDoc
247    {
248       TestUtil testUtil = new TestUtil();
249       System.out.println("=============== ScopedChildNoParentDelegationTester - FIELD ================");
250       Child_A3 a3 = new Child_A3();
251       
252       clear();
253       a3.a3 = 10;
254       String JavaDoc m = "Child_A3.a3";
255       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"a3"}, ChildAspect.invoked);
256       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a3"}, BaseAspect.invoked);
257       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a3"}, BaseParentAspect.invoked);
258       
259       clear();
260       testUtil.compare(10, a3.a3);
261       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"a3"}, ChildAspect.invoked);
262       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a3"}, BaseAspect.invoked);
263       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a3"}, BaseParentAspect.invoked);
264       
265       clear();
266       a3.a2 = 10;
267       m = "Child_A3.a2";
268       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"a2"}, ChildAspect.invoked);
269       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a2"}, BaseAspect.invoked);
270       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a2"}, BaseParentAspect.invoked);
271       
272       clear();
273       testUtil.compare(10, a3.a2);
274       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"a2"}, ChildAspect.invoked);
275       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a2"}, BaseAspect.invoked);
276       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a2"}, BaseParentAspect.invoked);
277       
278       clear();
279       a3.a1 = 10;
280       m = "Child_A3.a1";
281       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
282       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a1"}, BaseAspect.invoked);
283       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a1"}, BaseParentAspect.invoked);
284       
285       clear();
286       testUtil.compare(10, a3.a1);
287       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
288       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a1"}, BaseAspect.invoked);
289       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a1"}, BaseParentAspect.invoked);
290       
291       clear();
292       a3.base = 10;
293       m = "Child_A3.base";
294       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
295       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
296       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
297       
298       clear();
299       testUtil.compare(10, a3.base);
300       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
301       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
302       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
303       
304       
305       //Base_A1 overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
306
Base_A1 a1 = new Base_A1();
307
308       clear();
309       a1.a1 = 10;
310       m = "Base_A1.a1";
311       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
312       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a1"}, BaseAspect.invoked);
313       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a1"}, BaseParentAspect.invoked);
314       
315       clear();
316       testUtil.compare(10, a1.a1);
317       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
318       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"a1"}, BaseAspect.invoked);
319       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"a1"}, BaseParentAspect.invoked);
320       
321       clear();
322       a1.base = 10;
323       m = "Base_A1.base";
324       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
325       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
326       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
327       
328       clear();
329       testUtil.compare(10, a1.base);
330       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
331       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
332       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
333
334       //Base_A1 overrides the version from parent/global ucl, so aspects deployed by us should apply to its methods
335
Base_Base base = new Base_Base();
336
337       clear();
338       base.base = 10;
339       m = "Base_Base.base";
340       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
341       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
342       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
343       
344       clear();
345       testUtil.compare(10, base.base);
346       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
347       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
348       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
349
350
351       Child_B3 b3 = new Child_B3();
352       
353       clear();
354       b3.b3 = 10;
355       m = "Child_B3.b3";
356       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b3"}, ChildAspect.invoked);
357       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b3"}, BaseAspect.invoked);
358       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b3"}, BaseParentAspect.invoked);
359       
360       clear();
361       testUtil.compare(10, b3.b3);
362       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b3"}, ChildAspect.invoked);
363       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b3"}, BaseAspect.invoked);
364       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b3"}, BaseParentAspect.invoked);
365       
366       clear();
367       b3.b2 = 10;
368       m = "Child_B3.b2";
369       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b2"}, ChildAspect.invoked);
370       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b2"}, BaseAspect.invoked);
371       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b2"}, BaseParentAspect.invoked);
372       
373       clear();
374       testUtil.compare(10, b3.b2);
375       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b2"}, ChildAspect.invoked);
376       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b2"}, BaseAspect.invoked);
377       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b2"}, BaseParentAspect.invoked);
378       
379       clear();
380       b3.b1 = 10;
381       m = "Child_B3.b1";
382       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b1"}, ChildAspect.invoked);
383       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b1"}, BaseAspect.invoked);
384       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b1"}, BaseParentAspect.invoked);
385       
386       clear();
387       testUtil.compare(10, b3.b1);
388       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"b1"}, ChildAspect.invoked);
389       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"b1"}, BaseAspect.invoked);
390       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"b1"}, BaseParentAspect.invoked);
391       
392       clear();
393       b3.base = 10;
394       m = "Child_B3.base";
395       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
396       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
397       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
398       
399       clear();
400       testUtil.compare(10, b3.base);
401       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{}, ChildAspect.invoked);
402       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"base"}, BaseAspect.invoked);
403       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"base"}, BaseParentAspect.invoked);
404
405       BaseNotBaseWoven bnbw = new BaseNotBaseWoven();
406       clear();
407       m = "BaseNotBaseWoven.field";
408       bnbw.field = 100;
409       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"field"}, ChildAspect.invoked);
410       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{}, BaseAspect.invoked);
411       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"field"}, BaseParentAspect.invoked);
412
413       clear();
414       testUtil.compare(100, bnbw.field);
415       testUtil.compare(m, "ChildAspect", new String JavaDoc[]{"field"}, ChildAspect.invoked);
416       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{}, BaseAspect.invoked);
417       testUtil.compare(m, "BaseParentAspect", new String JavaDoc[]{"field"}, BaseParentAspect.invoked);
418
419       if (testUtil.getErrors() != null)
420       {
421          throw new RuntimeException JavaDoc(testUtil.getErrors());
422       }
423    }
424
425    public void testOverriddenInterceptors() throws Exception JavaDoc
426    {
427       //This makes sure that we get the correct overridden aspect instances loaded
428
System.out.println("=============== ScopedChildNoParentDelegationTester - TEST OVERRIDDEN INTERCEPTORS ================");
429       TestUtil testUtil = new TestUtil();
430       
431       Base_Base base = new Base_Base();
432       
433       clear();
434       base.differentScopes();
435       String JavaDoc m = "differentScopes";
436       testUtil.compare(m, "BaseAspect", new String JavaDoc[]{"differentScopes"}, BaseAspect.invoked);
437       testUtil.invoked(BasePerClassInterceptor.class);
438       testUtil.invoked(BasePerInstanceInterceptor.class);
439       testUtil.invoked(BasePerJoinPointInterceptor.class);
440       testUtil.invoked(BasePerClassJoinPointInterceptor.class);
441       
442       if (testUtil.getErrors() != null)
443       {
444          throw new RuntimeException JavaDoc(testUtil.getErrors());
445       }
446    }
447
448    public String JavaDoc readName()
449    {
450       return "ScopedChildNoParentDelegationTester";
451    }
452
453    private void clear()
454    {
455       BaseAspect.invoked.clear();
456       ChildAspect.invoked.clear();
457       BaseParentAspect.invoked.clear();
458       BasePerClassInterceptor.invoked = false;
459       BasePerInstanceInterceptor.invoked = false;
460       BasePerJoinPointInterceptor.invoked = false;
461       BasePerClassJoinPointInterceptor.invoked = false;
462    }
463
464 }
465
Popular Tags