01: package com.mockrunner.mock.web;
02:
03: import java.io.IOException;
04:
05: import javax.servlet.RequestDispatcher;
06: import javax.servlet.ServletException;
07: import javax.servlet.ServletRequest;
08: import javax.servlet.ServletResponse;
09:
10: /**
11: * Mock implementation of <code>RequestDispatcher</code>.
12: */
13: public class MockRequestDispatcher implements RequestDispatcher {
14: private ServletRequest forwardedRequest;
15: private ServletResponse forwardedResponse;
16: private ServletRequest includedRequest;
17: private ServletResponse includedResponse;
18: private String path;
19:
20: /**
21: * Sets the path for this <code>RequestDispatcher</code>.
22: * @param path the path
23: */
24: public void setPath(String path) {
25: this .path = path;
26: }
27:
28: /**
29: * Returns the name or path used to retrieve this <code>RequestDispatcher</code>.
30: * @return the name or path used to retrieve this <code>RequestDispatcher</code>
31: */
32: public String getPath() {
33: return path;
34: }
35:
36: public void forward(ServletRequest request, ServletResponse response)
37: throws ServletException, IOException {
38: forwardedRequest = request;
39: forwardedResponse = response;
40: }
41:
42: public void include(ServletRequest request, ServletResponse response)
43: throws ServletException, IOException {
44: includedRequest = request;
45: includedResponse = response;
46: }
47:
48: public ServletRequest getForwardedRequest() {
49: return forwardedRequest;
50: }
51:
52: public ServletResponse getForwardedResponse() {
53: return forwardedResponse;
54: }
55:
56: public ServletRequest getIncludedRequest() {
57: return includedRequest;
58: }
59:
60: public ServletResponse getIncludedResponse() {
61: return includedResponse;
62: }
63: }
|