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

org.milyn.useragent.request.MockHttpRequest Maven / Gradle / Ivy

There is a newer version: 1.7.1
Show newest version
package org.milyn.useragent.request;

import java.util.Hashtable;
import java.util.Enumeration;

/**
 * Mock object for a Http request.
 * 
 * @author Tom Fennelly
 */

public class MockHttpRequest implements HttpRequest {
	Hashtable headers = new Hashtable();

	Hashtable params = new Hashtable();

	public void setHeader(String header, String value) {
		headers.put(header, value);
	}

	public void setParameter(String parameter, String value) {
		params.put(parameter, value);
	}

	public String getHeader(String name) {
		return headers.get(name);
	}

	public String getParameter(String name) {
		return params.get(name);
	}

    public Enumeration getParameterNames() {
        return params.keys();
    }

    public String[] getParameterValues(String name) {
        String value = getParameter(name);

        if(value != null) {
            return new String[] {value};
        } else {
            return null;
        }

    }

    public void reset() {
		headers.clear();
		params.clear();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy