Port Locale sensitive test from 1.5.x
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.convert;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
@@ -78,6 +80,21 @@ public class StringToEnumIgnoringCaseConverterFactoryTests {
|
||||
.isEqualTo(TestEnum.THREE_AND_FOUR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertFromStringToEnumWhenUsingNonEnglishLocaleShouldConvertValue() {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
try {
|
||||
Locale.setDefault(new Locale("tr"));
|
||||
LocaleSensitiveEnum result = this.conversionService.convert(
|
||||
"accept-case-insensitive-properties", LocaleSensitiveEnum.class);
|
||||
assertThat(result
|
||||
.equals(LocaleSensitiveEnum.ACCEPT_CASE_INSENSITIVE_PROPERTIES));
|
||||
}
|
||||
finally {
|
||||
Locale.setDefault(defaultLocale);
|
||||
}
|
||||
}
|
||||
|
||||
@Parameters(name = "{0}")
|
||||
public static Iterable<Object[]> conversionServices() {
|
||||
return new ConversionServiceParameters(
|
||||
@@ -90,6 +107,12 @@ public class StringToEnumIgnoringCaseConverterFactoryTests {
|
||||
|
||||
}
|
||||
|
||||
enum LocaleSensitiveEnum {
|
||||
|
||||
ACCEPT_CASE_INSENSITIVE_PROPERTIES
|
||||
|
||||
}
|
||||
|
||||
enum TestSubclassEnum {
|
||||
|
||||
ONE {
|
||||
|
||||
Reference in New Issue
Block a user