1 /***************************************************************************************
2 * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
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 /***
18 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
19 * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
20 */
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 ;
30 }
31 }
32
33 public void testSerialVer() {
34
35 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
54 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
63 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 }