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

import java.util.Map;
import javax.portlet.PortletResponse;
import org.ajax4jsf.portlet.MockActionRequest;
import org.ajax4jsf.portlet.MockActionResponse;
import org.ajax4jsf.portlet.MockPortletContext;
import org.ajax4jsf.portlet.MockPortletRequest;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;

/**
 * @author asmirnov
 *
 */
public class PortletExternalContextTest extends AbstractAjax4JsfTestCase {
    private AbstractExternalContext portletContextImpl;
    private FacesContextImpl portalFacesContext;
    private MockPortletContext portletContext;
    private MockActionRequest portletRequest;
    private MockActionResponse portletResponse;

    /**
     * @param arg0
     */
    public PortletExternalContextTest(String arg0) {
	super(arg0);
    }

    /* (non-Javadoc)
     * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
     */
    public void setUp() throws Exception {
	super.setUp();
	portletContext=new MockPortletContext(servletContext);
	portletRequest = new MockActionRequest(portletContext);
	portletResponse = new MockActionResponse();
	portletContextImpl = new PortletExternalContextImpl(portletContext,portletRequest,portletResponse);
	portalFacesContext = new FacesContextImpl(portletContextImpl,lifecycle);
	portalFacesContext.setViewRoot(facesContext.getViewRoot());
    }

    /* (non-Javadoc)
     * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
     */
    public void tearDown() throws Exception {
	super.tearDown();
	portletContextImpl = null;
	portalFacesContext = null;
	portletContext = null;
	portletRequest = null;
	portletResponse = null;
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.PortletExternalContextImpl#getRequestParameterValuesMap()}.
     */
    public final void testGetRequestParameterValuesMap() {
	Map requestParameterValuesMap = portalFacesContext.getExternalContext().getRequestParameterValuesMap();
	assertNotNull(requestParameterValuesMap);
	assertSame(requestParameterValuesMap, portalFacesContext.getExternalContext().getRequestParameterValuesMap());
	assertSame(requestParameterValuesMap.get(MockPortletRequest.PARAMETER), portletRequest.getParameterValues(MockPortletRequest.PARAMETER));
	
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.PortletExternalContextImpl#getInitParameter(java.lang.String)}.
     */
    public final void testGetInitParameterString() {
	//TODO: Figure out why it fails?
	assertNull(portalFacesContext.getExternalContext().getInitParameter("blabla"));
	//assertSame(MockPortletContext.PORTLET_INIT_VALUE, portalFacesContext.getExternalContext().getInitParameter(MockPortletContext.INIT_PARAMETER));
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.PortletExternalContextImpl#getRequestLocales()}.
     */
    public final void testGetRequestLocales() {
//	fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.PortletExternalContextImpl#getSession(boolean)}.
     */
    public final void testGetSessionBoolean() {
//	fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getApplicationMap()}.
     */
    public final void testGetApplicationMap() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getInitParameterMap()}.
     */
    public final void testGetInitParameterMap() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#setRequest(java.lang.Object)}.
     */
    public final void testSetRequestObject() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestCookieMap()}.
     */
    public final void testGetRequestCookieMap() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestHeaderMap()}.
     */
    public final void testGetRequestHeaderMap() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestHeaderValuesMap()}.
     */
    public final void testGetRequestHeaderValuesMap() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestMap()}.
     */
    public final void testGetRequestMap() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestParameterMap()}.
     */
    public final void testGetRequestParameterMap() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestParameterNames()}.
     */
    public final void testGetRequestParameterNames() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#setResponse(java.lang.Object)}.
     */
    public final void testSetResponseObject() {
	// fail("Not yet implemented");
    }

    /**
     * Test method for {@link org.ajax4jsf.portlet.context.AbstractExternalContext#getSessionMap()}.
     */
    public final void testGetSessionMap() {
	// fail("Not yet implemented");
    }
}
