01: /**
02: *
03: */package net.sf.oval.test.guard;
04:
05: import junit.framework.TestCase;
06: import net.sf.oval.constraint.NotNull;
07: import net.sf.oval.exception.ConstraintsViolatedException;
08: import net.sf.oval.guard.Guard;
09: import net.sf.oval.guard.Guarded;
10:
11: /**
12: * @author Sebastian Thomschke
13: *
14: */
15: public class OverridingHashCodeTest extends TestCase {
16: @Guarded
17: public class Entity {
18: @Override
19: public int hashCode() {
20: return super .hashCode();
21: }
22:
23: public void setFoo(@NotNull
24: String s) {
25: //
26: }
27: }
28:
29: public void testGuarding() {
30: final Guard guard = new Guard();
31: TestGuardAspect.aspectOf().setGuard(guard);
32: try {
33: new Entity().setFoo(null);
34: fail("Violation expected");
35: } catch (ConstraintsViolatedException e) {
36: // expected
37: }
38: }
39: }
|