All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.mock.web.MockRequestDispatcher Maven / Gradle / Ivy

There is a newer version: 2.0.7
Show 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy