Package de.cuioss.test.jsf.util
Interface JsfEnvironmentConsumer
-
- All Known Implementing Classes:
AbstractBeanTest,AbstractComponentRendererTest,AbstractComponentTest,AbstractConverterTest,AbstractPropertyAwareFacesTest,AbstractRendererTestBase,AbstractSanitizingConverterTest,AbstractUiComponentTest,AbstractValidatorTest,JsfEnabledTestEnvironment
public interface JsfEnvironmentConsumer
Simple interface to be used in context ofJsfSetupExtension. It provides an interface for injecting the configuredJsfEnvironmentHolder. It is needed, when the test needs to access either anJsfTestContextConfiguratorlikeComponentConfigDecoratororRequestConfigDecoratoror a JSF-Object likeFacesContextorApplicationprogrammatically. The typical usage:
The actual delegation is implemented using default implementations within this interface, see the unit-test:@Setter @Getter private JsfEnvironmentHolder environmentHolder;@EnableJsfEnvironment @JsfTestConfiguration(BasicApplicationConfiguration.class) class JsfSetupExtensionTest implements JsfEnvironmentConsumer { @Setter @Getter private JsfEnvironmentHolder environmentHolder; @Test void shouldBootstrapJsf() { assertNotNull(environmentHolder); assertNotNull(getApplication()); assertNotNull(getApplicationConfigDecorator()); assertNotNull(getBeanConfigDecorator()); assertNotNull(getComponentConfigDecorator()); assertNotNull(getExternalContext()); assertNotNull(getFacesContext()); assertNotNull(getRequestConfigDecorator()); assertNotNull(getResponse()); } @Test void shouldApplyBasicConfiguration() { assertEquals(BasicApplicationConfiguration.FIREFOX, getExternalContext().getRequestHeaderMap().get(BasicApplicationConfiguration.USER_AGENT)); }- Author:
- Oliver Wolff
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidassertNavigatedWithOutcome(String outcome)Asserts whether a navigation was handled by callingNavigationHandler.handleNavigation(javax.faces.context.FacesContext, String, String)default voidassertRedirect(String redirectUrl)Asserts whether a navigation was initialized by callingExternalContext.redirect(String)default ApplicationgetApplication()default ApplicationConfigDecoratorgetApplicationConfigDecorator()default BeanConfigDecoratorgetBeanConfigDecorator()default ComponentConfigDecoratorgetComponentConfigDecorator()JsfEnvironmentHoldergetEnvironmentHolder()default ExternalContextgetExternalContext()default FacesContextgetFacesContext()default RequestConfigDecoratorgetRequestConfigDecorator()default org.apache.myfaces.test.mock.MockHttpServletResponsegetResponse()voidsetEnvironmentHolder(JsfEnvironmentHolder holder)
-
-
-
Method Detail
-
setEnvironmentHolder
void setEnvironmentHolder(JsfEnvironmentHolder holder)
- Parameters:
holder- to be set, is never null. Will be called fromTestInstancePostProcessor.postProcessTestInstance(Object, org.junit.jupiter.api.extension.ExtensionContext)
-
getEnvironmentHolder
JsfEnvironmentHolder getEnvironmentHolder()
- Returns:
- holder set by
setEnvironmentHolder(JsfEnvironmentHolder)
-
getComponentConfigDecorator
default ComponentConfigDecorator getComponentConfigDecorator()
- Returns:
- an
ComponentConfigDecoratorfor the containedJsfEnvironmentHolder
-
getBeanConfigDecorator
default BeanConfigDecorator getBeanConfigDecorator()
- Returns:
- an
BeanConfigDecoratorfor the containedJsfEnvironmentHolder
-
getApplicationConfigDecorator
default ApplicationConfigDecorator getApplicationConfigDecorator()
- Returns:
- an
ApplicationConfigDecoratorfor the containedJsfEnvironmentHolder
-
getRequestConfigDecorator
default RequestConfigDecorator getRequestConfigDecorator()
- Returns:
- an
ApplicationConfigDecoratorfor the containedJsfEnvironmentHolder
-
getFacesContext
default FacesContext getFacesContext()
- Returns:
- an
FacesContextfor the containedJsfEnvironmentHolder
-
getApplication
default Application getApplication()
- Returns:
- an
Applicationfor the containedJsfEnvironmentHolder
-
getExternalContext
default ExternalContext getExternalContext()
- Returns:
- an
ExternalContextfor the containedJsfEnvironmentHolder
-
getResponse
default org.apache.myfaces.test.mock.MockHttpServletResponse getResponse()
- Returns:
- an
MockHttpServletResponsefor the containedJsfEnvironmentHolder
-
assertNavigatedWithOutcome
default void assertNavigatedWithOutcome(String outcome)
Asserts whether a navigation was handled by callingNavigationHandler.handleNavigation(javax.faces.context.FacesContext, String, String)- Parameters:
outcome- must not be null
-
assertRedirect
default void assertRedirect(String redirectUrl)
Asserts whether a navigation was initialized by callingExternalContext.redirect(String)- Parameters:
redirectUrl- must not be null
-
-