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

com.jsftoolkit.test.AbstractHtmlRendererTest Maven / Gradle / Ivy

Go to download

The core classes for the JSF Toolkit Component Framework. Includes all framework base and utility classes as well as component kick-start/code-generation and registration tools. Also includes some classes for testing that are reused in other projects. They cannot be factored out into a separate project because they are referenced by the tests and they reference this code (circular dependence).

The newest version!
package com.jsftoolkit.test;

import java.io.IOException;
import java.io.StringWriter;

import javax.faces.component.UIComponent;

import org.apache.shale.test.base.AbstractJsfTestCase;
import org.apache.shale.test.mock.MockResponseWriter;
import org.xml.sax.SAXException;

import com.jsftoolkit.base.renderer.HtmlRenderer;

public abstract class AbstractHtmlRendererTest extends AbstractJsfTestCase {

	protected HtmlRenderer renderer;

	private StringWriter writer;

	public AbstractHtmlRendererTest(String template) throws IOException,
			SAXException {
		this(new HtmlRenderer(template) {
		});
	}

	protected AbstractHtmlRendererTest(HtmlRenderer renderer) {
		super("HtmlRendererTest");
		this.renderer = renderer;
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		writer = new StringWriter();
		facesContext.setResponseWriter(new MockResponseWriter(writer,
				"application/xhtml+xml", "US-ASCII"));
	}

	protected void checkOutput(UIComponent component, String expected)
			throws IOException {
		renderer.encodeBegin(facesContext, component);
		renderer.encodeChildren(facesContext, component);
		renderer.encodeEnd(facesContext, component);
		facesContext.getResponseWriter().close();
		assertEquals(expected, writer.toString());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy