Class ConfigurationRule<T>

java.lang.Object
org.junit.rules.ExternalResource
de.hybris.platform.integrationservices.util.ConfigurationRule<T>
All Implemented Interfaces:
org.junit.rules.TestRule

public class ConfigurationRule<T> extends org.junit.rules.ExternalResource
A test rule that automatically restores configuration changes done by the tests.
IMPORTANT: this rule can only manage beans written in Java. It fails to manage beans, for example, written in Groovy.
  • Method Details

    • createFor

      public static <C> ConfigurationRule<C> createFor(String beanId, Class<C> type)
      Creates a configuration rule for managing configuration parameters changes on the specified Spring bean.
      Type Parameters:
      C - class of the bean managed by this rule.
      Parameters:
      beanId - ID of the Spring Bean to be managed by this rule.
      type - type of the Spring Bean to be managed by this rule.
      Returns:
      a rule that automatically restores any settings changed on the Spring Bean.
    • createFor

      public static <C> ConfigurationRule<C> createFor(C bean)
      Creates a configuration rule for managing changes on the specified Java Bean instance.
      Type Parameters:
      C - class of the bean managed by this rule.
      Parameters:
      bean - a Java Bean to manage changes for.
      Returns:
      a rule that automatically restores any settings changed on the Java Bean.
    • configuration

      public T configuration()
    • intercept

      @RuntimeType public Object intercept(@Origin Method method, @AllArguments Object[] values)
      Intercepts invocations to the configuration managed by this rule.
      Parameters:
      method - method being called on the configuration object.
      values - parameters passed into the method.
      Returns:
      value returned by the configuration method being called.
    • after

      protected void after()
      Overrides:
      after in class org.junit.rules.ExternalResource