Package de.cuioss.test.jsf.renderer
Class AbstractRendererTestBase<R extends Renderer>
- java.lang.Object
-
- de.cuioss.test.jsf.junit5.JsfEnabledTestEnvironment
-
- de.cuioss.test.jsf.renderer.AbstractRendererTestBase<R>
-
- Type Parameters:
R- The renderer being tested
- All Implemented Interfaces:
JsfEnvironmentConsumer,de.cuioss.test.valueobjects.objects.ConfigurationCallBackHandler<R>
- Direct Known Subclasses:
AbstractComponentRendererTest
public abstract class AbstractRendererTestBase<R extends Renderer> extends JsfEnabledTestEnvironment implements de.cuioss.test.valueobjects.objects.ConfigurationCallBackHandler<R>
Base class for testing implementations ofRenderer. It focuses on conveniences and the basic-api contracts.Configuration
Documentation on the setup of the JSF-related test-infrastructure can be found at
EnableJsfEnvironmentIt acts as an
ConfigurationCallBackHandler, saying after initialization and prior to testing the methodConfigurationCallBackHandler.configure(Object)will be called allowing the concrete test-class to do some specific configuration e.g. calling init-methods and such.You can easily access pre-configured instance by calling
getRenderer().API-Tests
Base Renderer Test. Verify API contract of Renderer for- Renderer.decode(FacesContext, UIComponent)
- Renderer.encodeBegin(FacesContext, UIComponent)
- Renderer.encodeChildren(FacesContext, UIComponent)
- Renderer.encodeEnd(FacesContext, UIComponent)
- Renderer.convertClientId(FacesContext, String)
Contracts
assertRenderResult(UIComponent, Document)andassertRenderResult(UIComponent, String)are the main 'business' methods for explicit testing
- Author:
- Oliver Wolff
-
-
Constructor Summary
Constructors Constructor Description AbstractRendererTestBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidassertEmptyRenderResult(UIComponent toBeRendered)Assert, that the given component does not render any output.voidassertRenderResult(UIComponent toBeRendered, String expected)voidassertRenderResult(UIComponent toBeRendered, org.jdom2.Document expected)Calls the renderer and checks the result against the given expectedDocumentprotected abstract UIComponentgetComponent()RgetRenderer()StringrenderToString(UIComponent toBeRendered)Renders the given component / renderer into a String representation-
Methods inherited from class de.cuioss.test.jsf.junit5.JsfEnabledTestEnvironment
getEnvironmentHolder, setEnvironmentHolder
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.cuioss.test.valueobjects.objects.ConfigurationCallBackHandler
configure
-
Methods inherited from interface de.cuioss.test.jsf.util.JsfEnvironmentConsumer
assertNavigatedWithOutcome, assertRedirect, getApplication, getApplicationConfigDecorator, getBeanConfigDecorator, getComponentConfigDecorator, getExternalContext, getFacesContext, getRequestConfigDecorator, getResponse
-
-
-
-
Constructor Detail
-
AbstractRendererTestBase
public AbstractRendererTestBase()
-
-
Method Detail
-
getComponent
protected abstract UIComponent getComponent()
- Returns:
- the configured
UIComponent. Caution: you must always create a new instance of the component on each call
-
renderToString
public String renderToString(UIComponent toBeRendered) throws IOException
Renders the given component / renderer into a String representation- Parameters:
toBeRendered- the component to be passed to the renderer, must not be null- Returns:
- the String-result of the rendering
- Throws:
IOException
-
assertRenderResult
public void assertRenderResult(UIComponent toBeRendered, org.jdom2.Document expected)
Calls the renderer and checks the result against the given expectedDocument- Parameters:
toBeRendered- the component to be passed to the renderer, must not be nullexpected- must not be null
-
assertRenderResult
public void assertRenderResult(UIComponent toBeRendered, String expected)
- Parameters:
toBeRendered- the component to be passed to the renderer, must not be nullexpected- must not be null
-
assertEmptyRenderResult
public void assertEmptyRenderResult(UIComponent toBeRendered)
Assert, that the given component does not render any output.- Parameters:
toBeRendered- the component to be passed to the renderer, must not be null
-
getRenderer
public R getRenderer()
-
-