KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > introduction > IntroductionTester


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.aop.introduction;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import java.rmi.MarshalledObject JavaDoc;
28
29 import org.jboss.test.aop.AOPTestWithSetup;
30
31 /**
32  * Comment
33  *
34  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
35  * @version $Revision: 45977 $
36  */

37 public class IntroductionTester extends AOPTestWithSetup
38 {
39    public static void main(String JavaDoc[] 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    // Constants ----------------------------------------------------
51
// Attributes ---------------------------------------------------
52

53    // Static -------------------------------------------------------
54

55    // Constructors -------------------------------------------------
56
public IntroductionTester(String JavaDoc name)
57    {
58       super(name);
59    }
60
61    public void testSerialization() throws Exception JavaDoc
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 JavaDoc("non serialized isn't set correctly");
68       if (!((SerializedIntroduction) pojo).getMessage().equals("world")) throw new Exception JavaDoc("serialized isn't set correctly");
69
70       MarshalledObject JavaDoc mo = new MarshalledObject JavaDoc(pojo);
71       pojo = (SerializedPOJO) mo.get();
72
73       if (!((NonSerializedIntroduction) pojo).getNonMessage().equals("original")) throw new Exception JavaDoc("non serialized isn't set correctly" + ((NonSerializedIntroduction) pojo).getNonMessage().equals("original"));
74       if (!((SerializedIntroduction) pojo).getMessage().equals("world")) throw new Exception JavaDoc("serialized isn't set correctly");
75
76       assertTrue(((NonSerializedIntroduction) pojo)._testUnderscore());
77    }
78
79    public void testHandledByInterceptor() throws Exception JavaDoc
80    {
81       POJO pojo = new POJO();
82       int ret = ((InterceptorHandledIntroduction) pojo).handledByIntroduction();
83       assertEquals(5, ret);
84    }
85    
86    public void testOverrideBaseclassMethodsWithMixin() throws Exception JavaDoc
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