Polishing

(cherry picked from commit ace25d4)
This commit is contained in:
Juergen Hoeller 2016-09-16 11:18:50 +02:00
parent cf2112f539
commit b60af42e23
1 changed files with 13 additions and 14 deletions

View File

@ -618,51 +618,50 @@ public class StringUtilsTests {
assertNull("When given an empty Locale string, must return null.", locale); assertNull("When given an empty Locale string, must return null.", locale);
} }
// SPR-8637 @Test // SPR-8637
@Test
public void testParseLocaleWithMultiSpecialCharactersInVariant() throws Exception { public void testParseLocaleWithMultiSpecialCharactersInVariant() throws Exception {
final String variant = "proper-northern"; String variant = "proper-northern";
final String localeString = "en_GB_" + variant; String localeString = "en_GB_" + variant;
Locale locale = StringUtils.parseLocaleString(localeString); Locale locale = StringUtils.parseLocaleString(localeString);
assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant());
} }
@Test // SPR-3671 @Test // SPR-3671
public void testParseLocaleWithMultiValuedVariant() throws Exception { public void testParseLocaleWithMultiValuedVariant() throws Exception {
final String variant = "proper_northern"; String variant = "proper_northern";
final String localeString = "en_GB_" + variant; String localeString = "en_GB_" + variant;
Locale locale = StringUtils.parseLocaleString(localeString); Locale locale = StringUtils.parseLocaleString(localeString);
assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant());
} }
@Test // SPR-3671 @Test // SPR-3671
public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparators() throws Exception { public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparators() throws Exception {
final String variant = "proper northern"; String variant = "proper northern";
final String localeString = "en GB " + variant; String localeString = "en GB " + variant;
Locale locale = StringUtils.parseLocaleString(localeString); Locale locale = StringUtils.parseLocaleString(localeString);
assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant());
} }
@Test // SPR-3671 @Test // SPR-3671
public void testParseLocaleWithMultiValuedVariantUsingMixtureOfUnderscoresAndSpacesAsSeparators() throws Exception { public void testParseLocaleWithMultiValuedVariantUsingMixtureOfUnderscoresAndSpacesAsSeparators() throws Exception {
final String variant = "proper northern"; String variant = "proper northern";
final String localeString = "en_GB_" + variant; String localeString = "en_GB_" + variant;
Locale locale = StringUtils.parseLocaleString(localeString); Locale locale = StringUtils.parseLocaleString(localeString);
assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant());
} }
@Test // SPR-3671 @Test // SPR-3671
public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparatorsWithLotsOfLeadingWhitespace() throws Exception { public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparatorsWithLotsOfLeadingWhitespace() throws Exception {
final String variant = "proper northern"; String variant = "proper northern";
final String localeString = "en GB " + variant; // lots of whitespace String localeString = "en GB " + variant; // lots of whitespace
Locale locale = StringUtils.parseLocaleString(localeString); Locale locale = StringUtils.parseLocaleString(localeString);
assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant());
} }
@Test // SPR-3671 @Test // SPR-3671
public void testParseLocaleWithMultiValuedVariantUsingUnderscoresAsSeparatorsWithLotsOfLeadingWhitespace() throws Exception { public void testParseLocaleWithMultiValuedVariantUsingUnderscoresAsSeparatorsWithLotsOfLeadingWhitespace() throws Exception {
final String variant = "proper_northern"; String variant = "proper_northern";
final String localeString = "en_GB_____" + variant; // lots of underscores String localeString = "en_GB_____" + variant; // lots of underscores
Locale locale = StringUtils.parseLocaleString(localeString); Locale locale = StringUtils.parseLocaleString(localeString);
assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant());
} }