From 7c6663977c6586408ed63bfdd00f388205873e8a Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Tue, 31 Mar 2020 15:01:26 +0200 Subject: [PATCH] Fix Json integration test and 2.8 highlights docs (cherry picked from commit 120e103ed3ea2c460ae6ba1dea1817ccecc8b3f7) --- .../src/it/scala/play/it/libs/json/JavaJsonSpec.scala | 11 +++++++++-- .../manual/releases/release28/Highlights28.md | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/play-integration-test/src/it/scala/play/it/libs/json/JavaJsonSpec.scala b/core/play-integration-test/src/it/scala/play/it/libs/json/JavaJsonSpec.scala index 526104ee28a..3cb5e9f684a 100644 --- a/core/play-integration-test/src/it/scala/play/it/libs/json/JavaJsonSpec.scala +++ b/core/play-integration-test/src/it/scala/play/it/libs/json/JavaJsonSpec.scala @@ -26,14 +26,14 @@ class PlayBindingNameJavaJsonSpec extends JavaJsonSpec { override val createObjectMapper: ObjectMapper = GuiceApplicationBuilder() // should be able to use `.play.` namespace to override configurations // for this `ObjectMapper`. - .configure("akka.serialization.jackson.play.serialization-features.WRITE_DURATIONS_AS_TIMESTAMPS" -> false) + .configure("akka.serialization.jackson.play.serialization-features.WRITE_DURATIONS_AS_TIMESTAMPS" -> true) .build() .injector .instanceOf[ObjectMapper] "ObjectMapper" should { "respect the custom configuration" in new JsonScope { - Json.mapper().isEnabled(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) must beFalse + Json.mapper().isEnabled(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) must beTrue } } } @@ -41,6 +41,13 @@ class PlayBindingNameJavaJsonSpec extends JavaJsonSpec { // The dependency injected `ObjectMapper` class ApplicationJavaJsonSpec extends JavaJsonSpec { override val createObjectMapper: ObjectMapper = GuiceApplicationBuilder().build().injector.instanceOf[ObjectMapper] + + "ObjectMapper" should { + "not render date types as timestamps by default" in new JsonScope { + Json.mapper().isEnabled(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) must beFalse + Json.mapper().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) must beFalse + } + } } // Classic static `ObjectMapper` from play.libs.Json diff --git a/documentation/manual/releases/release28/Highlights28.md b/documentation/manual/releases/release28/Highlights28.md index a4e4f3fc1a9..3106d5482d6 100644 --- a/documentation/manual/releases/release28/Highlights28.md +++ b/documentation/manual/releases/release28/Highlights28.md @@ -22,13 +22,13 @@ Jackson dependency was updated to the [latest minor release, 2.10](https://githu Moreover, instead of providing its way to create and configure an `ObjectMapper`, which before Play 2.8 requires the user to write a custom binding, Play now uses Akka Jackson support to provide an `ObjectMapper`. So, it is now possible to add Jackson [Modules](https://doc.akka.io/docs/akka/2.6/serialization-jackson.html?language=scala#jackson-modules) and configure [Features](https://doc.akka.io/docs/akka/2.6/serialization-jackson.html?language=scala#additional-features) using `application.conf`. For example, if you want to add [Joda support](https://github.com/FasterXML/jackson-datatype-joda), you only need to add the following configuration: ```HOCON -akka.serialization.jackson.jackson-modules += "com.fasterxml.jackson.datatype.joda.JodaModule" +akka.serialization.jackson.play.jackson-modules += "com.fasterxml.jackson.datatype.joda.JodaModule" ``` And if you need to write numbers as strings, add the following configuration: ```HOCON -akka.serialization.jackson.serialization-features.WRITE_NUMBERS_AS_STRINGS=true +akka.serialization.jackson.play.serialization-features.WRITE_NUMBERS_AS_STRINGS=true ``` ### Guice support for Akka Actor Typed