-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Json integration test and 2.8 highlights docs #10155
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,21 +26,28 @@ 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 | ||
} | ||
} | ||
} | ||
|
||
// 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 | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just confirms that |
||
} | ||
|
||
// Classic static `ObjectMapper` from play.libs.Json | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the
as well. Just to keep things consistent. More info here: https://doc.akka.io/docs/akka/2.6/serialization-jackson.html?language=scala#additional-configuration playframework/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala Lines 30 to 33 in 76ad96d
|
||||||||||
``` | ||||||||||
|
||||||||||
### Guice support for Akka Actor Typed | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/playframework/playframework/pull/9494/files#r400895796
This test is just not working. Not only we need to change to
WRITE_DURATIONS_AS_TIMESTAMPS
in the test, but also configure it totrue
, becausefalse
is the default anyway, so the test would still be useless.