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
This commit is contained in:
@@ -412,17 +412,19 @@ public class JacksonAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customLocale() throws JsonProcessingException {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of("spring.jackson.locale:de").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.date-format:zzzz").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
|
||||
DateTime dateTime = new DateTime(1436966242231L, DateTimeZone.UTC);
|
||||
assertThat(objectMapper.writeValueAsString(dateTime))
|
||||
.isEqualTo("\"Koordinierte Universalzeit\"");
|
||||
public void customLocaleWithJodaTime() throws JsonProcessingException {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues
|
||||
.of("spring.jackson.locale:de_DE", "spring.jackson.date-format:zzzz",
|
||||
"spring.jackson.serialization.write-dates-with-zone-id:true")
|
||||
.applyTo(context);
|
||||
context.refresh();
|
||||
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
|
||||
DateTime jodaTime = new DateTime(1478424650000L,
|
||||
DateTimeZone.forID("Europe/Rome"));
|
||||
assertThat(objectMapper.writeValueAsString(jodaTime))
|
||||
.startsWith("\"Mitteleuropäische ");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user