From 3244836003520a562b9fd1e53a1f478a59bd0ca6 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 26 Feb 2018 22:26:33 -0800 Subject: [PATCH] Port Locale sensitive test from 1.5.x --- ...EnumIgnoringCaseConverterFactoryTests.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/StringToEnumIgnoringCaseConverterFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/StringToEnumIgnoringCaseConverterFactoryTests.java index e006030a76..65c53d4ae6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/StringToEnumIgnoringCaseConverterFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/StringToEnumIgnoringCaseConverterFactoryTests.java @@ -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 conversionServices() { return new ConversionServiceParameters( @@ -90,6 +107,12 @@ public class StringToEnumIgnoringCaseConverterFactoryTests { } + enum LocaleSensitiveEnum { + + ACCEPT_CASE_INSENSITIVE_PROPERTIES + + } + enum TestSubclassEnum { ONE {