-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Locale
conversion format configuration property
#4492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Locale
conversion format configuration property
#4492
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
public static final DefaultArgumentConverter INSTANCE = new DefaultArgumentConverter(); | ||
private static final String DEFAULT_LOCALE_CONVERSION_FORMAT_PROPERTY_NAME = "junit.jupiter.params.arguments.conversion.locale.format"; | ||
|
||
private DefaultArgumentConverter() { | ||
// nothing to initialize | ||
private static final Function<String, LocaleConversionFormat> CONFIGURATION_TRANSFORMER = value -> LocaleConversionFormat.valueOf( | ||
value.trim().toUpperCase(Locale.ROOT)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To reduce the change's footprint, I included the property and the converter here instead of in JupiterConfiguration
(which isn't accessible right now in DefaultArgumentConverter
).
Let me know if you see any limitations with this approach!
This comment was marked as outdated.
This comment was marked as outdated.
if (targetType == Locale.class && getLocaleConversionFormat() == LocaleConversionFormat.BCP_47) { | ||
return Locale.forLanguageTag((String) source); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm delaying the format retrieval via getLocaleConversionFormat()
because I'm unsure if it would be safe to grab that value in the constructor and keep it internally.
If you think it could be fetched earlier, I'm happy to refactor it.
Overview
Locale
argument conversion not settinglanguage
andcountry
properly #3141I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations