@Target(value={METHOD,TYPE})
@Retention(value=RUNTIME)
@ExtendWith(value=org.junitpioneer.jupiter.DefaultLocaleExtension.class)
public @interface DefaultLocale
@DefaultLocale
is a JUnit Jupiter extension to change the value
returned by Locale.getDefault()
for a test execution.
The Locale
to set as the default locale can be
configured in several ways:
language tag
language
language and a county
language, a county, and a variant
If a language tag is set, none of the other fields must be set. Otherwise an
ExtensionConfigurationException
will
be thrown. Specifying a country()
but no language()
, or a
variant()
but no country()
and language()
will
also cause an ExtensionConfigurationException
. After the annotated
element has been executed, the default Locale
will be restored to
its original value.
@DefaultLocale
can be used on the method and on the class level.
If a class is annotated, the configured Locale
will be the default
Locale
for all tests inside that class. Any method level
configurations will override the class level default Locale
.
Locale.getDefault()
,
DefaultTimeZone
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
country
An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
|
java.lang.String |
language
An ISO 639 alpha-2 or alpha-3 language code, or a language subtag up to
8 characters in length.
|
java.lang.String |
value
An language tag string as specified by IETF BCP 47.
|
java.lang.String |
variant
Any arbitrary value used to indicate a variation of a
Locale . |
public abstract java.lang.String value
Locale.forLanguageTag(String)
for more information
about valid language tag values.public abstract java.lang.String language
Locale
class
description about valid language values.