Class BrowserlessFeatureFlags

java.lang.Object
com.vaadin.experimental.FeatureFlags
com.vaadin.browserless.internal.BrowserlessFeatureFlags
All Implemented Interfaces:
Serializable

public class BrowserlessFeatureFlags extends FeatureFlags
FeatureFlags implementation that applies test defined feature flag overrides on top of the ones resolved by Vaadin.

The instance is installed into the VaadinContext of the mock environment before the Vaadin servlet is initialized, so that everything reading feature flags during startup, for example a VaadinServiceInitListener, already observes the test configuration.

For internal use only. May be renamed or removed in a future release.

Since:
25.3
See Also:
  • Method Details

    • install

      public static void install(VaadinContext context, Map<String,Boolean> overrides)
      Installs a FeatureFlags instance applying the given overrides into the given Vaadin context.

      Must be invoked before anything requests the feature flags for the context, otherwise Vaadin creates and caches its own instance.

      Parameters:
      context - the Vaadin context of the mock environment, not null
      overrides - feature identifiers mapped to their enablement state, not null
      Throws:
      BrowserlessTestSetupException - if a feature identifier is not known by Vaadin
    • loadProperties

      public void loadProperties()
      Read the feature flag properties files and updates the enable property of each feature object.

      Re-applies the test defined overrides, so that they are not silently discarded by code reloading the feature flags, for example through FeatureFlags.setPropertiesLocation(java.io.File).

      Overrides:
      loadProperties in class FeatureFlags
    • setEnabled

      public void setEnabled(String featureId, boolean enabled)
      Enables or disables the given feature.

      Toggles the feature for the current test only. Unlike the default implementation, it neither requires development mode nor stores the new state into the vaadin-featureflags.properties file of the project.

      The new state is recorded among the overrides, so that it survives a later reload of the feature flags, exactly like the states declared by the test configuration.

      Overrides:
      setEnabled in class FeatureFlags
      Parameters:
      featureId - the feature id
      enabled - true to enable, false to disable