01: package ch.ethz.prose.crosscut;
02:
03: import junit.framework.TestCase;
04: import ch.ethz.prose.*;
05: import ch.ethz.prose.filter.Fields;
06: import ch.ethz.prose.filter.PointCutter;
07:
08: public class ConstructorFieldTest extends TestCase {
09:
10: protected static boolean crosscutted;
11:
12: public ConstructorFieldTest(String name) {
13: super (name);
14: }
15:
16: protected void setUp() throws SystemStartupException {
17: ProseSystem.startup();
18: crosscutted = false;
19: }
20:
21: protected void tearDown() throws SystemTeardownException {
22: ProseSystem.teardown();
23: }
24:
25: public void test_010_empty_constructor() {
26: ProseSystem.getAspectManager().insert(new TestAspect());
27: TestClass tc = new TestClass();
28: assertTrue("Field `value' is crosscutted by a GetCut",
29: crosscutted);
30: }
31:
32: public void test_020_second_constructor() {
33: ProseSystem.getAspectManager().insert(new TestAspect());
34: TestClass tc = new TestClass(42);
35: assertTrue("Field `value' is crosscutted by a GetCut",
36: crosscutted);
37: }
38:
39: public static class TestClass {
40: int value = 10;
41:
42: public TestClass() {
43: };
44:
45: public TestClass(int v) {
46: value = v;
47: }
48: }
49:
50: public static class TestAspect extends DefaultAspect {
51: public Crosscut c = new SetCut() {
52: public void SET_ARGS(TestClass c, int v) {
53: crosscutted = true;
54: }
55:
56: protected PointCutter pointCutter() {
57: return Fields.named("value");
58: }
59:
60: protected Class[] potentialCrosscutClasses() {
61: return new Class[] { TestClass.class };
62: }
63: };
64: }
65:
66: }
|