01 import junit.framework.Assert;
02 import javax.servlet.*;
03 import java.io.IOException;
04
05 public class MyFilterChain implements FilterChain {
06
07 private boolean shouldBeInvoked;
08 private boolean wasInvoked;
09
10 public void doFilter(ServletRequest req, ServletResponse res)
11 throws IOException, ServletException {
12 this.wasInvoked = true;
13 }
14 // rozhodovací ukazovateľ
15 public void setExpectedInvocation(boolean shouldBeInvoked) {
16 this.shouldBeInvoked = shouldBeInvoked;
17 }
18 // overovacia metóda
19 public void verify() {
20 if (this.shouldBeInvoked) {
21 Assert.assertTrue("SecurityFilter was done.", this.wasInvoked);
22 } else {
23 Assert.assertFalse("SecurityFilter was break.", this.wasInvoked);
24 }
25 }
26 }
|