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.orthogonal;
9
10 import junit.framework.TestCase;
11 import test.Loggable;
12
13 /***
14 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
15 */
16 public class OrthogonalTest extends TestCase implements Loggable {
17 private String m_logString = "";
18
19 private int m_setFieldAroundAdviced = 0;
20
21 private int m_getFieldAroundAdviced = 0;
22
23 public OrthogonalTest() {
24 }
25
26 public OrthogonalTest(String name) {
27 super(name);
28 }
29
30 public void testMethodAdvice() {
31 m_logString = "";
32 methodAdvicedMethod();
33 assertEquals("before invocation after ", m_logString);
34 }
35
36 public void testSetField() {
37 m_logString = "";
38 setField();
39 assertEquals("before after ", m_logString);
40 }
41
42 public void testGetField() {
43 m_logString = "";
44 getField();
45 assertEquals("before after ", m_logString);
46 }
47
48
49
50 public static void main(String[] args) {
51 junit.textui.TestRunner.run(suite());
52 }
53
54 public static junit.framework.Test suite() {
55 return new junit.framework.TestSuite(OrthogonalTest.class);
56 }
57
58
59 public void log(final String wasHere) {
60 m_logString += wasHere;
61 }
62
63 public void methodAdvicedMethod() {
64 log("invocation ");
65 }
66
67 public void getField() {
68 int local = m_getFieldAroundAdviced;
69 }
70
71 public void setField() {
72 int local = 1;
73 m_setFieldAroundAdviced = 1;
74 }
75 }