package com.oreilly.javaxp.cactus.filter;
import junit.framework.Assert;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
/**
* @author Brian M. Coyner
* $version $Id: MockFilterChain.java,v 1.4 2003/02/27 00:24:43 jepc Exp $
*/
public class MockFilterChain implements FilterChain {
private boolean shouldBeInvoked;
private boolean wasInvoked;
public void doFilter(ServletRequest req, ServletResponse res)
throws IOException, ServletException {
this.wasInvoked = true;
}
public void setExpectedInvocation(boolean shouldBeInvoked) {
this.shouldBeInvoked = shouldBeInvoked;
}
public void verify() {
if (this.shouldBeInvoked) {
Assert.assertTrue("Expected MockFilterChain to be invoked.",
this.wasInvoked);
} else {
Assert.assertTrue("Expected MockFilterChain filter not to be invoked.",
!this.wasInvoked);
}
}
}
|