Class LocalizationBundleStub

java.lang.Object
org.silverpeas.kernel.test.extension.LocalizationBundleStub
All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension

public class LocalizationBundleStub extends Object implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
Provides easy stubbing on the LocalizationBundle in unit tests. This class is to declare as a field of the unit test class a LocalizationBundle that will be used by the tests and with which some translations can be preconfigured or modified without having to use a set of physical properties files (a LocalizationBundle is mapped to a l10n properties file). By annotating the field with the RegisterExtension annotation, the required resources initialization is performed before the execution of a unit test and the resource cleanup is applied once the unit test resumed.
Author:
silveryocha
  • Field Details

  • Constructor Details

    • LocalizationBundleStub

      public LocalizationBundleStub(String bundleName, String... languages)
  • Method Details

    • put

      public LocalizationBundleStub put(String key, String value)
      Puts a couple key / value linked to default locale set by the extension itself.
      Parameters:
      key - the key.
      value - the value.
      Returns:
      itself.
    • put

      public LocalizationBundleStub put(String locale, String key, String value)
      Puts a couple key / value linked to specified locale.
      Parameters:
      locale - the locale.
      key - the key.
      value - the value.
      Returns:
      itself.
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
      Throws:
      Exception
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
    • clear

      protected void clear()