/**
 * License Agreement.
 *
 * Rich Faces - Natural Ajax for Java Server Faces (JSF)
 *
 * Copyright (C) 2007 Exadel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

package org.ajax4jsf.webapp;

import java.io.InputStream;

import javax.servlet.ServletException;

import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.webapp.WebXml;
import org.apache.shale.test.mock.MockServletContext;

public class WebXmlTest extends AbstractAjax4JsfTestCase {

	MockServletContext context;

	public WebXmlTest(String arg0) {
		super(arg0);
	}

	public void setUp() throws Exception {
			super.setUp();
		context = new MockServletContext(){

			/* (non-Javadoc)
			 * @see org.apache.shale.test.mock.MockServletContext#getResourceAsStream(java.lang.String)
			 */
			public InputStream getResourceAsStream(String uri) {
				if(uri.equals(WebXml.WEB_XML)){
					return this.getClass().getResourceAsStream("/WEB-INF/complex-web.xml");
				} else {
					return super.getResourceAsStream(uri);
				}
			}
			
		};
	}

	public void tearDown() throws Exception {
		super.tearDown();
	}

	/*
	 * Test method for 'org.ajax4jsf.webapp.WebXml.reset()'
	 */
	public void testReset() {

	}

	/*
	 * Test method for 'org.ajax4jsf.webapp.WebXml.init(ServletContext, String)'
	 */
	public void testInit() throws ServletException {
		WebXml webXml = new WebXml();
		webXml.init(context,"ajax4jsf");
		assertFalse(webXml.isPrefixMapping());
		assertNull(webXml.getFacesFilterPrefix());
		assertNotNull(webXml.getFacesFilterSuffix());
		assertEquals(".jsf",webXml.getFacesFilterSuffix());
	}

	/*
	 * Test method for 'org.ajax4jsf.webapp.WebXml.getInstance()'
	 */
	public void testGetInstance() {

	}

	/*
	 * Test method for 'org.ajax4jsf.webapp.WebXml.getFacesResourceURL(FacesContext, String)'
	 */
	public void testGetFacesResourceURL() throws ServletException {
		WebXml webXml = new WebXml();
		webXml.init(context,"ajax4jsf");
		String resourceURL = webXml.getFacesResourceURL(facesContext,"foo.Bar");
		System.out.println(resourceURL);
		assertEquals("/testContext/"+WebXml.RESOURCE_URI_PREFIX+"foo.Bar.jsf",resourceURL);
		
	}

	/*
	 * Test method for 'org.ajax4jsf.webapp.WebXml.getFacesResourceKey(HttpServletRequest)'
	 */
	public void testGetFacesResourceKey() {

	}

	/*
	 * Test method for 'org.ajax4jsf.webapp.WebXml.isFacesRequest(HttpServletRequest)'
	 */
	public void testIsFacesRequest() {

	}

	/*
	 * Test method for 'org.ajax4jsf.webapp.WebXml.setFilterName(String)'
	 */
	public void testSetFilterName() {

	}

}
