Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Allow disabling Jackson ObjectMapper WRITE_DURATIONS_AS_TIMESTAMPS
- Loading branch information
Showing
6 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...est/java/io/quarkus/jackson/deployment/JacksonWriteDurationsAsTimestampsDisabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.quarkus.jackson.deployment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.Duration; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class JacksonWriteDurationsAsTimestampsDisabledTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("application-write-durations-as-timestamps-disabled.properties"); | ||
|
||
@Inject | ||
ObjectMapper objectMapper; | ||
|
||
@Test | ||
public void testDurationWrittenAsIso8601() throws JsonProcessingException { | ||
Pojo pojo = new Pojo(); | ||
pojo.duration = Duration.ofMillis(65542516); | ||
|
||
assertThat(objectMapper.writeValueAsString(pojo)).isEqualTo("{\"duration\":\"PT18H12M22.516S\"}"); | ||
} | ||
|
||
public static class Pojo { | ||
|
||
public Duration duration; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...test/java/io/quarkus/jackson/deployment/JacksonWriteDurationsAsTimestampsEnabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.quarkus.jackson.deployment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.Duration; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class JacksonWriteDurationsAsTimestampsEnabledTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("application-write-durations-as-timestamps-enabled.properties"); | ||
|
||
@Inject | ||
ObjectMapper objectMapper; | ||
|
||
@Test | ||
public void testDurationWrittenAsTimestamp() throws JsonProcessingException { | ||
Pojo pojo = new Pojo(); | ||
pojo.duration = Duration.ofMillis(65542516); | ||
|
||
assertThat(objectMapper.writeValueAsString(pojo)).isEqualTo("{\"duration\":65542.516000000}"); | ||
} | ||
|
||
public static class Pojo { | ||
|
||
public Duration duration; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ployment/src/test/resources/application-write-durations-as-timestamps-disabled.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quarkus.jackson.write-durations-as-timestamps=false |
1 change: 1 addition & 0 deletions
1
...eployment/src/test/resources/application-write-durations-as-timestamps-enabled.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quarkus.jackson.write-durations-as-timestamps=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters