001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package test.callAndExecution;
008:
009: import junit.framework.TestCase;
010:
011: /**
012: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
013: */
014: public class CallExecutionTest extends TestCase implements Intf {
015: private static String s_logString = "";
016:
017: public CallExecutionTest() {
018: }
019:
020: public CallExecutionTest(String name) {
021: super (name);
022: }
023:
024: public void testPrivateMethod() {
025: s_logString = "";
026: privateMethod();
027: assertEquals("call1 execution1 invocation execution2 call2 ",
028: s_logString);
029: }
030:
031: public void testPublicMethod() {
032: s_logString = "";
033: publicMethod();
034: assertEquals("call1 execution1 invocation execution2 call2 ",
035: s_logString);
036: }
037:
038: public void testIntfMethod() {
039: //AW-253
040: s_logString = "";
041: Intf me = new CallExecutionTest();
042: me.called();
043: me.called(1);
044: assertEquals("call1 execution1 invocation execution2 call2 ",
045: s_logString);
046:
047: s_logString = "";
048: CallExecutionTest me2 = new CallExecutionTest();
049: me2.called();
050: me2.called(1);
051: assertEquals("call1 execution1 invocation execution2 call2 ",
052: s_logString);
053: }
054:
055: public void testAbstractMethod() {
056: //AW-253
057: s_logString = "";
058: Abstract me = new Abstract.AbstractImpl();
059: me.called();
060: assertEquals("call1 execution1 invocation execution2 call2 ",
061: s_logString);
062:
063: s_logString = "";
064: Abstract.AbstractImpl me2 = new Abstract.AbstractImpl();
065: me2.called();
066: assertEquals("call1 execution1 invocation execution2 call2 ",
067: s_logString);
068: }
069:
070: public static void main(String[] args) {
071: junit.textui.TestRunner.run(suite());
072: }
073:
074: public static junit.framework.Test suite() {
075: return new junit.framework.TestSuite(CallExecutionTest.class);
076: }
077:
078: // ==== methods to test ====
079: public static void log(final String wasHere) {
080: s_logString += wasHere;
081: }
082:
083: private void privateMethod() {
084: log("invocation ");
085: }
086:
087: public void publicMethod() {
088: log("invocation ");
089: }
090:
091: public void called() {
092: //AW-253 interface declared method
093: log("invocation ");
094: }
095:
096: public void called(int i) {
097: //AW-253 interface declared method
098: // not used, but force the compiler to do invokeinterface
099: }
100: }
|