001: //$Id$
002: //=====================================================================
003: //
004: //(history at end)
005: //
006:
007: package ch.ethz.prose.crosscut;
008:
009: import junit.framework.TestCase;
010: import ch.ethz.prose.*;
011: import ch.ethz.prose.filter.*;
012:
013: /**
014: * Cross-cut methods with different arguments.
015: *
016: * @version $Revision$
017: * @author Johann Gyger
018: */
019: public class MethodArgumentsTest extends TestCase {
020:
021: protected static boolean crosscutted;
022:
023: public MethodArgumentsTest(String name) {
024: super (name);
025: }
026:
027: protected void setUp() throws SystemStartupException {
028: ProseSystem.startup();
029: }
030:
031: protected void tearDown() throws SystemTeardownException {
032: ProseSystem.teardown();
033: }
034:
035: public void myMethod() {
036: }
037:
038: public void myMethodByte(byte arg1, byte arg2) {
039: }
040:
041: public void myMethodShort(short arg1, short arg2) {
042: }
043:
044: public void myMethodInt(int arg1, int arg2) {
045: }
046:
047: public void myMethodLong(long arg1, long arg2) {
048: }
049:
050: public void myMethodFloat(float arg1, float arg2) {
051: }
052:
053: public void myMethodDouble(double arg1, double arg2) {
054: }
055:
056: public void myMethodReference(Object arg1, Object arg2) {
057: }
058:
059: public void myMethodMixed(byte arg1, short arg2, int arg3,
060: long arg4, float arg5, double arg6, Object arg7, byte arg8,
061: short arg9, int arg10, long arg11, float arg12,
062: double arg13, Object arg14) {
063: }
064:
065: public void test_010_interface() {
066: ProseSystem.getAspectManager().insert(new MethodAspect());
067: MyInterface mi = new MyClass();
068:
069: crosscutted = false;
070: myMethod();
071: assertTrue("Method invocation is cross-cutted (empty)",
072: crosscutted);
073:
074: crosscutted = false;
075: byte b = 0;
076: myMethodByte(b, b);
077: assertTrue("Method invocation is cross-cutted (byte)",
078: crosscutted);
079:
080: crosscutted = false;
081: short s = 0;
082: myMethodShort(s, s);
083: assertTrue("Method invocation is cross-cutted (short)",
084: crosscutted);
085:
086: crosscutted = false;
087: myMethodInt(0, 0);
088: assertTrue("Method invocation is cross-cutted (int)",
089: crosscutted);
090:
091: crosscutted = false;
092: myMethodLong(0, 0);
093: assertTrue("Method invocation is cross-cutted (long)",
094: crosscutted);
095:
096: crosscutted = false;
097: myMethodFloat(0, 0);
098: assertTrue("Method invocation is cross-cutted (float)",
099: crosscutted);
100:
101: crosscutted = false;
102: myMethodDouble(0, 0);
103: assertTrue("Method invocation is cross-cutted (double)",
104: crosscutted);
105:
106: crosscutted = false;
107: myMethodReference(null, null);
108: assertTrue("Method invocation is cross-cutted (ref)",
109: crosscutted);
110:
111: crosscutted = false;
112: myMethodMixed(b, s, 0, 0, 0, 0, null, b, s, 0, 0, 0, 0, null);
113: assertTrue("Method invocation is cross-cutted (mixed)",
114: crosscutted);
115: }
116:
117: public interface MyInterface {
118: public void myMethod();
119: }
120:
121: public class MyClass implements MyInterface {
122: public void myMethod() {
123: };
124: }
125:
126: public class MethodAspect extends DefaultAspect {
127: public Crosscut c = new MethodCut() {
128: public void METHOD_ARGS(MethodArgumentsTest c, REST r) {
129: crosscutted = true;
130: }
131:
132: protected PointCutter pointCutter() {
133: return Within.method("myMethod.*").AND(
134: Executions.before());
135: }
136:
137: protected Class[] potentialCrosscutClasses() {
138: return new Class[] { MethodArgumentsTest.class };
139: }
140: };
141: };
142: }
143:
144: //======================================================================
145: //
146: // $Log$
147: //
|