01: /**
02: *
03: */package net.sf.oval.test.guard;
04:
05: import junit.framework.TestCase;
06: import net.sf.oval.guard.Guard;
07: import net.sf.oval.guard.Guarded;
08:
09: /**
10: * @author Sebastian Thomschke
11: *
12: */
13: public class OverridingEqualsTest extends TestCase {
14: @Guarded
15: public class Entity {
16: private int foo;
17:
18: @Override
19: public boolean equals(Object o) {
20: final boolean retVal;
21: if (o == null) {
22: retVal = false;
23: } else if (o instanceof Entity) {
24: retVal = ((Entity) o).foo == foo;
25: } else {
26: retVal = false;
27: }
28: return retVal;
29: }
30: }
31:
32: public void testGuarding() {
33: final Guard guard = new Guard();
34: TestGuardAspect.aspectOf().setGuard(guard);
35:
36: Entity a1 = new Entity();
37: a1.foo = 2;
38: Entity a2 = new Entity();
39: a2.foo = 2;
40:
41: assertEquals(a1, a2);
42: }
43: }
|