01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package test.mixindeployment;
08:
09: import junit.framework.TestCase;
10:
11: /**
12: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
13: */
14: public class IntroductionDeploymentTest extends TestCase {
15: public IntroductionDeploymentTest(String s) {
16: super (s);
17: }
18:
19: public void testPerInstanceMixin() {
20: TargetA a1 = new TargetA();
21: TargetA a2 = new TargetA();
22: TargetB b = new TargetB();
23: Marker m1 = (Marker) a1;
24: Object o1 = m1.getTargetInstance();
25: assertEquals(a1, ((Marker) a1).getTargetInstance());
26: assertNotSame(((Marker) a1).getTargetInstance(), ((Marker) a2)
27: .getTargetInstance());
28: assertEquals(((Marker) a1).getTargetClass(), ((Marker) a2)
29: .getTargetClass());
30: assertEquals(b, ((Marker) b).getTargetInstance());
31: assertEquals(b.getClass(), ((Marker) b).getTargetClass());
32: }
33:
34: public void testPerClassMixin() {
35: TargetC c1 = new TargetC();
36: TargetC c2 = new TargetC();
37: assertNull(((Marker) c1).getTargetInstance());
38: assertEquals(((Marker) c1).getTargetClass(), ((Marker) c2)
39: .getTargetClass());
40: }
41:
42: public void testHashcodeMixin() {
43: TargetD d = new TargetD();
44: d.doD();
45: assertEquals(2, d.hashCode());
46: }
47:
48: public static void main(String[] args) {
49: junit.textui.TestRunner.run(suite());
50: }
51:
52: public static junit.framework.Test suite() {
53: return new junit.framework.TestSuite(
54: IntroductionDeploymentTest.class);
55: }
56:
57: public class TargetA {
58: }
59:
60: public class TargetB {
61: }
62:
63: public class TargetC {
64: }
65:
66: public class TargetD {
67: public void doD() {
68: }
69: }
70: }
|