Commit 2c2b9be4 authored by Andy Wilkinson's avatar Andy Wilkinson

Fix Jackson custom locale with Joda Time test on Java 9

The translations for the timezone names vary between Java 8 and Java
9. For example, with Java 9, UTC's name is no longer localized while
others have different localizations. This commit updates the test
to verify that the correct locale is being used while also tolerating
the different localization's of Java 8 and 9.

See gh-7226
parent f396740a
...@@ -412,17 +412,19 @@ public class JacksonAutoConfigurationTests { ...@@ -412,17 +412,19 @@ public class JacksonAutoConfigurationTests {
} }
@Test @Test
public void customLocale() throws JsonProcessingException { public void customLocaleWithJodaTime() throws JsonProcessingException {
this.context.register(JacksonAutoConfiguration.class); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertyValues.of("spring.jackson.locale:de").applyTo(this.context); context.register(JacksonAutoConfiguration.class);
TestPropertyValues.of("spring.jackson.date-format:zzzz").applyTo(this.context); TestPropertyValues
this.context.refresh(); .of("spring.jackson.locale:de_DE", "spring.jackson.date-format:zzzz",
ObjectMapper objectMapper = this.context "spring.jackson.serialization.write-dates-with-zone-id:true")
.getBean(Jackson2ObjectMapperBuilder.class).build(); .applyTo(context);
context.refresh();
DateTime dateTime = new DateTime(1436966242231L, DateTimeZone.UTC); ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
assertThat(objectMapper.writeValueAsString(dateTime)) DateTime jodaTime = new DateTime(1478424650000L,
.isEqualTo("\"Koordinierte Universalzeit\""); DateTimeZone.forID("Europe/Rome"));
assertThat(objectMapper.writeValueAsString(jodaTime))
.startsWith("\"Mitteleuropäische ");
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment