KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tirsen > nanning > InheritanceTest


1 package com.tirsen.nanning;
2
3 import junit.framework.TestCase;
4
5 public class InheritanceTest extends TestCase {
6     public static interface InheritedIntf extends Intf {
7     }
8
9     public static class InheritedImpl extends IntfImpl implements InheritedIntf {
10     }
11
12     public static interface InheritedSideAspect extends Intf, TestMixin {
13     }
14
15     public static class InheritedSideAspectImpl extends TestMixinImpl implements InheritedSideAspect {
16         public void call() {
17         }
18     }
19
20     public void testInheritance() {
21         AspectInstance instance = new AspectInstance();
22         MixinInstance mixin = new MixinInstance(InheritedIntf.class, new InheritedImpl());
23         mixin.addInterceptor(new MockInterceptor());
24         instance.addMixin(mixin);
25
26         InheritedIntf proxy = (InheritedIntf) instance.getProxy();
27
28         MockInterceptor classInterceptor = (MockInterceptor) Aspects.getInterceptors(proxy).get(0);
29         classInterceptor.expectTarget(Aspects.getTarget(proxy, Intf.class));
30
31         proxy.call();
32     }
33 }
34
Popular Tags