1 22 package org.jboss.test.aop.introduction; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 27 import java.rmi.MarshalledObject ; 28 29 import org.jboss.test.aop.AOPTestWithSetup; 30 31 37 public class IntroductionTester extends AOPTestWithSetup 38 { 39 public static void main(String [] args) 40 { 41 junit.textui.TestRunner.run(IntroductionTester.class); 42 } 43 44 public static Test suite() 45 { 46 TestSuite suite = new TestSuite("IntroductionTester"); 47 suite.addTestSuite(IntroductionTester.class); 48 return suite; 49 } 50 53 55 public IntroductionTester(String name) 57 { 58 super(name); 59 } 60 61 public void testSerialization() throws Exception 62 { 63 SerializedPOJO pojo = new SerializedPOJO(); 64 ((NonSerializedIntroduction) pojo).setNonMessage("hello"); 65 ((SerializedIntroduction) pojo).setMessage("world"); 66 67 if (!((NonSerializedIntroduction) pojo).getNonMessage().equals("hello")) throw new Exception ("non serialized isn't set correctly"); 68 if (!((SerializedIntroduction) pojo).getMessage().equals("world")) throw new Exception ("serialized isn't set correctly"); 69 70 MarshalledObject mo = new MarshalledObject (pojo); 71 pojo = (SerializedPOJO) mo.get(); 72 73 if (!((NonSerializedIntroduction) pojo).getNonMessage().equals("original")) throw new Exception ("non serialized isn't set correctly" + ((NonSerializedIntroduction) pojo).getNonMessage().equals("original")); 74 if (!((SerializedIntroduction) pojo).getMessage().equals("world")) throw new Exception ("serialized isn't set correctly"); 75 76 assertTrue(((NonSerializedIntroduction) pojo)._testUnderscore()); 77 } 78 79 public void testHandledByInterceptor() throws Exception 80 { 81 POJO pojo = new POJO(); 82 int ret = ((InterceptorHandledIntroduction) pojo).handledByIntroduction(); 83 assertEquals(5, ret); 84 } 85 86 public void testOverrideBaseclassMethodsWithMixin() throws Exception 87 { 88 BaseClass base = new BaseClass(); 89 assertEquals("sumfink", base.getNonMessage()); 90 91 SubClass sub = new SubClass(); 92 NonSerializedIntroduction intro = (NonSerializedIntroduction)sub; 93 assertEquals("original", intro.getNonMessage()); 94 } 95 } 96 | Popular Tags |