KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > callAndExecution > CallExecutionTest


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.callAndExecution;
9
10 import junit.framework.TestCase;
11
12 /**
13  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
14  */

15 public class CallExecutionTest extends TestCase implements Intf {
16     private static String JavaDoc s_logString = "";
17
18     public CallExecutionTest() {
19     }
20
21     public CallExecutionTest(String JavaDoc name) {
22         super(name);
23     }
24
25     public void testPrivateMethod() {
26         s_logString = "";
27         privateMethod();
28         assertEquals("call1 execution1 invocation execution2 call2 ", s_logString);
29     }
30
31     public void testPublicMethod() {
32         s_logString = "";
33         publicMethod();
34         assertEquals("call1 execution1 invocation execution2 call2 ", s_logString);
35     }
36
37     public void testIntfMethod() {
38         //AW-253
39
s_logString = "";
40         Intf me = new CallExecutionTest();
41         me.called();
42         me.called(1);
43         assertEquals("call1 execution1 invocation execution2 call2 ", s_logString);
44
45         s_logString = "";
46         CallExecutionTest me2 = new CallExecutionTest();
47         me2.called();
48         me2.called(1);
49         assertEquals("call1 execution1 invocation execution2 call2 ", s_logString);
50     }
51
52     public void testAbstractMethod() {
53         //AW-253
54
s_logString = "";
55         Abstract me = new Abstract.AbstractImpl();
56         me.called();
57         assertEquals("call1 execution1 invocation execution2 call2 ", s_logString);
58
59         s_logString = "";
60         Abstract.AbstractImpl me2 = new Abstract.AbstractImpl();
61         me2.called();
62         assertEquals("call1 execution1 invocation execution2 call2 ", s_logString);
63     }
64
65     public static void main(String JavaDoc[] args) {
66         junit.textui.TestRunner.run(suite());
67     }
68
69     public static junit.framework.Test suite() {
70         return new junit.framework.TestSuite(CallExecutionTest.class);
71     }
72
73     // ==== methods to test ====
74
public static void log(final String JavaDoc wasHere) {
75         s_logString += wasHere;
76     }
77
78     private void privateMethod() {
79         log("invocation ");
80     }
81
82     public void publicMethod() {
83         log("invocation ");
84     }
85
86     public void called() {
87         //AW-253 interface declared method
88
log("invocation ");
89     }
90
91     public void called(int i) {
92         //AW-253 interface declared method
93
// not used, but force the compiler to do invokeinterface
94
}
95 }
Popular Tags