com.mockrunner.mock.web.MockRequestDispatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Mockrunner is a lightweight framework for unit testing applications
in the J2EE environment. It supports servlets, filters, tag classes
and Struts actions. It includes a JDBC a JMS and a JCA test
framework and can be used to test EJB based applications.
The newest version!
package com.mockrunner.mock.web;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
* Mock implementation of RequestDispatcher
.
*/
public class MockRequestDispatcher implements RequestDispatcher
{
private ServletRequest forwardedRequest;
private ServletResponse forwardedResponse;
private ServletRequest includedRequest;
private ServletResponse includedResponse;
private String path;
/**
* Sets the path for this RequestDispatcher
.
* @param path the path
*/
public void setPath(String path)
{
this.path = path;
}
/**
* Returns the name or path used to retrieve this RequestDispatcher
.
* @return the name or path used to retrieve this RequestDispatcher
*/
public String getPath()
{
return path;
}
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException
{
forwardedRequest = request;
forwardedResponse = response;
}
public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException
{
includedRequest = request;
includedResponse = response;
}
public ServletRequest getForwardedRequest()
{
return forwardedRequest;
}
public ServletResponse getForwardedResponse()
{
return forwardedResponse;
}
public ServletRequest getIncludedRequest()
{
return includedRequest;
}
public ServletResponse getIncludedResponse()
{
return includedResponse;
}
}