Annotation Type EnableJsfEnvironment
-
@Documented @Retention(RUNTIME) @Target(TYPE) @ExtendWith(JsfSetupExtension.class) @Repeatable(de.cuioss.test.jsf.junit5.EnableJsfEnvironments.class) public @interface EnableJsfEnvironment
Using this annotations at type-level of a junit 5 test enable the myfaces-test-based test-framework for unit-tests. 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
Using
Simple Sample: Use a preconfigured JSF-context for the test providing BasicApplicationConfiguration
@EnableJsfEnvironment @JsfTestConfiguration(BasicApplicationConfiguration.class) class JSFEnableTest {Complex Sample: Use a preconfigured JSF-context with access to the context information like
FacesContext,ComponentConfigurator, ... as defined withinJsfEnvironmentHolderWith this setup you can programmatically access the element@EnableJsfEnvironment @JsfTestConfiguration(BasicApplicationConfiguration.class) class JsfSetupExtensionTest implements JsfEnvironmentConsumer { @Setter @Getter private JsfEnvironmentHolder environmentHolder;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 settinguseIdentityResourceBundle(). If it is active it is used as well for resolving the MessageBundle. In case of many annotations ofEnableJsfEnvironmentare in the type hierarchy, the one on the most concrete Type will be chosen, usually on the actual unit-test.- Author:
- Oliver Wolff
- It scans for the annotations of type
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanuseIdentityResourceBundle
-
-
-
Element Detail
-
useIdentityResourceBundle
boolean useIdentityResourceBundle
- Returns:
- boolean
- Default:
- true
-
-