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:

    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 within JsfEnvironmentHolder With 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 IdentityResourceBundle configured: 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 setting useIdentityResourceBundle(). If it is active it is used as well for resolving the MessageBundle. In case of many annotations of EnableJsfEnvironment are in the type hierarchy, the one on the most concrete Type will be chosen, usually on the actual unit-test.

    Author:
    Oliver Wolff
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean useIdentityResourceBundle