1 8 package test.mixindeployment; 9 10 import junit.framework.TestCase; 11 12 15 public class IntroductionDeploymentTest extends TestCase { 16 public IntroductionDeploymentTest(String s) { 17 super(s); 18 } 19 20 public void testPerInstanceMixin() { 21 TargetA a1 = new TargetA(); 22 TargetA a2 = new TargetA(); 23 TargetB b = new TargetB(); 24 Marker m1 = (Marker) a1; 25 Object o1 = m1.getTargetInstance(); 26 assertEquals(a1, ((Marker) a1).getTargetInstance()); 27 assertNotSame(((Marker) a1).getTargetInstance(), ((Marker) a2).getTargetInstance()); 28 assertEquals(((Marker) a1).getTargetClass(), ((Marker) a2).getTargetClass()); 29 assertEquals(b, ((Marker) b).getTargetInstance()); 30 assertEquals(b.getClass(), ((Marker) b).getTargetClass()); 31 } 32 33 public void testPerClassMixin() { 34 TargetC c1 = new TargetC(); 35 TargetC c2 = new TargetC(); 36 assertNull(((Marker) c1).getTargetInstance()); 37 assertEquals(((Marker) c1).getTargetClass(), ((Marker) c2).getTargetClass()); 38 } 39 40 public void testHashcodeMixin() { 41 TargetD d = new TargetD(); 42 d.doD(); 43 assertEquals(2, d.hashCode()); 44 } 45 46 public static void main(String [] args) { 47 junit.textui.TestRunner.run(suite()); 48 } 49 50 public static junit.framework.Test suite() { 51 return new junit.framework.TestSuite(IntroductionDeploymentTest.class); 52 } 53 54 public class TargetA { 55 } 56 57 public class TargetB { 58 } 59 60 public class TargetC { 61 } 62 63 public class TargetD { 64 public void doD() { 65 } 66 } 67 } | Popular Tags |