1 8 package test.mixin.perjvm; 9 10 import java.lang.reflect.Method ; 11 import java.lang.reflect.Field ; 12 import java.io.Serializable ; 13 14 import junit.framework.TestCase; 15 import test.SerialVerUidTest; 16 17 21 public class IntroductionTest extends TestCase { 22 23 public void testIntroducedComesFromInterfaces() { 24 Class klass = ToBeIntroduced.class.getClass(); 25 try { 26 Method m = klass.getDeclaredMethod("NOT_IN_MIXIN_INTF", new Class [0]); 27 fail("should not have introduced : " + m); 28 } catch (NoSuchMethodException e) { 29 ; } 31 } 32 33 public void testSerialVer() { 34 try { 36 Field f = ToBeIntroduced.class.getDeclaredField("serialVersionUID"); 37 } catch (Throwable t) { 38 fail(t.toString()); 39 } 40 } 41 42 public void testMixinInterface() { 43 ToBeIntroduced target = new ToBeIntroduced(); 44 assertTrue(target instanceof Introductions); 45 } 46 47 public void testSome() { 48 ToBeIntroduced target = new ToBeIntroduced(); 49 ((Introductions)target).noArgs(); 50 ToBeIntroduced target2 = new ToBeIntroduced(); 51 assertEquals(2, ((Introductions)target2).intArg(2)); 52 53 assertEquals(1, MyImpl.s_count); 55 } 56 57 public void testParams() { 58 assertEquals("v1", MyImpl.s_params.get("p1")); 59 assertEquals("v2", MyImpl.s_params.get("p2")); 60 } 61 62 public static void main(String [] args) { 64 junit.textui.TestRunner.run(suite()); 65 } 66 67 public static junit.framework.Test suite() { 68 return new junit.framework.TestSuite(IntroductionTest.class); 69 } 70 } | Popular Tags |