/**
 * 
 */
package org.ajax4jsf.portlet;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;

/**
 * @author asmirnov
 *
 */
public class MockPortletConfig implements PortletConfig {
	
	private final PortletContext context;
	
	private Map<String, String> parameters;

	private String portletName="generic";
	

	/* (non-Javadoc)
	 * @see javax.portlet.PortletConfig#getInitParameter(java.lang.String)
	 */
	public String getInitParameter(String arg0) {
		
		return parameters.get(arg0);
	}

	/* (non-Javadoc)
	 * @see javax.portlet.PortletConfig#getInitParameterNames()
	 */
	public Enumeration getInitParameterNames() {
		return new IteratorEnumeration(parameters.keySet().iterator());
	}

	/* (non-Javadoc)
	 * @see javax.portlet.PortletConfig#getPortletContext()
	 */
	public PortletContext getPortletContext() {
		return context;
	}

	/* (non-Javadoc)
	 * @see javax.portlet.PortletConfig#getPortletName()
	 */
	public String getPortletName() {
		// TODO Auto-generated method stub
		return this.portletName;
	}

	/* (non-Javadoc)
	 * @see javax.portlet.PortletConfig#getResourceBundle(java.util.Locale)
	 */
	public ResourceBundle getResourceBundle(Locale arg0) {
		return ResourceBundle.getBundle("javax.portlet.faces.bundle", arg0);
	}

	/**
	 * @param portletName the portletName to set
	 */
	public void setPortletName(String name) {
		this.portletName = name;
	}
	
	public void addInitParameter(String name, String value){
		this.parameters.put(name, value);
	}

	public MockPortletConfig(PortletContext context) {
		super();
		this.context = context;
		parameters = new HashMap<String, String>();
	}

}
