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

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

Go to download

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.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;

/**
 * Mock implementation of ServletConfig.
 */
public class MockServletConfig implements ServletConfig
{
    private ServletContext servletContext;
    private Map initParameters;
    private String servletName;
    
    public MockServletConfig()
    {
        initParameters = new HashMap();
    }

    public synchronized String getServletName()
    {
        return servletName;
    }
    
    public synchronized void setServletName(String servletName)
    {
        this.servletName = servletName;
    }

    public synchronized ServletContext getServletContext()
    {
        return servletContext;
    }
    
    /**
     * Sets the ServletContext.
     * @param servletContext the ServletContext
     */
    public synchronized void setServletContext(ServletContext servletContext)
    {
        this.servletContext = servletContext;
    }
    
    /**
     * Clears the init parameters.
     */
    public synchronized void clearInitParameters()
    {
        initParameters.clear();
    }

    public synchronized String getInitParameter(String name)
    {
        return (String)initParameters.get(name);
    }
    
    /**
     * Sets an init parameter.
     * @param name the name
     * @param value the value
     */
    public synchronized void setInitParameter(String name, String value) 
    {
        initParameters.put(name, value);
    }
    
    /**
     * Sets several init parameters.
     * @param parameters the parameter map
     */
    public synchronized void setInitParameters(Map parameters) 
    {
        initParameters.putAll(parameters);
    }

    public synchronized Enumeration getInitParameterNames()
    {
        return new Vector(initParameters.keySet()).elements();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy