01: // StrutsTestCase - a JUnit extension for testing Struts actions
02: // within the context of the ActionServlet.
03: // Copyright (C) 2002 Deryl Seale
04: //
05: // This library is free software; you can redistribute it and/or
06: // modify it under the terms of the Apache Software License as
07: // published by the Apache Software Foundation; either version 1.1
08: // of the License, or (at your option) any later version.
09: //
10: // This library is distributed in the hope that it will be useful,
11: // but WITHOUT ANY WARRANTY; without even the implied warranty of
12: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: // Apache Software Foundation Licens for more details.
14: //
15: // You may view the full text here: http://www.apache.org/LICENSE.txt
16:
17: package servletunit;
18:
19: import javax.servlet.FilterChain;
20: import javax.servlet.ServletRequest;
21: import javax.servlet.ServletResponse;
22:
23: /**
24: * A unit testing tool for simulating a FilterChain <p>
25: *
26: *
27: * @author Sean Pritchard
28: * May 11, 2002
29: * @version 1.0
30: */
31:
32: public class FilterChainSimulator implements FilterChain {
33:
34: private ServletRequest request = null;
35: private ServletResponse response = null;
36: private boolean doFilterCalled = false;
37:
38: /**
39: * Constructor for the FilterChainSimulator object
40: */
41: public FilterChainSimulator() {
42: }
43:
44: /**
45: * Description of the Method
46: *
47: * @param parm1 The request
48: * @param parm2 The response
49: * @exception javax.servlet.ServletException
50: * @exception java.io.IOException Description of the Exception
51: */
52: public void doFilter(ServletRequest parm1, ServletResponse parm2)
53: throws javax.servlet.ServletException, java.io.IOException {
54: request = parm1;
55: response = parm2;
56: doFilterCalled = true;
57: }
58:
59: /**
60: * Gets the request passed in as a parameter of the doFilter call.
61: *
62: * @return The request value
63: */
64: public ServletRequest getRequest() {
65: return request;
66: }
67:
68: /**
69: * * Gets the response passed in as a parameter of the doFilter call.
70: *
71: * @return The response value
72: */
73: public ServletResponse getResponse() {
74: return response;
75: }
76:
77: /**
78: * Indicates whether doFilter has been called.
79: *
80: * @return true if doFilter has been called
81: */
82: public boolean doFilterCalled() {
83: return doFilterCalled;
84: }
85: }
|