Class ConfigurableFacesTest
- java.lang.Object
-
- de.cuioss.test.jsf.util.ConfigurableFacesTest
-
public class ConfigurableFacesTest extends Object
Base class for configuring theFacesContextprovided by MyFaces-Test. The configuration is implemented using some kind of decorator pattern (roughly). The actual configuration relies on two sources:- It scans for the annotations of type
JsfTestConfigurationinstantiates the corresponding classes and configures the environment accordingly - It checks whether the actual test-class implements one of
ApplicationConfigurator,BeanConfigurator,RequestConfiguratororComponentConfiguratorand calls the corresponding methods accordingly, after the configurator derived by the annotations
The corresponding objects
ComponentConfigurator,BeanConfigDecorator,RequestConfigDecoratorandApplicationConfiguratorcan be accessed by the getter-methods, in case you need to configure elements for a certain test only.In addition there is a new way of dealing with localized messages for unit-tests. In essence there is the
IdentityResourceBundleconfigured: This is helpful for tests where you want to ensure that a certain message key is used to create a message but do not want to test the actual ResourceBundle mechanism itself. It will always return the given key itself. As default this mechanism is active, you can change this by overwriting #isUseIdentityResouceBundle(). If it is active it is used as well for resolving the MessageBundle- Author:
- Oliver Wolff
- It scans for the annotations of type
-
-
Field Summary
Fields Modifier and Type Field Description static StringLOCATION_HEADER"Location"
-
Constructor Summary
Constructors Constructor Description ConfigurableFacesTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertNavigatedWithOutcome(String outcome)Asserts whether a navigation was handled by callingNavigationHandler.handleNavigation(javax.faces.context.FacesContext, String, String)voidassertRedirect(String redirectUrl)Asserts whether a navigation was initialized by callingExternalContext.redirect(String)protected ApplicationgetApplication()protected ApplicationConfigDecoratorgetApplicationConfigDecorator()protected BeanConfigDecoratorgetBeanConfigDecorator()protected ComponentConfigDecoratorgetComponentConfigDecorator()protected ExternalContextgetExternalContext()protected FacesContextgetFacesContext()RequestConfigDecoratorgetRequestConfigDecorator()protected org.apache.myfaces.test.mock.MockHttpServletResponsegetResponse()protected booleanisUseIdentityResourceBundle()protected voidsetupAdditionalConfiguration()See class documentation ofConfigurableFacesTestfor details.
-
-
-
Field Detail
-
LOCATION_HEADER
public static final String LOCATION_HEADER
"Location"- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConfigurableFacesTest
public ConfigurableFacesTest()
-
-
Method Detail
-
setupAdditionalConfiguration
@BeforeEach protected void setupAdditionalConfiguration()
See class documentation ofConfigurableFacesTestfor details.
-
getFacesContext
protected FacesContext getFacesContext()
-
getApplication
protected Application getApplication()
-
getExternalContext
protected ExternalContext getExternalContext()
-
getResponse
protected org.apache.myfaces.test.mock.MockHttpServletResponse getResponse()
-
isUseIdentityResourceBundle
protected boolean isUseIdentityResourceBundle()
-
assertNavigatedWithOutcome
public 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
public void assertRedirect(String redirectUrl)
Asserts whether a navigation was initialized by callingExternalContext.redirect(String)- Parameters:
redirectUrl- must not be null
-
getComponentConfigDecorator
protected ComponentConfigDecorator getComponentConfigDecorator()
-
getBeanConfigDecorator
protected BeanConfigDecorator getBeanConfigDecorator()
-
getApplicationConfigDecorator
protected ApplicationConfigDecorator getApplicationConfigDecorator()
-
getRequestConfigDecorator
public RequestConfigDecorator getRequestConfigDecorator()
-
-