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 Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]All the languages theLocalizationBundleactually supports.static final StringThe default ISO 639-1 code of the german language for theLocalizationBundlestatic final StringThe default ISO 639-1 code of the english language for theLocalizationBundlestatic final StringThe default ISO 639-1 code of the french language for theLocalizationBundle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) protected voidclear()Puts a couple key / value linked to default locale set by the extension itself.Puts a couple key / value linked to specified locale.
-
Field Details
-
LANGUAGE_FR
The default ISO 639-1 code of the french language for theLocalizationBundle- See Also:
-
LANGUAGE_EN
The default ISO 639-1 code of the english language for theLocalizationBundle- See Also:
-
LANGUAGE_DE
The default ISO 639-1 code of the german language for theLocalizationBundle- See Also:
-
LANGUAGE_ALL
All the languages theLocalizationBundleactually supports.
-
-
Constructor Details
-
LocalizationBundleStub
-
-
Method Details
-
put
Puts a couple key / value linked to default locale set by the extension itself.- Parameters:
key- the key.value- the value.- Returns:
- itself.
-
put
Puts a couple key / value linked to specified locale.- Parameters:
locale- the locale.key- the key.value- the value.- Returns:
- itself.
-
beforeEach
- Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Throws:
Exception
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback
-
clear
protected void clear()
-