From d62d8c69884b2aa5fdeb68076697014bab7507de Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 26 Sep 2024 20:56:11 -0700 Subject: [PATCH 001/140] Start 2.19 branch --- .github/workflows/main.yml | 4 ++-- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- release-notes/VERSION-2.x | 4 ++++ 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8deb3e08..22e47cce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: branches: - master - "3.0" - - "2.18" + - "2.19" paths-ignore: - "README.md" - "release-notes/*" @@ -12,7 +12,7 @@ on: branches: - master - "3.0" - - "2.18" + - "2.19" paths-ignore: - "README.md" - "release-notes/*" diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 55d36f67..41bdbdb7 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.18.1-SNAPSHOT + 2.19.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index a87c9e3c..08c1939f 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.18.1-SNAPSHOT + 2.19.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 9270d1af..43bf73bc 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.18.1-SNAPSHOT + 2.19.0-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index ce66a921..914a1abc 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.18.1-SNAPSHOT + 2.19.0-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.18.1-SNAPSHOT + 2.19.0-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 0b590a63..81c98a34 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,10 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.19.0 (not yet released) + +- + 2.18.0 (26-Sep-2024) No changes since 2.17 From 40bbc04d9890f7dd87da3771b0522142922cd0d4 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 2 Dec 2024 20:00:57 -0800 Subject: [PATCH 002/140] Update CI, maven wrapper --- .github/workflows/main.yml | 20 +++++++++++--------- .mvn/wrapper/maven-wrapper.properties | 20 ++++++++++++++++++-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22e47cce..3201205f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,18 +22,20 @@ permissions: jobs: build: - runs-on: ${{ matrix.os }} + runs-on: 'ubuntu-20.04' strategy: fail-fast: false matrix: java_version: ['8', '11', '17', '21'] - os: ['ubuntu-20.04'] + include: + - java_version: '8' + - release_build: 'R' env: JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 with: distribution: 'temurin' java-version: ${{ matrix.java_version }} @@ -48,20 +50,20 @@ jobs: run: ./mvnw -B -q -ff -ntp verify - name: Extract project Maven version id: projectVersion - run: echo "version=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate -DforceStdout -Dexpression=project.version -q)" >> $GITHUB_OUTPUT + run: echo "version=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate -DforceStdout -Dexpression=project.version -q)" >> $GITHUB_OUTPUT - name: Deploy snapshot - if: github.event_name != 'pull_request' && matrix.java_version == '8' && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') + if: github.event_name != 'pull_request' && matrix.release_build && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} # MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} run: ./mvnw -B -q -ff -DskipTests -ntp source:jar deploy - name: Generate code coverage - if: github.event_name != 'pull_request' && matrix.java_version == '8' + if: github.event_name != 'pull_request' && matrix.release_build run: ./mvnw -B -q -ff -ntp test - name: Publish code coverage - if: github.event_name != 'pull_request' && matrix.java_version == '8' - uses: codecov/codecov-action@v1 + if: github.event_name != 'pull_request' && matrix.release_build + uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./target/site/jacoco/jacoco.xml diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 642d572c..8f2e6451 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,18 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar From 3ef90c925d4e9dbd5c32279a26e5f4d01ece32da Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 2 Dec 2024 20:02:01 -0800 Subject: [PATCH 003/140] Fix CI wrt tab --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3201205f..f4a383fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: java_version: ['8', '11', '17', '21'] - include: + include: - java_version: '8' - release_build: 'R' env: From ac177c307e8afdbf72faa9d313e4e7be959bf1ef Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 2 Dec 2024 20:05:44 -0800 Subject: [PATCH 004/140] Fix CI wrt "if" statements --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4a383fe..d78df442 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,17 +52,17 @@ jobs: id: projectVersion run: echo "version=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate -DforceStdout -Dexpression=project.version -q)" >> $GITHUB_OUTPUT - name: Deploy snapshot - if: github.event_name != 'pull_request' && matrix.release_build && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') + if: ${{ github.event_name != 'pull_request' && matrix.release_build && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') }} env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} # MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} run: ./mvnw -B -q -ff -DskipTests -ntp source:jar deploy - name: Generate code coverage - if: github.event_name != 'pull_request' && matrix.release_build + if: ${{ github.event_name != 'pull_request' && matrix.release_build }} run: ./mvnw -B -q -ff -ntp test - name: Publish code coverage - if: github.event_name != 'pull_request' && matrix.release_build + if: ${{ github.event_name != 'pull_request' && matrix.release_build }} uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 with: token: ${{ secrets.CODECOV_TOKEN }} From c8951d08eef42ae73d270fa6971c01de7c7c769f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 2 Dec 2024 20:30:02 -0800 Subject: [PATCH 005/140] Fix CI --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d78df442..8fc4744b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,17 +52,17 @@ jobs: id: projectVersion run: echo "version=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate -DforceStdout -Dexpression=project.version -q)" >> $GITHUB_OUTPUT - name: Deploy snapshot - if: ${{ github.event_name != 'pull_request' && matrix.release_build && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') }} + if: ${{ matrix.release_build && github.event_name != 'pull_request' && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') }} env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} # MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} run: ./mvnw -B -q -ff -DskipTests -ntp source:jar deploy - name: Generate code coverage - if: ${{ github.event_name != 'pull_request' && matrix.release_build }} + if: ${{ matrix.release_build && github.event_name != 'pull_request' }} run: ./mvnw -B -q -ff -ntp test - name: Publish code coverage - if: ${{ github.event_name != 'pull_request' && matrix.release_build }} + if: ${{ matrix.release_build && github.event_name != 'pull_request' }} uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 with: token: ${{ secrets.CODECOV_TOKEN }} From 683a43aa72271a07658d677034a9f66b7581eff0 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 2 Dec 2024 20:35:22 -0800 Subject: [PATCH 006/140] Final (?) fix for CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8fc4744b..a1c56135 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: java_version: ['8', '11', '17', '21'] include: - java_version: '8' - - release_build: 'R' + release_build: 'R' env: JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" steps: From 502826332441a80582a14bd31d78c07f5d813893 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 3 Dec 2024 20:19:14 -0800 Subject: [PATCH 007/140] Remove pre-JDK17 targets from v3 rebuild --- .github/workflows/dep_build_v3.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dep_build_v3.yml b/.github/workflows/dep_build_v3.yml index cf461a51..6da2dd55 100644 --- a/.github/workflows/dep_build_v3.yml +++ b/.github/workflows/dep_build_v3.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - java_version: ['8', '17', '21'] + java_version: ['17', '21'] env: JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" steps: From 18dca62a3bc087d78e38fc71d1883b37ca140e13 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 5 Dec 2024 20:45:33 -0800 Subject: [PATCH 008/140] ... --- release-notes/VERSION-2.x | 1 - 1 file changed, 1 deletion(-) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 72030cc1..94acc6e7 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -18,7 +18,6 @@ Modules: while `WRITE_DATES_WITH_ZONE_ID` enabled (reported by @verve111) (fix by Joo-Hyuk K) ->>>>>>> 2.18 2.18.2 (27-Nov-2024) From 29aa2b8f2cb0092f41f099d6d9d3889827aefc6b Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Mon, 16 Dec 2024 21:01:48 -0500 Subject: [PATCH 009/140] Optimize InstantDeserializer addInColonToOffsetIfMissing (#336) --- .../jsr310/deser/InstantDeserializer.java | 40 ++++++++++++++++--- .../jsr310/deser/OffsetDateTimeDeserTest.java | 35 ++++++++++++++++ .../jsr310/deser/ZonedDateTimeDeserTest.java | 35 ++++++++++++++++ 3 files changed, 104 insertions(+), 6 deletions(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java index 2aca24c6..75a870c4 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java @@ -519,14 +519,42 @@ private static String replaceZeroOffsetAsZ(String text) } // @since 2.13 - private String addInColonToOffsetIfMissing(String text) + private static String addInColonToOffsetIfMissing(String text) { - final Matcher matcher = ISO8601_COLONLESS_OFFSET_REGEX.matcher(text); - if (matcher.find()){ - StringBuilder sb = new StringBuilder(matcher.group(0)); - sb.insert(3, ":"); + int timeIndex = text.indexOf('T'); + if (timeIndex < 0 || timeIndex > text.length() - 1) { + return text; + } + + int offsetIndex = text.indexOf('+', timeIndex + 1); + if (offsetIndex < 0) { + offsetIndex = text.indexOf('-', timeIndex + 1); + } + + if (offsetIndex < 0 || offsetIndex > text.length() - 5) { + return text; + } + + int colonIndex = text.indexOf(':', offsetIndex); + if (colonIndex == offsetIndex + 3) { + return text; + } - return matcher.replaceFirst(sb.toString()); + if (Character.isDigit(text.charAt(offsetIndex + 1)) + && Character.isDigit(text.charAt(offsetIndex + 2)) + && Character.isDigit(text.charAt(offsetIndex + 3)) + && Character.isDigit(text.charAt(offsetIndex + 4))) { + String match = text.substring(offsetIndex, offsetIndex + 5); + return text.substring(0, offsetIndex) + + match.substring(0, 3) + ':' + match.substring(3) + + text.substring(offsetIndex + match.length()); + } + + // fallback to slow regex path, should be fully handled by the above + final Matcher matcher = ISO8601_COLONLESS_OFFSET_REGEX.matcher(text); + if (matcher.find()) { + String match = matcher.group(0); + return matcher.replaceFirst(match.substring(0, 3) + ':' + match.substring(3)); } return text; } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java index e676230d..83e46d0e 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java @@ -5,6 +5,7 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; +import java.util.Arrays; import java.util.Map; import java.util.TimeZone; @@ -811,6 +812,40 @@ public void testOffsetDateTimeMinOrMax() throws Exception _testOffsetDateTimeMinOrMax(OffsetDateTime.MAX); } + @Test + public void OffsetDateTime_with_offset_can_be_deserialized() throws Exception { + ObjectReader r = MAPPER.readerFor(OffsetDateTime.class) + .without(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + + String base = "2015-07-24T12:23:34.184"; + for (String offset : Arrays.asList("+00", "-00")) { + String time = base + offset; + if (!System.getProperty("java.version").startsWith("1.8")) { + // JDK 8 cannot parse hour offsets without minutes + assertIsEqual(OffsetDateTime.parse("2015-07-24T12:23:34.184Z"), r.readValue('"' + time + '"')); + } + assertIsEqual(OffsetDateTime.parse("2015-07-24T12:23:34.184Z"), r.readValue('"' + time + "00" + '"')); + assertIsEqual(OffsetDateTime.parse("2015-07-24T12:23:34.184Z"), r.readValue('"' + time + ":00" + '"')); + assertIsEqual(OffsetDateTime.parse("2015-07-24T12:23:34.184" + offset + ":30"), r.readValue('"' + time + "30" + '"')); + assertIsEqual(OffsetDateTime.parse("2015-07-24T12:23:34.184" + offset + ":30"), r.readValue('"' + time + ":30" + '"')); + } + + for (String prefix : Arrays.asList("-", "+")) { + for (String hours : Arrays.asList("00", "01", "02", "03", "11", "12")) { + String time = base + prefix + hours; + OffsetDateTime expectedHour = OffsetDateTime.parse(time + ":00"); + if (!System.getProperty("java.version").startsWith("1.8")) { + // JDK 8 cannot parse hour offsets without minutes + assertIsEqual(expectedHour, r.readValue('"' + time + '"')); + } + assertIsEqual(expectedHour, r.readValue('"' + time + "00" + '"')); + assertIsEqual(expectedHour, r.readValue('"' + time + ":00" + '"')); + assertIsEqual(OffsetDateTime.parse(time + ":30"), r.readValue('"' + time + "30" + '"')); + assertIsEqual(OffsetDateTime.parse(time + ":30"), r.readValue('"' + time + ":30" + '"')); + } + } + } + private void _testOffsetDateTimeMinOrMax(OffsetDateTime offsetDateTime) throws Exception { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java index 72dc2206..4f6388cd 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java @@ -18,11 +18,13 @@ import java.io.IOException; import java.time.LocalDateTime; +import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.util.Arrays; import java.util.Map; import java.util.TimeZone; @@ -282,6 +284,39 @@ public void testDeserializationWithoutColonInTimeZoneWithTZDB() throws Throwable wrapper.value); } + @Test + public void ZonedDateTime_with_offset_can_be_deserialized() throws Exception { + ObjectReader r = newMapper().readerFor(ZonedDateTime.class) + .without(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + + String base = "2015-07-24T12:23:34.184"; + for (String offset : Arrays.asList("+00", "-00")) { + String time = base + offset; + if (!System.getProperty("java.version").startsWith("1.8")) { + // JDK 8 cannot parse hour offsets without minutes + assertEquals(ZonedDateTime.parse("2015-07-24T12:23:34.184Z"), r.readValue('"' + time + '"')); + } + assertEquals(ZonedDateTime.parse("2015-07-24T12:23:34.184Z"), r.readValue('"' + time + "00" + '"')); + assertEquals(ZonedDateTime.parse("2015-07-24T12:23:34.184Z"), r.readValue('"' + time + ":00" + '"')); + assertEquals(ZonedDateTime.parse("2015-07-24T12:23:34.184" + offset + ":30" ), r.readValue('"' + time + "30" + '"')); + assertEquals(ZonedDateTime.parse("2015-07-24T12:23:34.184" + offset + ":30" ), r.readValue('"' + time + ":30" + '"')); + } + + for (String prefix : Arrays.asList("-", "+")) { + for (String hours : Arrays.asList("00", "01", "02", "03", "11", "12")) { + String time = base + prefix + hours; + ZonedDateTime expectedHour = ZonedDateTime.parse(time + ":00"); + if (!System.getProperty("java.version").startsWith("1.8")) { + // JDK 8 cannot parse hour offsets without minutes + assertEquals(expectedHour, r.readValue('"' + time + '"')); + } + assertEquals(expectedHour, r.readValue('"' + time + "00" + '"')); + assertEquals(expectedHour, r.readValue('"' + time + ":00" + '"')); + assertEquals(ZonedDateTime.parse(time + ":30"), r.readValue('"' + time + "30" + '"')); + assertEquals(ZonedDateTime.parse(time + ":30"), r.readValue('"' + time + ":30" + '"')); + } + } + } private void expectFailure(String json) throws Throwable { try { From cb5e00d5ebf43e844c83cbbc9a8bdbd44c922c04 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 16 Dec 2024 18:04:53 -0800 Subject: [PATCH 010/140] Update release notes wrt #336 --- release-notes/CREDITS-2.x | 2 ++ release-notes/VERSION-2.x | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index cb733c9e..91dd124d 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -170,6 +170,8 @@ MichaƂ Ostrowski (karbi@github) David Schlosnagle (schlosna@github) * Contributed #266: Optimize `InstantDeserializer` method `replaceZeroOffsetAsZIfNecessary()` (2.15.0) + * Contributed #336: Optimize `InstantDeserializer` `addInColonToOffsetIfMissing()` + (2.19.0) Daniel Scalzi (dscalzi@github) * Contributed #267: Normalize zone id during ZonedDateTime deserialization diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 94acc6e7..4588f980 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -10,7 +10,8 @@ Modules: 2.19.0 (not yet released) -- +#336: Optimize `InstantDeserializer` `addInColonToOffsetIfMissing()` + (contributed by David S) 2.18.3 (not yet released) From 05875ebe643aca93d1264df5e4393ca2f0ce9d97 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Mon, 27 Jan 2025 04:39:47 +0900 Subject: [PATCH 011/140] [JSTEP-10] Migrate modules `datatype` and `parameter-names` to `JUnit 5` (#344) --- .../jdk8/ContextualOptional17Test.java | 5 ++ .../jackson/datatype/jdk8/CreatorTest.java | 6 ++ .../jdk8/DoubleStreamSerializerTest.java | 10 +-- .../jdk8/IntStreamSerializerTest.java | 4 +- .../datatype/jdk8/JDKSerializabilityTest.java | 4 +- .../jdk8/Java8OptionalUnwrappedTest.java | 7 ++ .../jdk8/LongStreamSerializerTest.java | 6 +- .../jackson/datatype/jdk8/ModuleTestBase.java | 4 +- .../datatype/jdk8/OptionalBasicTest.java | 26 +++++- .../datatype/jdk8/OptionalBooleanTest.java | 5 ++ .../datatype/jdk8/OptionalConverterTest.java | 6 ++ .../datatype/jdk8/OptionalMergeTest.java | 5 ++ .../datatype/jdk8/OptionalNumbersTest.java | 29 +++++- .../jackson/datatype/jdk8/OptionalTest.java | 17 ++++ .../datatype/jdk8/OptionalWithEmptyTest.java | 6 ++ .../datatype/jdk8/OptionalnclusionTest.java | 13 +++ .../jdk8/PolymorphicOptionalTest.java | 5 ++ .../datatype/jdk8/SchemaVisitorTest.java | 7 ++ .../datatype/jdk8/StreamSerializerTest.java | 6 +- .../jackson/datatype/jdk8/StreamTestBase.java | 89 ++++++------------- .../jdk8/TestConfigureAbsentsAsNulls.java | 11 +++ .../jdk8/TestOptionalWithPolymorphic.java | 8 ++ datetime/pom.xml | 7 ++ .../ConstructorDetectorConfigTest.java | 6 +- .../CreatorWithNamingStrategy74Test.java | 4 +- .../paramnames/DelegatingCreatorTest.java | 4 +- .../module/paramnames/EnumNamingTest.java | 6 +- .../paramnames/JDKSerializabilityTest.java | 4 +- .../module/paramnames/JsonCreatorTest.java | 9 +- .../module/paramnames/MapKeyNames206Test.java | 4 +- .../paramnames/NamingStrategy67Test.java | 2 +- ...ameterNamesAnnotationIntrospectorTest.java | 17 ++-- .../jackson/module/paramnames/PersonTest.java | 2 +- pom.xml | 11 ++- 34 files changed, 241 insertions(+), 114 deletions(-) diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ContextualOptional17Test.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ContextualOptional17Test.java index 37f9e448..64239a2e 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ContextualOptional17Test.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ContextualOptional17Test.java @@ -5,10 +5,14 @@ import java.util.Optional; import java.util.TimeZone; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ContextualOptional17Test extends ModuleTestBase { // [datatypes-java8#17] @@ -30,6 +34,7 @@ static class ContextualOptionals /********************************************************** */ + @Test public void testContextualOptionals() throws Exception { final ObjectMapper mapper = mapperWithModule(); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/CreatorTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/CreatorTest.java index 66f41e80..dd33b8cf 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/CreatorTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/CreatorTest.java @@ -2,11 +2,15 @@ import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; +import static org.junit.jupiter.api.Assertions.*; + public class CreatorTest extends ModuleTestBase { static class CreatorWithOptionalStrings @@ -35,6 +39,7 @@ public CreatorWithOptionalStrings(@JsonProperty("a") Optional a, * Test to ensure that creator parameters use defaulting * (introduced in Jackson 2.6) */ + @Test public void testCreatorWithOptionalDefault() throws Exception { CreatorWithOptionalStrings bean = MAPPER.readValue( @@ -47,6 +52,7 @@ public void testCreatorWithOptionalDefault() throws Exception assertEquals("foo", bean.a.get()); } + @Test public void testCreatorWithOptionalAbsentAsNull() throws Exception { Jdk8Module module = new Jdk8Module() diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/DoubleStreamSerializerTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/DoubleStreamSerializerTest.java index db29ce40..9b845777 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/DoubleStreamSerializerTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/DoubleStreamSerializerTest.java @@ -1,15 +1,15 @@ package com.fasterxml.jackson.datatype.jdk8; -import static org.junit.Assert.*; - import java.io.IOException; import java.util.stream.DoubleStream; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + @SuppressWarnings({ "unqualified-field-access", "javadoc" }) public class DoubleStreamSerializerTest extends StreamTestBase { @@ -21,7 +21,7 @@ public class DoubleStreamSerializerTest extends StreamTestBase { final String exceptionMessage = "DoubleStream peek threw"; - @Before + @BeforeEach public void setUp() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module()); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/IntStreamSerializerTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/IntStreamSerializerTest.java index bc06a70e..09360df5 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/IntStreamSerializerTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/IntStreamSerializerTest.java @@ -1,11 +1,11 @@ package com.fasterxml.jackson.datatype.jdk8; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.stream.IntStream; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; @SuppressWarnings({ "unqualified-field-access", "javadoc" }) public class IntStreamSerializerTest extends StreamTestBase { diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/JDKSerializabilityTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/JDKSerializabilityTest.java index 195bec9e..f48d86d6 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/JDKSerializabilityTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/JDKSerializabilityTest.java @@ -3,10 +3,12 @@ import java.io.*; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class JDKSerializabilityTest extends ModuleTestBase { static class BooleanBean { diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/Java8OptionalUnwrappedTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/Java8OptionalUnwrappedTest.java index 1c4639cb..35804af1 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/Java8OptionalUnwrappedTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/Java8OptionalUnwrappedTest.java @@ -3,6 +3,8 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.JavaType; @@ -11,6 +13,8 @@ import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor; import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider; +import static org.junit.jupiter.api.Assertions.*; + public class Java8OptionalUnwrappedTest extends ModuleTestBase { static class Child { @@ -46,6 +50,7 @@ static class Bean2 { public String name; } + @Test public void testUntypedWithOptionalsNotNulls() throws Exception { final ObjectMapper mapper = mapperWithModule(false); @@ -55,6 +60,7 @@ public void testUntypedWithOptionalsNotNulls() throws Exception } // for [datatype-jdk8#20] + @Test public void testShouldSerializeUnwrappedOptional() throws Exception { final ObjectMapper mapper = mapperWithModule(false); @@ -63,6 +69,7 @@ public void testShouldSerializeUnwrappedOptional() throws Exception { } // for [datatype-jdk8#26] + @Test public void testPropogatePrefixToSchema() throws Exception { final ObjectMapper mapper = mapperWithModule(false); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/LongStreamSerializerTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/LongStreamSerializerTest.java index 1d483a54..fc70b207 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/LongStreamSerializerTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/LongStreamSerializerTest.java @@ -1,11 +1,11 @@ package com.fasterxml.jackson.datatype.jdk8; -import static org.junit.Assert.*; - import java.io.IOException; import java.util.stream.LongStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; @SuppressWarnings({ "unqualified-field-access", "javadoc" }) public class LongStreamSerializerTest extends StreamTestBase { diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ModuleTestBase.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ModuleTestBase.java index f72498c6..c0240db6 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ModuleTestBase.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/ModuleTestBase.java @@ -8,7 +8,9 @@ import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; -public abstract class ModuleTestBase extends junit.framework.TestCase +import static org.junit.jupiter.api.Assertions.fail; + +public abstract class ModuleTestBase { public static class NoCheckSubTypeValidator extends PolymorphicTypeValidator.Base diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBasicTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBasicTest.java index 29eaae6e..ed883906 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBasicTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBasicTest.java @@ -2,6 +2,8 @@ import java.util.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; @@ -9,6 +11,8 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class OptionalBasicTest extends ModuleTestBase { public static final class OptionalData { @@ -59,6 +63,7 @@ public static class ContainedImpl implements Contained { } private final ObjectMapper MAPPER = mapperWithModule(); + @Test public void testOptionalTypeResolution() throws Exception { // With 2.6, we need to recognize it as ReferenceType JavaType t = MAPPER.constructType(Optional.class); @@ -67,6 +72,7 @@ public void testOptionalTypeResolution() throws Exception { assertTrue(t.isReferenceType()); } + @Test public void testDeserAbsent() throws Exception { Optional value = MAPPER.readValue("null", new TypeReference>() { @@ -74,6 +80,7 @@ public void testDeserAbsent() throws Exception { assertFalse(value.isPresent()); } + @Test public void testDeserSimpleString() throws Exception { Optional value = MAPPER.readValue("\"simpleString\"", new TypeReference>() { @@ -82,6 +89,7 @@ public void testDeserSimpleString() throws Exception { assertEquals("simpleString", value.get()); } + @Test public void testDeserInsideObject() throws Exception { OptionalData data = MAPPER.readValue("{\"myString\":\"simpleString\"}", OptionalData.class); @@ -89,6 +97,7 @@ public void testDeserInsideObject() throws Exception { assertEquals("simpleString", data.myString.get()); } + @Test public void testDeserComplexObject() throws Exception { TypeReference> type = new TypeReference>() { }; @@ -99,6 +108,7 @@ public void testDeserComplexObject() throws Exception { assertEquals("simpleString", data.get().myString.get()); } + @Test public void testDeserGeneric() throws Exception { TypeReference>> type = new TypeReference>>() { }; @@ -109,16 +119,19 @@ public void testDeserGeneric() throws Exception { assertEquals("simpleString", data.get().myData.get()); } + @Test public void testSerAbsent() throws Exception { String value = MAPPER.writeValueAsString(Optional.empty()); assertEquals("null", value); } + @Test public void testSerSimpleString() throws Exception { String value = MAPPER.writeValueAsString(Optional.of("simpleString")); assertEquals("\"simpleString\"", value); } + @Test public void testSerInsideObject() throws Exception { OptionalData data = new OptionalData(); data.myString = Optional.of("simpleString"); @@ -126,6 +139,7 @@ public void testSerInsideObject() throws Exception { assertEquals("{\"myString\":\"simpleString\"}", value); } + @Test public void testSerComplexObject() throws Exception { OptionalData data = new OptionalData(); data.myString = Optional.of("simpleString"); @@ -133,6 +147,7 @@ public void testSerComplexObject() throws Exception { assertEquals("{\"myString\":\"simpleString\"}", value); } + @Test public void testSerGeneric() throws Exception { OptionalGenericData data = new OptionalGenericData(); data.myData = Optional.of("simpleString"); @@ -140,6 +155,7 @@ public void testSerGeneric() throws Exception { assertEquals("{\"myData\":\"simpleString\"}", value); } + @Test public void testSerNonNull() throws Exception { OptionalData data = new OptionalData(); data.myString = Optional.empty(); @@ -149,6 +165,7 @@ public void testSerNonNull() throws Exception { assertEquals("{}", value); } + @Test public void testSerOptDefault() throws Exception { OptionalData data = new OptionalData(); data.myString = Optional.empty(); @@ -157,6 +174,7 @@ public void testSerOptDefault() throws Exception { assertEquals("{\"myString\":null}", value); } + @Test public void testSerOptNull() throws Exception { OptionalData data = new OptionalData(); data.myString = null; @@ -166,6 +184,7 @@ public void testSerOptNull() throws Exception { } @SuppressWarnings("deprecation") + @Test public void testSerOptDisableAsNull() throws Exception { final OptionalData data = new OptionalData(); data.myString = Optional.empty(); @@ -187,6 +206,7 @@ public void testSerOptDisableAsNull() throws Exception { assertEquals("{}", mapper.writeValueAsString(data)); } + @Test public void testSerOptNonEmpty() throws Exception { OptionalData data = new OptionalData(); data.myString = null; @@ -195,6 +215,7 @@ public void testSerOptNonEmpty() throws Exception { assertEquals("{}", value); } + @Test public void testWithTypingEnabled() throws Exception { final ObjectMapper objectMapper = mapperWithModule(); // ENABLE TYPING @@ -210,6 +231,7 @@ public void testWithTypingEnabled() throws Exception { assertEquals(myData.myString, deserializedMyData.myString); } + @Test public void testObjectId() throws Exception { final Unit input = new Unit(); input.link(input); @@ -222,6 +244,7 @@ public void testObjectId() throws Exception { assertSame(result, base); } + @Test public void testOptionalCollection() throws Exception { TypeReference>> typeReference = new TypeReference>>() { @@ -238,10 +261,11 @@ public void testOptionalCollection() throws Exception { List> result = MAPPER.readValue(str, typeReference); assertEquals(list.size(), result.size()); for (int i = 0; i < list.size(); ++i) { - assertEquals("Entry #" + i, list.get(i), result.get(i)); + assertEquals(list.get(i), result.get(i), "Entry #" + i); } } + @Test public void testPolymorphic() throws Exception { final Container dto = new Container(); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBooleanTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBooleanTest.java index 56ac1fb4..26475cb3 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBooleanTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalBooleanTest.java @@ -2,8 +2,12 @@ import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class OptionalBooleanTest extends ModuleTestBase { static class BooleanBean { @@ -18,6 +22,7 @@ public BooleanBean(Boolean b) { private final ObjectMapper MAPPER = mapperWithModule(); // for [datatype-jdk8#23] + @Test public void testBoolean() throws Exception { // First, serialization diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalConverterTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalConverterTest.java index f01e7e42..fb508da9 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalConverterTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalConverterTest.java @@ -2,11 +2,15 @@ import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.util.StdConverter; +import static org.junit.jupiter.api.Assertions.*; + // [modules-java#294]: Optional + converters public class OptionalConverterTest extends ModuleTestBase { @@ -56,6 +60,7 @@ public PointReferenceBean(int x, int y) { private final ObjectMapper MAPPER = mapperWithModule(); // [modules-java#294]: Optional + converters, deser + @Test public void testDeserializeOptionalConverting() throws Exception { PointReferenceBean w = MAPPER.readerFor(PointReferenceBean.class) .readValue("{\"opt\": [1,2]}"); @@ -68,6 +73,7 @@ public void testDeserializeOptionalConverting() throws Exception { } // [modules-java#294]: Optional + converters, ser + @Test public void testSerializeOptionalConverting() throws Exception { assertEquals("{\"opt\":[3,4]}", MAPPER.writeValueAsString(new PointReferenceBean(3, 4))); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalMergeTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalMergeTest.java index cd852ee7..bea56026 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalMergeTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalMergeTest.java @@ -4,9 +4,13 @@ import java.util.List; import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonMerge; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class OptionalMergeTest extends ModuleTestBase { // [modules-java8#214] @@ -18,6 +22,7 @@ static class OptionalListWrapper { private final ObjectMapper MAPPER = mapperWithModule(); // [modules-java8#214]: ReferenceType of List, merge + @Test public void testMergeToListViaRef() throws Exception { OptionalListWrapper base = MAPPER.readValue(a2q("{'list':['a']}"), diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalNumbersTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalNumbersTest.java index b5c6849c..667d0b6d 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalNumbersTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalNumbersTest.java @@ -4,13 +4,14 @@ import java.util.OptionalInt; import java.util.OptionalLong; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.MismatchedInputException; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.*; public class OptionalNumbersTest extends ModuleTestBase { @@ -52,12 +53,14 @@ static class OptionalDoubleBean { /********************************************************** */ + @Test public void testOptionalIntAbsent() throws Exception { String json = MAPPER.writeValueAsString(OptionalInt.empty()); assertFalse(MAPPER.readValue(json, OptionalInt.class).isPresent()); } + @Test public void testOptionalIntInArrayAbsent() throws Exception { OptionalInt[] ints = MAPPER.readValue("[null]", OptionalInt[].class); @@ -66,11 +69,13 @@ public void testOptionalIntInArrayAbsent() throws Exception assertFalse(ints[0].isPresent()); } + @Test public void testOptionalIntPresent() throws Exception { assertEquals(5, MAPPER.readValue(MAPPER.writeValueAsBytes(OptionalInt.of(5)), OptionalInt.class).getAsInt()); } + @Test public void testOptionalIntCoerceFromString() throws Exception { OptionalInt opt = MAPPER.readValue(q("123"), OptionalInt.class); @@ -95,11 +100,13 @@ public void testOptionalIntCoerceFromString() throws Exception /********************************************************** */ + @Test public void testOptionalLongAbsent() throws Exception { assertFalse(MAPPER.readValue(MAPPER.writeValueAsBytes(OptionalLong.empty()), OptionalLong.class).isPresent()); } + @Test public void testOptionalLongInArrayAbsent() throws Exception { OptionalLong[] arr = MAPPER.readValue("[null]", OptionalLong[].class); @@ -107,12 +114,14 @@ public void testOptionalLongInArrayAbsent() throws Exception assertNotNull(arr[0]); assertFalse(arr[0].isPresent()); } - + + @Test public void testOptionalLongPresent() throws Exception { assertEquals(Long.MAX_VALUE, MAPPER.readValue(MAPPER.writeValueAsBytes(OptionalLong.of(Long.MAX_VALUE)), OptionalLong.class).getAsLong()); } + @Test public void testOptionalLongCoerceFromString() throws Exception { OptionalLong opt = MAPPER.readValue(q("123"), OptionalLong.class); @@ -132,7 +141,8 @@ public void testOptionalLongCoerceFromString() throws Exception assertNotNull(bean.value); assertEquals(19L, bean.value.getAsLong()); } - + + @Test public void testOptionalLongSerializeFilter() throws Exception { ObjectMapper mapper = mapperWithModule() @@ -158,11 +168,13 @@ public void testOptionalLongSerializeFilter() throws Exception /********************************************************** */ + @Test public void testOptionalDoubleAbsent() throws Exception { assertFalse(MAPPER.readValue(MAPPER.writeValueAsBytes(OptionalInt.empty()), OptionalInt.class).isPresent()); } + @Test public void testOptionalDoubleInArrayAbsent() throws Exception { OptionalDouble[] arr = MAPPER.readValue("[null]", OptionalDouble[].class); @@ -171,11 +183,13 @@ public void testOptionalDoubleInArrayAbsent() throws Exception assertFalse(arr[0].isPresent()); } + @Test public void testOptionalDoublePresent() throws Exception { assertEquals(Double.MIN_VALUE, MAPPER.readValue(MAPPER.writeValueAsBytes(OptionalDouble.of(Double.MIN_VALUE)), OptionalDouble.class).getAsDouble()); } + @Test public void testOptionalDoubleCoerceFromString() throws Exception { OptionalDouble opt = MAPPER.readValue(q("0.25"), OptionalDouble.class); @@ -196,6 +210,7 @@ public void testOptionalDoubleCoerceFromString() throws Exception assertEquals(0.5, bean.value.getAsDouble()); } + @Test public void testOptionalDoubleInArraySpecialValues() throws Exception { OptionalDouble[] actual = MAPPER.readValue( @@ -212,6 +227,7 @@ public void testOptionalDoubleInArraySpecialValues() throws Exception assertArrayEquals(expected, actual); } + @Test public void testOptionalDoubleInArraySpecialValuesWithoutCoercion() throws Exception { OptionalDouble[] actual = MAPPER_WITHOUT_COERCION.readValue( @@ -227,12 +243,14 @@ public void testOptionalDoubleInArraySpecialValuesWithoutCoercion() throws Excep assertArrayEquals(expected, actual); } + @Test public void testQuotedOptionalDoubleWithoutCoercion() { assertThrows(MismatchedInputException.class, () -> MAPPER_WITHOUT_COERCION.readValue(a2q("['1']"), OptionalDouble[].class)); } + @Test public void testOptionalDoubleBeanSpecialValuesWithoutCoercion_null() throws Exception { OptionalDoubleBean bean = MAPPER_WITHOUT_COERCION.readValue( @@ -240,6 +258,7 @@ public void testOptionalDoubleBeanSpecialValuesWithoutCoercion_null() throws Exc assertEquals(OptionalDouble.empty(), bean.value); } + @Test public void testOptionalDoubleBeanSpecialValuesWithoutCoercion_nan() throws Exception { OptionalDoubleBean bean = MAPPER_WITHOUT_COERCION.readValue( @@ -247,6 +266,7 @@ public void testOptionalDoubleBeanSpecialValuesWithoutCoercion_nan() throws Exce assertEquals(OptionalDouble.of(Double.NaN), bean.value); } + @Test public void testOptionalDoubleBeanSpecialValuesWithoutCoercion_positiveInfinity() throws Exception { OptionalDoubleBean bean = MAPPER_WITHOUT_COERCION.readValue( @@ -254,6 +274,7 @@ public void testOptionalDoubleBeanSpecialValuesWithoutCoercion_positiveInfinity( assertEquals(OptionalDouble.of(Double.POSITIVE_INFINITY), bean.value); } + @Test public void testOptionalDoubleBeanSpecialValuesWithoutCoercion_negativeInfinity() throws Exception { OptionalDoubleBean bean = MAPPER_WITHOUT_COERCION.readValue( diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalTest.java index a640e924..656ec913 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalTest.java @@ -4,6 +4,8 @@ import java.util.*; import java.util.concurrent.atomic.AtomicReference; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.JsonGenerator; @@ -18,6 +20,8 @@ import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; import com.fasterxml.jackson.databind.type.TypeFactory; +import static org.junit.jupiter.api.Assertions.*; + public class OptionalTest extends ModuleTestBase { private static final TypeReference> OPTIONAL_STRING_TYPE = new TypeReference>() {}; @@ -126,21 +130,25 @@ public String deserialize(JsonParser p, DeserializationContext ctxt) /********************************************************** */ + @Test public void testStringAbsent() throws Exception { assertFalse(roundtrip(Optional.empty(), OPTIONAL_STRING_TYPE).isPresent()); } + @Test public void testStringPresent() throws Exception { assertEquals("test", roundtrip(Optional.of("test"), OPTIONAL_STRING_TYPE).get()); } + @Test public void testBeanAbsent() throws Exception { assertFalse(roundtrip(Optional.empty(), OPTIONAL_BEAN_TYPE).isPresent()); } + @Test public void testBeanPresent() throws Exception { final TestBean bean = new TestBean(Integer.MAX_VALUE, "woopwoopwoopwoopwoop"); @@ -148,6 +156,7 @@ public void testBeanPresent() throws Exception } // [issue#4] + @Test public void testBeanWithCreator() throws Exception { final Issue4Entity emptyEntity = new Issue4Entity(Optional.empty()); @@ -160,6 +169,7 @@ public void testBeanWithCreator() throws Exception } // [issue#4] + @Test public void testOptionalStringInBean() throws Exception { OptionalStringBean bean = MAPPER.readValue("{\"value\":\"xyz\"}", OptionalStringBean.class); @@ -168,6 +178,7 @@ public void testOptionalStringInBean() throws Exception } // To support [datatype-jdk8#8] + @Test public void testExcludeIfOptionalAbsent() throws Exception { ObjectMapper mapper = mapperWithModule() @@ -187,6 +198,7 @@ public void testExcludeIfOptionalAbsent() throws Exception mapper.writeValueAsString(new OptionalStringBean(null))); } + @Test public void testWithCustomDeserializer() throws Exception { CaseChangingStringWrapper w = MAPPER.readValue(a2q("{'value':'FoobaR'}"), @@ -195,6 +207,7 @@ public void testWithCustomDeserializer() throws Exception } // [modules-java8#36] + @Test public void testWithCustomDeserializerIfOptionalAbsent() throws Exception { // 10-Aug-2017, tatu: Actually this is not true: missing value does not trigger @@ -208,6 +221,7 @@ public void testWithCustomDeserializerIfOptionalAbsent() throws Exception CaseChangingStringWrapper.class).value); } + @Test public void testCustomSerializer() throws Exception { final String VALUE = "fooBAR"; @@ -215,6 +229,7 @@ public void testCustomSerializer() throws Exception assertEquals(json, a2q("{'value':'FOOBAR'}")); } + @Test public void testCustomSerializerIfOptionalAbsent() throws Exception { ObjectMapper mapper = mapperWithModule() @@ -235,6 +250,7 @@ public void testCustomSerializerIfOptionalAbsent() throws Exception } // [modules-java8#33]: Verify against regression... + @Test public void testOtherRefSerializers() throws Exception { String json = MAPPER.writeValueAsString(new AtomicReference("foo")); @@ -242,6 +258,7 @@ public void testOtherRefSerializers() throws Exception } // Check [databind#2796] here too + @Test public void testTypeResolution() throws Exception { // Should be able to construct using parametric `constructType()` diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalWithEmptyTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalWithEmptyTest.java index ca96c4fd..dd415a65 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalWithEmptyTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalWithEmptyTest.java @@ -2,9 +2,13 @@ import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class OptionalWithEmptyTest extends ModuleTestBase { private final ObjectMapper MAPPER = mapperWithModule(); @@ -18,12 +22,14 @@ public BooleanBean(Boolean b) { } } + @Test public void testOptionalFromEmpty() throws Exception { Optional value = MAPPER.readValue(q(""), new TypeReference>() {}); assertEquals(false, value.isPresent()); } // for [datatype-jdk8#23] + @Test public void testBooleanWithEmpty() throws Exception { // and looks like a special, somewhat non-conforming case is what a user had diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalnclusionTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalnclusionTest.java index 0ddb1885..32508055 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalnclusionTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/OptionalnclusionTest.java @@ -4,6 +4,8 @@ import java.util.Map; import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; @@ -11,6 +13,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class OptionalnclusionTest extends ModuleTestBase { @JsonAutoDetect(fieldVisibility=Visibility.ANY) @@ -55,6 +59,7 @@ public OptMapBean(String key, Optional v) { private final ObjectMapper MAPPER = mapperWithModule(); + @Test public void testSerOptNonEmpty() throws Exception { OptionalData data = new OptionalData(); @@ -64,6 +69,7 @@ public void testSerOptNonEmpty() throws Exception assertEquals("{}", value); } + @Test public void testSerOptNonDefault() throws Exception { OptionalData data = new OptionalData(); @@ -73,6 +79,7 @@ public void testSerOptNonDefault() throws Exception assertEquals("{}", value); } + @Test public void testSerOptNonAbsent() throws Exception { OptionalData data = new OptionalData(); @@ -82,6 +89,7 @@ public void testSerOptNonAbsent() throws Exception assertEquals("{}", value); } + @Test public void testExcludeEmptyStringViaOptional() throws Exception { String json = MAPPER.writeValueAsString(new OptionalNonEmptyStringBean("x")); @@ -92,6 +100,7 @@ public void testExcludeEmptyStringViaOptional() throws Exception assertEquals("{}", json); } + @Test public void testSerPropInclusionAlways() throws Exception { JsonInclude.Value incl = @@ -101,6 +110,7 @@ public void testSerPropInclusionAlways() throws Exception mapper.writeValueAsString(OptionalGenericData.construct(Boolean.TRUE))); } + @Test public void testSerPropInclusionNonNull() throws Exception { JsonInclude.Value incl = @@ -110,6 +120,7 @@ public void testSerPropInclusionNonNull() throws Exception mapper.writeValueAsString(OptionalGenericData.construct(Boolean.TRUE))); } + @Test public void testSerPropInclusionNonAbsent() throws Exception { JsonInclude.Value incl = @@ -119,6 +130,7 @@ public void testSerPropInclusionNonAbsent() throws Exception mapper.writeValueAsString(OptionalGenericData.construct(Boolean.TRUE))); } + @Test public void testSerPropInclusionNonEmpty() throws Exception { JsonInclude.Value incl = @@ -128,6 +140,7 @@ public void testSerPropInclusionNonEmpty() throws Exception mapper.writeValueAsString(OptionalGenericData.construct(Boolean.TRUE))); } + @Test public void testMapElementInclusion() throws Exception { ObjectMapper mapper = mapperWithModule().setDefaultPropertyInclusion( diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/PolymorphicOptionalTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/PolymorphicOptionalTest.java index 0d8741dc..d9c82c60 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/PolymorphicOptionalTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/PolymorphicOptionalTest.java @@ -2,11 +2,15 @@ import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class PolymorphicOptionalTest extends ModuleTestBase { // For [datatype-jdk8#14] @@ -25,6 +29,7 @@ public static class ContainedImpl implements Contained { } private final ObjectMapper MAPPER = mapperWithModule(); // [datatype-jdk8#14] + @Test public void testPolymorphic14() throws Exception { final Container dto = new Container(); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/SchemaVisitorTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/SchemaVisitorTest.java index fac77e9a..f1283b9a 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/SchemaVisitorTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/SchemaVisitorTest.java @@ -3,17 +3,22 @@ import java.util.*; import java.util.concurrent.atomic.AtomicReference; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser.NumberType; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.*; +import static org.junit.jupiter.api.Assertions.*; + // trivial tests visitor used (mostly) for JSON Schema generation public class SchemaVisitorTest extends ModuleTestBase { private final ObjectMapper MAPPER = mapperWithModule(); // for [datatype-jdk8#25] + @Test public void testOptionalInteger() throws Exception { final AtomicReference result = new AtomicReference<>(); @@ -33,6 +38,7 @@ public void numberType(NumberType t) { } // for [datatype-jdk8#25] + @Test public void testOptionalLong() throws Exception { final AtomicReference result = new AtomicReference<>(); @@ -52,6 +58,7 @@ public void numberType(NumberType t) { } // for [datatype-jdk8#25] + @Test public void testOptionalDouble() throws Exception { final AtomicReference result = new AtomicReference<>(); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamSerializerTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamSerializerTest.java index 1d7389a1..670fd66a 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamSerializerTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamSerializerTest.java @@ -1,7 +1,5 @@ package com.fasterxml.jackson.datatype.jdk8; -import static org.junit.Assert.*; - import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -9,11 +7,13 @@ import java.util.List; import java.util.stream.Stream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.datatype.jdk8.OptionalTest.TestBean; +import static org.junit.jupiter.api.Assertions.*; + @SuppressWarnings({ "javadoc", "unqualified-field-access" }) public class StreamSerializerTest extends StreamTestBase { diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamTestBase.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamTestBase.java index 5083a6a5..e6f77c9c 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamTestBase.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/StreamTestBase.java @@ -1,27 +1,18 @@ package com.fasterxml.jackson.datatype.jdk8; -import static org.junit.Assert.*; - import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.stream.BaseStream; -import org.hamcrest.CustomMatcher; -import org.hamcrest.Description; -import org.hamcrest.core.AllOf; -import org.hamcrest.core.Is; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -public class StreamTestBase { +import static org.junit.jupiter.api.Assertions.*; - @Rule - public final ExpectedException expectedException = ExpectedException.none(); +public class StreamTestBase { ObjectMapper objectMapper; @@ -47,7 +38,7 @@ static void castAndThrow(final Throwable t) throws T { throw (T) t; } - @Before + @BeforeEach public void initObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module()); @@ -63,77 +54,53 @@ > void assertClosesOnSuccess(S baseStream, Consume assertTrue(closed.get()); } - > void assertClosesOnRuntimeException(String exceptionMessage, Consumer roundTrip, + > void assertClosesOnRuntimeException(String exMessage, Consumer roundTrip, S baseStream) { AtomicBoolean closed = new AtomicBoolean(); - initExpectedException(RuntimeException.class, exceptionMessage,closed); - - roundTrip.accept(baseStream.onClose(() -> closed.set(true))); + Exception actualEx = assertThrows(Exception.class, + () -> roundTrip.accept(baseStream.onClose(() -> closed.set(true)))); + initExpectedException(actualEx, exMessage, closed); } - > void assertClosesOnIoException(String exceptionMessage, Consumer roundTrip, + > void assertClosesOnIoException(String exMessage, Consumer roundTrip, S baseStream) { AtomicBoolean closed = new AtomicBoolean(); - initExpectedExceptionIoException(exceptionMessage,closed); - - roundTrip.accept(baseStream.onClose(() -> closed.set(true))); + Exception actual = assertThrows(Exception.class, + () -> roundTrip.accept(baseStream.onClose(() -> closed.set(true)))); + initExpectedExceptionIoException(actual, closed, + "Unexpected IOException (of type java.io.IOException): " + exMessage); } - > void assertClosesOnWrappedIoException(String exceptionMessage, + > void assertClosesOnWrappedIoException(String expectedMsg, Consumer roundTrip, S baseStream) { AtomicBoolean closed = new AtomicBoolean(); - final String actualMessage = "Unexpected IOException (of type java.io.IOException): " + exceptionMessage; - - initExpectedExceptionIoException(actualMessage,closed); - - roundTrip.accept(baseStream.onClose(() -> closed.set(true))); + Exception actual = assertThrows(Exception.class, + () -> roundTrip.accept(baseStream.onClose(() -> closed.set(true)))); + initExpectedExceptionIoException(actual, closed, + "Unexpected IOException (of type java.io.IOException): " + expectedMsg); } - void initExpectedExceptionIoException(final String exceptionMessage, AtomicBoolean closed) { - - this.expectedException.expect(new IsClosedMatcher(closed)); - this.expectedException.expect(Is.isA(IOException.class)); - this.expectedException.expectMessage(exceptionMessage); + void initExpectedExceptionIoException(final Exception actualException, AtomicBoolean closed, final String exceptionMessage) + { + assertInstanceOf(IOException.class, actualException); + assertTrue(closed.get()); + assertTrue(actualException.getMessage().contains(exceptionMessage)); } - void initExpectedException(Class cause, final String exceptionMessage, AtomicBoolean closed) { - this.expectedException.expect(AllOf.allOf(Is.isA(JsonMappingException.class), new IsClosedMatcher(closed))); - this.expectedException.expect(Is.isA(JsonMappingException.class)); - this.expectedException.expectCause(Is.isA(cause)); - this.expectedException.expectMessage(exceptionMessage); + void initExpectedException(final Exception actualException, final String exceptionMessage, AtomicBoolean closed) + { + assertInstanceOf(JsonMappingException.class, actualException); + assertTrue(closed.get()); + assertTrue(actualException.getMessage().contains(exceptionMessage)); } - /** - * Matcher that matches when the {@link StreamTestBase#closed} value is set to true. - */ - static class IsClosedMatcher extends CustomMatcher { - - final AtomicBoolean closed; - - public IsClosedMatcher(AtomicBoolean closed) { - super("Check flag closed"); - this.closed = closed; - } - - @Override - public void describeMismatch(Object item, Description description) { - description.appendText("The onClose method was not called"); - } - - @Override - public boolean matches(Object item) { - - return closed.get(); - } - - } } diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestConfigureAbsentsAsNulls.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestConfigureAbsentsAsNulls.java index 2769f1f6..68aa2db8 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestConfigureAbsentsAsNulls.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestConfigureAbsentsAsNulls.java @@ -5,11 +5,15 @@ import java.util.OptionalInt; import java.util.OptionalLong; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + @SuppressWarnings("deprecation") public class TestConfigureAbsentsAsNulls extends ModuleTestBase { @@ -39,6 +43,7 @@ public static final class OptionalDoubleWrapper { /********************************************************************** */ + @Test public void testConfigAbsentsAsNullsTrue() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(true)); @@ -48,6 +53,7 @@ public void testConfigAbsentsAsNullsTrue() throws Exception { assertEquals("{}", value); } + @Test public void testConfigAbsentsAsNullsFalse() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(false)); @@ -57,6 +63,7 @@ public void testConfigAbsentsAsNullsFalse() throws Exception { assertEquals("{\"myString\":null}", value); } + @Test public void testConfigNonAbsentAbsentsAsNullsTrue() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(true)); @@ -66,6 +73,7 @@ public void testConfigNonAbsentAbsentsAsNullsTrue() throws Exception { assertEquals("{}", value); } + @Test public void testConfigNonAbsentAbsentsAsNullsFalse() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(false)); @@ -81,6 +89,7 @@ public void testConfigNonAbsentAbsentsAsNullsFalse() throws Exception { /********************************************************************** */ + @Test public void testOptionalIntAbsentAsNulls() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(true)); @@ -88,6 +97,7 @@ public void testOptionalIntAbsentAsNulls() throws Exception { assertEquals("{}", value); } + @Test public void testOptionalLongAbsentAsNulls() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(true)); @@ -95,6 +105,7 @@ public void testOptionalLongAbsentAsNulls() throws Exception { assertEquals("{}", value); } + @Test public void testOptionalDoubleAbsentAsNulls() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(true)); diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestOptionalWithPolymorphic.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestOptionalWithPolymorphic.java index ab23043c..6d8bd2fc 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestOptionalWithPolymorphic.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jdk8/TestOptionalWithPolymorphic.java @@ -4,6 +4,8 @@ import java.util.Map; import java.util.Optional; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSubTypes; @@ -11,6 +13,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import static org.junit.jupiter.api.Assertions.*; + public class TestOptionalWithPolymorphic extends ModuleTestBase { static class ContainerA { @@ -69,6 +73,7 @@ static class AbstractOptional { final ObjectMapper MAPPER = mapperWithModule(); + @Test public void testOptionalMapsFoo() throws Exception { Map foo = new LinkedHashMap<>(); @@ -82,6 +87,7 @@ public void testOptionalMapsFoo() throws Exception { _test(MAPPER, foo); } + @Test public void testOptionalMapsBar() throws Exception { Map bar = new LinkedHashMap<>(); @@ -95,6 +101,7 @@ public void testOptionalMapsBar() throws Exception { _test(MAPPER, bar); } + @Test public void testOptionalMapsBaz() throws Exception { Map baz = new LinkedHashMap<>(); Map loop = new LinkedHashMap<>(); @@ -107,6 +114,7 @@ public void testOptionalMapsBaz() throws Exception { _test(MAPPER, baz); } + @Test public void testOptionalWithTypeAnnotation13() throws Exception { AbstractOptional result = MAPPER.readValue("{\"value\" : 5}", diff --git a/datetime/pom.xml b/datetime/pom.xml index 08c1939f..69903cef 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -46,6 +46,13 @@ com.fasterxml.jackson.core jackson-annotations + + + + junit + junit + test + diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ConstructorDetectorConfigTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ConstructorDetectorConfigTest.java index bd9627f5..8309b1c6 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ConstructorDetectorConfigTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ConstructorDetectorConfigTest.java @@ -1,12 +1,12 @@ package com.fasterxml.jackson.module.paramnames; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.cfg.ConstructorDetector; +import static org.junit.jupiter.api.Assertions.*; + public class ConstructorDetectorConfigTest extends ModuleTestBase { diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java index f1e81044..3c264048 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java @@ -1,13 +1,13 @@ package com.fasterxml.jackson.module.paramnames; +import org.junit.jupiter.api.Test; + import static org.assertj.core.api.BDDAssertions.then; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; -import org.junit.Test; - // for [java8-modules#74] public class CreatorWithNamingStrategy74Test extends ModuleTestBase diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java index d17f0444..9b68acc1 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java @@ -1,11 +1,11 @@ package com.fasterxml.jackson.module.paramnames; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.type.*; import com.fasterxml.jackson.databind.*; -import org.junit.*; - import java.io.*; import java.util.*; diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/EnumNamingTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/EnumNamingTest.java index 4b275c1b..9258f626 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/EnumNamingTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/EnumNamingTest.java @@ -1,13 +1,13 @@ package com.fasterxml.jackson.module.paramnames; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.databind.ObjectMapper; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class EnumNamingTest extends ModuleTestBase { diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JDKSerializabilityTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JDKSerializabilityTest.java index ef0ade22..ebb2b513 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JDKSerializabilityTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JDKSerializabilityTest.java @@ -2,11 +2,11 @@ import java.io.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.*; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class JDKSerializabilityTest extends ModuleTestBase { diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java index ba525c96..23b94e7e 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java @@ -1,16 +1,15 @@ package com.fasterxml.jackson.module.paramnames; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.*; - import static org.assertj.core.api.BDDAssertions.*; +import static org.junit.jupiter.api.Assertions.*; + public class JsonCreatorTest extends ModuleTestBase { static class ClassWithJsonCreatorOnStaticMethod { diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/MapKeyNames206Test.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/MapKeyNames206Test.java index e3336be2..9ed6fdcf 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/MapKeyNames206Test.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/MapKeyNames206Test.java @@ -2,7 +2,7 @@ import java.util.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonKey; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; // [modules-java8#206] public class MapKeyNames206Test diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java index 645af4b1..c9bcc778 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.BDDAssertions.then; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ParameterNamesAnnotationIntrospectorTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ParameterNamesAnnotationIntrospectorTest.java index 433a5dd5..5f3a35e0 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ParameterNamesAnnotationIntrospectorTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/ParameterNamesAnnotationIntrospectorTest.java @@ -4,12 +4,11 @@ import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor; import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; import com.fasterxml.jackson.databind.introspect.AnnotatedParameter; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.Mockito; import java.lang.reflect.Constructor; import java.lang.reflect.MalformedParametersException; @@ -19,20 +18,20 @@ import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.when; /** * @author Lovro Pandzic */ -@RunWith(MockitoJUnitRunner.class) public class ParameterNamesAnnotationIntrospectorTest { - @Mock private ParameterExtractor parameterExtractor; private ParameterNamesAnnotationIntrospector introspector; - @Before + @BeforeEach public void setUp() throws Exception { + parameterExtractor = Mockito.mock(ParameterExtractor.class); introspector = new ParameterNamesAnnotationIntrospector(JsonCreator.Mode.DEFAULT, parameterExtractor); } @@ -44,7 +43,7 @@ public void shouldFindParameterNameFromConstructorForLegalIndex() throws Excepti Parameter[] givenParameters = givenConstructor.getParameters(); AnnotatedConstructor owner = new AnnotatedConstructor(null, givenConstructor, null, null); AnnotatedParameter annotatedParameter = new AnnotatedParameter(owner, null, null, null, 0); - given(parameterExtractor.getParameters(any())).willReturn(givenParameters); + when(parameterExtractor.getParameters(any())).thenReturn(givenParameters); // when String actual = introspector.findImplicitPropertyName(annotatedParameter); diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java index 6dc184e5..1e0198fd 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java @@ -5,7 +5,7 @@ import java.io.IOException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PersonTest { diff --git a/pom.xml b/pom.xml index 914a1abc..f9c37837 100644 --- a/pom.xml +++ b/pom.xml @@ -40,10 +40,15 @@ jackson-databind - + - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test From 6d27f260c0e00b20c6929896637f3b4f29d29de1 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Tue, 28 Jan 2025 08:23:21 +0900 Subject: [PATCH 012/140] [JSTEP-10] Migrate part of `datetime` module tests to JUnit 5 (#347) --- datetime/pom.xml | 12 + .../datatype/jsr310/old/ModuleTestBase.java | 3 + .../datatype/jsr310/old/PolymorphicTest.java | 6 +- .../datatype/jsr310/old/TestDecimalUtils.java | 47 ++-- .../old/TestDurationDeserialization.java | 75 +++-- .../old/TestDurationKeySerialization.java | 15 +- .../jsr310/old/TestDurationSerialization.java | 52 ++-- .../datatype/jsr310/old/TestFeatures.java | 17 +- .../old/TestInstantKeySerialization.java | 20 +- .../jsr310/old/TestInstantSerialization.java | 133 +++++---- .../old/TestLocalDateKeySerialization.java | 14 +- .../old/TestLocalDateSerialization.java | 53 ++-- .../TestLocalDateTimeKeySerialization.java | 18 +- .../old/TestLocalDateTimeSerialization.java | 119 ++++---- .../old/TestLocalTimeKeySerialization.java | 17 +- .../old/TestLocalTimeSerialization.java | 125 ++++----- .../old/TestMonthDayKeySerialization.java | 13 +- .../jsr310/old/TestMonthDaySerialization.java | 42 ++- .../jsr310/old/TestNullKeySerialization.java | 13 +- .../TestOffsetDateTimeKeySerialization.java | 21 +- .../old/TestOffsetDateTimeSerialization.java | 227 ++++++++------- .../old/TestOffsetTimeKeySerialization.java | 21 +- .../old/TestOffsetTimeSerialization.java | 121 ++++---- .../old/TestPeriodKeySerialization.java | 17 +- .../jsr310/old/TestPeriodSerialization.java | 43 ++- .../jsr310/old/TestYearKeySerialization.java | 13 +- .../old/TestYearMonthKeySerialization.java | 13 +- .../old/TestYearMonthSerialization.java | 63 ++--- .../jsr310/old/TestYearSerialization.java | 38 ++- .../old/TestZoneIdKeySerialization.java | 21 +- .../jsr310/old/TestZoneIdSerialization.java | 33 ++- .../old/TestZoneOffsetKeySerialization.java | 17 +- .../old/TestZoneOffsetSerialization.java | 46 ++-- .../TestZonedDateTimeKeySerialization.java | 21 +- .../old/TestZonedDateTimeSerialization.java | 259 +++++++++--------- 35 files changed, 862 insertions(+), 906 deletions(-) diff --git a/datetime/pom.xml b/datetime/pom.xml index 69903cef..f46a4a87 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -46,6 +46,18 @@ com.fasterxml.jackson.core jackson-annotations + + + + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api + test + diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/ModuleTestBase.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/ModuleTestBase.java index 8832fec8..ed1c7362 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/ModuleTestBase.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/ModuleTestBase.java @@ -2,6 +2,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ModuleTestBase { // 14-Mar-2016, tatu: Serialization of trailing zeroes may change [datatype-jsr310#67] diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/PolymorphicTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/PolymorphicTest.java index 761e0c0f..bcc0ec5f 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/PolymorphicTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/PolymorphicTest.java @@ -2,13 +2,13 @@ import java.time.ZoneId; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase.NoCheckSubTypeValidator; +import static org.junit.jupiter.api.Assertions.*; + public class PolymorphicTest extends ModuleTestBase { private final ObjectMapper TYPING_MAPPER = newMapper(); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDecimalUtils.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDecimalUtils.java index 3ad09ec2..64d4ab1a 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDecimalUtils.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDecimalUtils.java @@ -1,11 +1,12 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; - import java.math.BigDecimal; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.datatype.jsr310.DecimalUtils; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.*; @SuppressWarnings("deprecation") public class TestDecimalUtils extends ModuleTestBase @@ -14,22 +15,22 @@ public class TestDecimalUtils extends ModuleTestBase public void testToDecimal01() { String decimal = DecimalUtils.toDecimal(0, 0); - assertEquals("The returned decimal is not correct.", NO_NANOSECS_SER, decimal); + assertEquals(NO_NANOSECS_SER, decimal, "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(15, 72); - assertEquals("The returned decimal is not correct.", "15.000000072", decimal); + assertEquals("15.000000072", decimal, "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(19827342231L, 192837465); - assertEquals("The returned decimal is not correct.", "19827342231.192837465", - decimal); + assertEquals("19827342231.192837465", decimal, + "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(19827342231L, 0); - assertEquals("The returned decimal is not correct.", - "19827342231"+NO_NANOSECS_SUFFIX, decimal); + assertEquals("19827342231"+NO_NANOSECS_SUFFIX, decimal, + "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(19827342231L, 987654321); - assertEquals("The returned decimal is not correct.", - "19827342231.987654321", decimal); + assertEquals("19827342231.987654321", decimal, + "The returned decimal is not correct."); } @Test @@ -38,10 +39,10 @@ public void testExtractNanosecondDecimal01() BigDecimal value = new BigDecimal("0"); long seconds = value.longValue(); - assertEquals("The second part is not correct.", 0L, seconds); + assertEquals(0L, seconds, "The second part is not correct."); int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - assertEquals("The nanosecond part is not correct.", 0, nanoseconds); + assertEquals(0, nanoseconds, "The nanosecond part is not correct."); } @Test @@ -50,10 +51,10 @@ public void testExtractNanosecondDecimal02() BigDecimal value = new BigDecimal("15.000000072"); long seconds = value.longValue(); - assertEquals("The second part is not correct.", 15L, seconds); + assertEquals(15L, seconds, "The second part is not correct."); int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - assertEquals("The nanosecond part is not correct.", 72, nanoseconds); + assertEquals(72, nanoseconds, "The nanosecond part is not correct."); } @Test @@ -62,10 +63,10 @@ public void testExtractNanosecondDecimal03() BigDecimal value = new BigDecimal("15.72"); long seconds = value.longValue(); - assertEquals("The second part is not correct.", 15L, seconds); + assertEquals(15L, seconds, "The second part is not correct."); int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - assertEquals("The nanosecond part is not correct.", 720000000, nanoseconds); + assertEquals(720000000, nanoseconds, "The nanosecond part is not correct."); } @Test @@ -74,10 +75,10 @@ public void testExtractNanosecondDecimal04() BigDecimal value = new BigDecimal("19827342231.192837465"); long seconds = value.longValue(); - assertEquals("The second part is not correct.", 19827342231L, seconds); + assertEquals(19827342231L, seconds, "The second part is not correct."); int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - assertEquals("The nanosecond part is not correct.", 192837465, nanoseconds); + assertEquals(192837465, nanoseconds, "The nanosecond part is not correct."); } @Test @@ -86,10 +87,10 @@ public void testExtractNanosecondDecimal05() BigDecimal value = new BigDecimal("19827342231"); long seconds = value.longValue(); - assertEquals("The second part is not correct.", 19827342231L, seconds); + assertEquals(19827342231L, seconds, "The second part is not correct."); int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - assertEquals("The nanosecond part is not correct.", 0, nanoseconds); + assertEquals(0, nanoseconds, "The nanosecond part is not correct."); } @Test @@ -98,9 +99,9 @@ public void testExtractNanosecondDecimal06() BigDecimal value = new BigDecimal("19827342231.999999999"); long seconds = value.longValue(); - assertEquals("The second part is not correct.", 19827342231L, seconds); + assertEquals(19827342231L, seconds, "The second part is not correct."); int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - assertEquals("The nanosecond part is not correct.", 999999999, nanoseconds); + assertEquals(999999999, nanoseconds, "The nanosecond part is not correct."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationDeserialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationDeserialization.java index 967011e7..822c171c 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationDeserialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationDeserialization.java @@ -1,19 +1,16 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.time.Duration; import java.time.temporal.TemporalAmount; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; +import static org.junit.jupiter.api.Assertions.*; + public class TestDurationDeserialization extends ModuleTestBase { private final ObjectReader READER = newMapper().readerFor(Duration.class); @@ -24,9 +21,9 @@ public void testDeserializationAsFloat01() throws Exception Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60.0"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); Duration exp = Duration.ofSeconds(60L, 0); - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } @Test @@ -35,9 +32,9 @@ public void testDeserializationAsFloat02() throws Exception Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60.0"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); Duration exp = Duration.ofSeconds(60L, 0); - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } @Test @@ -45,8 +42,8 @@ public void testDeserializationAsFloat03() throws Exception { Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498.000008374"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 8374), value); + assertNotNull(value); + assertEquals(Duration.ofSeconds(13498L, 8374), value, "The value is not correct."); } @Test @@ -54,8 +51,8 @@ public void testDeserializationAsFloat04() throws Exception { Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498.000008374"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 8374), value); + assertNotNull(value); + assertEquals(Duration.ofSeconds(13498L, 8374), value, "The value is not correct."); } @Test @@ -63,8 +60,8 @@ public void testDeserializationAsInt01() throws Exception { Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value); + assertNotNull(value); + assertEquals(Duration.ofSeconds(60L, 0), value, "The value is not correct."); } @Test @@ -73,8 +70,8 @@ public void testDeserializationAsInt02() throws Exception Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60000"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value); + assertNotNull(value); + assertEquals(Duration.ofSeconds(60L, 0), value, "The value is not correct."); } @Test @@ -83,8 +80,8 @@ public void testDeserializationAsInt03() throws Exception Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 0), value); + assertNotNull(value); + assertEquals(Duration.ofSeconds(13498L, 0), value, "The value is not correct."); } @Test @@ -93,8 +90,8 @@ public void testDeserializationAsInt04() throws Exception Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498000"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 0), value); + assertNotNull(value); + assertEquals(Duration.ofSeconds(13498L, 0), value, "The value is not correct."); } @Test @@ -103,8 +100,8 @@ public void testDeserializationAsString01() throws Exception Duration exp = Duration.ofSeconds(60L, 0); Duration value = READER.readValue('"' + exp.toString() + '"'); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", exp, value); + assertNotNull(value); + assertEquals(exp, value, "The value is not correct."); } @Test @@ -113,15 +110,15 @@ public void testDeserializationAsString02() throws Exception Duration exp = Duration.ofSeconds(13498L, 8374); Duration value = READER.readValue('"' + exp.toString() + '"'); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", exp, value); + assertNotNull(value); + assertEquals(exp, value, "The value is not correct."); } @Test public void testDeserializationAsString03() throws Exception { Duration value = READER.readValue("\" \""); - assertNull("The value should be null.", value); + assertNull(value, "The value should be null."); } @Test @@ -136,9 +133,9 @@ public void testDeserializationWithTypeInfo01() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + "13498.000008374]", TemporalAmount.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", duration, value); + assertNotNull(value); + assertInstanceOf(Duration.class, value, "The value should be a Duration."); + assertEquals(duration, value, "The value is not correct."); } @Test @@ -151,9 +148,9 @@ public void testDeserializationWithTypeInfo02() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + "13498]", TemporalAmount.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L), value); + assertNotNull(value); + assertInstanceOf(Duration.class, value, "The value should be a Duration."); + assertEquals(Duration.ofSeconds(13498L), value, "The value is not correct."); } @Test @@ -166,9 +163,9 @@ public void testDeserializationWithTypeInfo03() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + "13498837]", TemporalAmount.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 837000000), value); + assertNotNull(value); + assertInstanceOf(Duration.class, value, "The value should be a Duration."); + assertEquals(Duration.ofSeconds(13498L, 837000000), value, "The value is not correct."); } @Test @@ -182,8 +179,8 @@ public void testDeserializationWithTypeInfo04() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + '"' + duration.toString() + "\"]", TemporalAmount.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", duration, value); + assertNotNull(value); + assertInstanceOf(Duration.class, value, "The value should be a Duration."); + assertEquals(duration, value, "The value is not correct."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationKeySerialization.java index d33285be..e2a48711 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationKeySerialization.java @@ -1,15 +1,16 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; - import java.time.Duration; import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.*; public class TestDurationKeySerialization extends ModuleTestBase { @@ -21,7 +22,7 @@ public class TestDurationKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -37,7 +38,7 @@ public void testSerialization() throws Exception { String value = om.writeValueAsString(map); - assertEquals("Value is not correct", map(DURATION_STRING, "test"), value); + assertEquals(map(DURATION_STRING, "test"), value); } @Test @@ -47,7 +48,7 @@ public void testDeserialization() throws Exception { TYPE_REF); map.put(DURATION, "test"); - assertEquals("Value is not correct", map, value); + assertEquals(map, value, "Value is not correct"); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationSerialization.java index 19c79227..3847ba6b 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestDurationSerialization.java @@ -4,19 +4,19 @@ import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.Duration; import java.time.temporal.TemporalAmount; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class TestDurationSerialization extends ModuleTestBase { private ObjectWriter WRITER; - @Before + @BeforeEach public void setUp() { WRITER = newMapper().writer(); @@ -31,9 +31,8 @@ public void testSerializationAsTimestampNanoseconds01() throws Exception .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "60"+NO_NANOSECS_SUFFIX, value); + assertNotNull(value); + assertEquals("60"+NO_NANOSECS_SUFFIX, value); } @Test @@ -45,8 +44,8 @@ public void testSerializationAsTimestampNanoseconds02() throws Exception .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "13498.000008374", value); + assertNotNull(value); + assertEquals("13498.000008374", value); } @Test @@ -58,8 +57,8 @@ public void testSerializationAsTimestampMilliseconds01() throws Exception .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "60000", value); + assertNotNull(value); + assertEquals("60000", value); } @Test @@ -71,8 +70,8 @@ public void testSerializationAsTimestampMilliseconds02() throws Exception .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "13498000", value); + assertNotNull(value); + assertEquals("13498000", value); } @Test @@ -84,8 +83,8 @@ public void testSerializationAsTimestampMilliseconds03() throws Exception .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "13498837", value); + assertNotNull(value); + assertEquals("13498837", value); } @Test @@ -96,8 +95,8 @@ public void testSerializationAsString01() throws Exception .without(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) .writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + duration.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + duration.toString() + '"', value); } @Test @@ -108,8 +107,8 @@ public void testSerializationAsString02() throws Exception .without(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) .writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + duration.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + duration.toString() + '"', value); } @Test @@ -122,9 +121,8 @@ public void testSerializationWithTypeInfo01() throws Exception Duration duration = Duration.ofSeconds(13498L, 8374); String value = mapper.writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + Duration.class.getName() + "\",13498.000008374]", value); + assertNotNull(value); + assertEquals("[\"" + Duration.class.getName() + "\",13498.000008374]", value); } @Test @@ -137,9 +135,8 @@ public void testSerializationWithTypeInfo02() throws Exception Duration duration = Duration.ofSeconds(13498L, 837481723); String value = mapper.writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + Duration.class.getName() + "\",13498837]", value); + assertNotNull(value); + assertEquals("[\"" + Duration.class.getName() + "\",13498837]", value); } @Test @@ -151,8 +148,7 @@ public void testSerializationWithTypeInfo03() throws Exception Duration duration = Duration.ofSeconds(13498L, 8374); String value = mapper.writeValueAsString(duration); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + Duration.class.getName() + "\",\"" + duration.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + Duration.class.getName() + "\",\"" + duration.toString() + "\"]", value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestFeatures.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestFeatures.java index 724806ae..3fa74700 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestFeatures.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestFeatures.java @@ -16,32 +16,33 @@ package com.fasterxml.jackson.datatype.jsr310.old; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class TestFeatures { @Test public void testWriteDateTimestampsAsNanosecondsSettingEnabledByDefault() { - assertTrue("Write date timestamps as nanoseconds setting should be enabled by default.", - SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault()); + assertTrue(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault(), + "Write date timestamps as nanoseconds setting should be enabled by default."); } @Test public void testReadDateTimestampsAsNanosecondsSettingEnabledByDefault() { - assertTrue("Read date timestamps as nanoseconds setting should be enabled by default.", - DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault()); + assertTrue(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault(), + "Read date timestamps as nanoseconds setting should be enabled by default."); } @Test public void testAdjustDatesToContextTimeZoneSettingEnabledByDefault() { - assertTrue("Adjust dates to context time zone setting should be enabled by default.", - DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE.enabledByDefault()); + assertTrue(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE.enabledByDefault(), + "Adjust dates to context time zone setting should be enabled by default."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantKeySerialization.java index e11823ed..67a625e5 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantKeySerialization.java @@ -1,16 +1,16 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; - import java.time.Instant; import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.*; public class TestInstantKeySerialization extends ModuleTestBase { @@ -24,7 +24,7 @@ public class TestInstantKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -40,7 +40,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(INSTANT_0_STRING, "test"), value); + assertEquals(map(INSTANT_0_STRING, "test"), value); } @Test @@ -49,7 +49,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - assertEquals("Value is incorrect", map(INSTANT_STRING, "test"), value); + assertEquals(map(INSTANT_STRING, "test"), value); } @Test @@ -57,7 +57,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(INSTANT_0_STRING, "test"), TYPE_REF); map.put(INSTANT_0, "test"); - assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -65,7 +65,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(INSTANT_STRING, "test"), TYPE_REF); map.put(INSTANT, "test"); - assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantSerialization.java index 6e3736f7..c420f4ec 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestInstantSerialization.java @@ -16,22 +16,20 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Instant; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.DecimalUtils; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestInstantSerialization extends ModuleTestBase { @@ -39,7 +37,7 @@ public class TestInstantSerialization extends ModuleTestBase private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -54,8 +52,8 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "0.0", value); + assertNotNull(value); + assertEquals("0.0", value); } @Test @@ -67,8 +65,8 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "0", value); + assertNotNull(value); + assertEquals("0", value); } @Test @@ -80,8 +78,8 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertNotNull(value); + assertEquals("123456789.183917322", value); } @Test @@ -93,8 +91,8 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "123456789183", value); + assertNotNull(value); + assertEquals("123456789183", value); } @Test @@ -106,8 +104,8 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", DecimalUtils.toDecimal(date.getEpochSecond(), date.getNano()), value); + assertNotNull(value); + assertEquals(DecimalUtils.toDecimal(date.getEpochSecond(), date.getNano()), value); } @Test @@ -119,8 +117,8 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Long.toString(date.toEpochMilli()), value); + assertNotNull(value); + assertEquals(Long.toString(date.toEpochMilli()), value); } @Test @@ -131,8 +129,8 @@ public void testSerializationAsString01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertNotNull(value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -143,8 +141,8 @@ public void testSerializationAsString02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertNotNull(value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -155,8 +153,8 @@ public void testSerializationAsString03() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertNotNull(value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -169,8 +167,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"" + Instant.class.getName() + "\",123456789.183917322]", value); + assertNotNull(value); + assertEquals("[\"" + Instant.class.getName() + "\",123456789.183917322]", value); } @Test @@ -183,8 +181,8 @@ public void testSerializationWithTypeInfo02() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"" + Instant.class.getName() + "\",123456789183]", value); + assertNotNull(value); + assertEquals("[\"" + Instant.class.getName() + "\",123456789183]", value); } @Test @@ -196,9 +194,8 @@ public void testSerializationWithTypeInfo03() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + Instant.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + Instant.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); } @Test @@ -208,8 +205,8 @@ public void testDeserializationAsFloat01() throws Exception Instant value = this.mapper.readValue("0.000000000", Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -219,8 +216,8 @@ public void testDeserializationAsFloat02() throws Exception Instant value = this.mapper.readValue("123456789.183917322", Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -232,8 +229,8 @@ public void testDeserializationAsFloat03() throws Exception DecimalUtils.toDecimal(date.getEpochSecond(), date.getNano()), Instant.class ); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -244,8 +241,8 @@ public void testDeserializationAsInt01Nanoseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); Instant value = this.mapper.readValue("0", Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -256,8 +253,8 @@ public void testDeserializationAsInt01Milliseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); Instant value = this.mapper.readValue("0", Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -268,8 +265,8 @@ public void testDeserializationAsInt02Nanoseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); Instant value = this.mapper.readValue("123456789", Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -280,8 +277,8 @@ public void testDeserializationAsInt02Milliseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); Instant value = this.mapper.readValue("123456789422", Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -293,8 +290,8 @@ public void testDeserializationAsInt03Nanoseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); Instant value = this.mapper.readValue(Long.toString(date.getEpochSecond()), Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -306,8 +303,8 @@ public void testDeserializationAsInt03Milliseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); Instant value = this.mapper.readValue(Long.toString(date.toEpochMilli()), Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -317,8 +314,8 @@ public void testDeserializationAsString01() throws Exception Instant value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -328,8 +325,8 @@ public void testDeserializationAsString02() throws Exception Instant value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -339,8 +336,8 @@ public void testDeserializationAsString03() throws Exception Instant value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', Instant.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -353,9 +350,9 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + Instant.class.getName() + "\",123456789.183917322]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an Instant.", value instanceof Instant); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertInstanceOf(Instant.class, value, "The value should be an Instant."); + assertEquals(date, value); } @Test @@ -369,9 +366,9 @@ public void testDeserializationWithTypeInfo02() throws Exception "[\"" + Instant.class.getName() + "\",123456789]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an Instant.", value instanceof Instant); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertInstanceOf(Instant.class, value, "The value should be an Instant."); + assertEquals(date, value); } @Test @@ -385,9 +382,9 @@ public void testDeserializationWithTypeInfo03() throws Exception "[\"" + Instant.class.getName() + "\",123456789422]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an Instant.", value instanceof Instant); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertInstanceOf(Instant.class, value, "The value should be an Instant."); + assertEquals(date, value); } @Test @@ -400,8 +397,8 @@ public void testDeserializationWithTypeInfo04() throws Exception "[\"" + Instant.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an Instant.", value instanceof Instant); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertInstanceOf(Instant.class, value, "The value should be an Instant."); + assertEquals(date, value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateKeySerialization.java index 090401da..01e77945 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateKeySerialization.java @@ -1,16 +1,16 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; - import java.time.LocalDate; import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestLocalDateKeySerialization extends ModuleTestBase { @@ -22,7 +22,7 @@ public class TestLocalDateKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -38,7 +38,7 @@ public void testSerialization() throws Exception { String value = om.writeValueAsString(map); - assertEquals("Incorrect value", map(DATE_STRING, "test"), value); + assertEquals(map(DATE_STRING, "test"), value); } @Test @@ -48,7 +48,7 @@ public void testDeserialization() throws Exception { TYPE_REF); map.put(DATE, "test"); - assertEquals("Incorrect value", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateSerialization.java index 7203b196..a72cd6cf 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateSerialization.java @@ -16,9 +16,8 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.LocalDate; import java.time.Month; @@ -27,14 +26,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestLocalDateSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -48,8 +46,8 @@ public void testSerializationAsTimestamp01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[1986,1,17]", value); + assertNotNull(value); + assertEquals("[1986,1,17]", value); } @Test @@ -60,8 +58,8 @@ public void testSerializationAsTimestamp02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2013,8,21]", value); + assertNotNull(value); + assertEquals("[2013,8,21]", value); } @Test @@ -72,8 +70,8 @@ public void testSerializationAsString01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + date.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + date.toString() + '"', value); } @Test @@ -84,8 +82,8 @@ public void testSerializationAsString02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + date.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + date.toString() + '"', value); } @Test @@ -97,9 +95,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + LocalDate.class.getName() + "\",\"" + date.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + LocalDate.class.getName() + "\",\"" + date.toString() + "\"]", value); } @Test @@ -109,8 +106,8 @@ public void testDeserializationAsTimestamp01() throws Exception LocalDate value = this.mapper.readValue("[1986,1,17]", LocalDate.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -120,8 +117,8 @@ public void testDeserializationAsTimestamp02() throws Exception LocalDate value = this.mapper.readValue("[2013,8,21]", LocalDate.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -131,8 +128,8 @@ public void testDeserializationAsString01() throws Exception LocalDate value = this.mapper.readValue('"' + date.toString() + '"', LocalDate.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -142,8 +139,8 @@ public void testDeserializationAsString02() throws Exception LocalDate value = this.mapper.readValue('"' + date.toString() + '"', LocalDate.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertEquals(date, value); } @Test @@ -156,8 +153,8 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + LocalDate.class.getName() + "\",\"" + date.toString() + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalDate.", value instanceof LocalDate); - assertEquals("The value is not correct.", date, value); + assertNotNull(value); + assertInstanceOf(LocalDate.class, value); + assertEquals(date, value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeKeySerialization.java index 0d8e5730..d6d64122 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeKeySerialization.java @@ -1,17 +1,17 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; - import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestLocalDateTimeKeySerialization extends ModuleTestBase { @@ -28,7 +28,7 @@ public class TestLocalDateTimeKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -44,7 +44,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - assertEquals("Value is incorrect", map(DATE_TIME_0_STRING, "test"), value); + assertEquals(map(DATE_TIME_0_STRING, "test"), value); } @Test @@ -53,7 +53,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - assertEquals("Value is incorrect", map(DATE_TIME_STRING, "test"), value); + assertEquals(map(DATE_TIME_STRING, "test"), value); } @Test @@ -63,7 +63,7 @@ public void testDeserialization0() throws Exception { TYPE_REF); map.put(DATE_TIME_0, "test"); - assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -73,7 +73,7 @@ public void testDeserialization1() throws Exception { TYPE_REF); map.put(DATE_TIME, "test"); - assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeSerialization.java index 544fd0ed..9f696a88 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalDateTimeSerialization.java @@ -16,26 +16,26 @@ package com.fasterxml.jackson.datatype.jsr310.old; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Before; -import org.junit.Test; - import java.time.LocalDateTime; import java.time.Month; import java.time.temporal.Temporal; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class TestLocalDateTimeSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { mapper = newMapper(); @@ -49,8 +49,8 @@ public void testSerializationAsTimestamp01() throws Exception String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[1986,1,17,15,43]", value); + assertNotNull(value); + assertEquals("[1986,1,17,15,43]", value); } @Test @@ -59,8 +59,8 @@ public void testSerializationAsTimestamp02() throws Exception LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 57); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2013,8,21,9,22,57]", value); + assertNotNull(value); + assertEquals("[2013,8,21,9,22,57]", value); } @Test @@ -71,8 +71,8 @@ public void testSerializationAsTimestamp03Nanosecond() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2013,8,21,9,22,0,57]", value); + assertNotNull(value); + assertEquals("[2013,8,21,9,22,0,57]", value); } @Test @@ -83,8 +83,8 @@ public void testSerializationAsTimestamp03Millisecond() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2013,8,21,9,22,0,0]", value); + assertNotNull(value); + assertEquals("[2013,8,21,9,22,0,0]", value); } @Test @@ -95,8 +95,8 @@ public void testSerializationAsTimestamp04Nanosecond() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2005,11,5,22,31,5,829837]", value); + assertNotNull(value); + assertEquals("[2005,11,5,22,31,5,829837]", value); } @Test @@ -107,8 +107,8 @@ public void testSerializationAsTimestamp04Millisecond() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2005,11,5,22,31,5,422]", value); + assertNotNull(value); + assertEquals("[2005,11,5,22,31,5,422]", value); } @Test @@ -120,8 +120,8 @@ public void testSerializationAsString01() throws Exception m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"1986-01-17T15:43:06\"", value); + assertNotNull(value); + assertEquals("\"1986-01-17T15:43:06\"", value); } @Test @@ -133,8 +133,8 @@ public void testSerializationAsString02() throws Exception m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -146,8 +146,8 @@ public void testSerializationAsString03() throws Exception m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -161,9 +161,8 @@ public void testSerializationWithTypeInfo01() throws Exception m.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,829837]]", value); + assertNotNull(value); + assertEquals("[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,829837]]", value); } @Test @@ -177,9 +176,8 @@ public void testSerializationWithTypeInfo02() throws Exception LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 422829837); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,422]]", value); + assertNotNull(value); + assertEquals("[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,422]]", value); } @Test @@ -191,9 +189,8 @@ public void testSerializationWithTypeInfo03() throws Exception LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829837); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + LocalDateTime.class.getName() + "\",\"" + time.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + LocalDateTime.class.getName() + "\",\"" + time.toString() + "\"]", value); } @Test @@ -201,9 +198,9 @@ public void testDeserializationAsTimestamp01() throws Exception { LocalDateTime value = this.mapper.readValue("[1986,1,17,15,43]", LocalDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); LocalDateTime time = LocalDateTime.of(1986, Month.JANUARY, 17, 15, 43); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value); } @Test @@ -211,9 +208,9 @@ public void testDeserializationAsTimestamp02() throws Exception { LocalDateTime value = this.mapper.readValue("[2013,8,21,9,22,57]", LocalDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 57); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value); } @Test @@ -223,9 +220,9 @@ public void testDeserializationAsTimestamp03Nanoseconds() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2013,8,21,9,22,0,57]"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value); } @Test @@ -235,9 +232,9 @@ public void testDeserializationAsTimestamp03Milliseconds() throws Exception .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2013,8,21,9,22,0,57]"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57000000); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value); } @Test @@ -247,9 +244,9 @@ public void testDeserializationAsTimestamp04Nanoseconds() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2005,11,5,22,31,5,829837]"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829837); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value); } @Test @@ -259,9 +256,9 @@ public void testDeserializationAsTimestamp04Milliseconds01() throws Exception .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2005,11,5,22,31,5,829837]"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829837); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value); } @Test @@ -271,9 +268,9 @@ public void testDeserializationAsTimestamp04Milliseconds02() throws Exception .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2005,11,5,22,31,5,829]"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829000000); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value); } @Test @@ -283,8 +280,8 @@ public void testDeserializationAsString01() throws Exception LocalDateTime value = this.mapper.readValue('"' + time.toString() + '"', LocalDateTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -294,8 +291,8 @@ public void testDeserializationAsString02() throws Exception LocalDateTime value = this.mapper.readValue('"' + time.toString() + '"', LocalDateTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -305,8 +302,8 @@ public void testDeserializationAsString03() throws Exception LocalDateTime value = this.mapper.readValue('"' + time.toString() + '"', LocalDateTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -321,9 +318,9 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,829837]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalDateTime.", value instanceof LocalDateTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertTrue(value instanceof LocalDateTime); + assertEquals(time, value); } @Test @@ -337,9 +334,9 @@ public void testDeserializationWithTypeInfo02() throws Exception "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,422]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalDateTime.", value instanceof LocalDateTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertTrue(value instanceof LocalDateTime); + assertEquals(time, value); } @Test @@ -352,8 +349,8 @@ public void testDeserializationWithTypeInfo03() throws Exception "[\"" + LocalDateTime.class.getName() + "\",\"" + time.toString() + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalDateTime.", value instanceof LocalDateTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertTrue(value instanceof LocalDateTime); + assertEquals(time, value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeKeySerialization.java index b7efe692..10f9d5ed 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestLocalTimeKeySerialization extends ModuleTestBase { @@ -26,7 +27,7 @@ public class TestLocalTimeKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -42,7 +43,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(TIME_0_STRING, "test"), value); + assertEquals(map(TIME_0_STRING, "test"), value); } @Test @@ -51,7 +52,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(TIME_STRING, "test"), value); + assertEquals(map(TIME_STRING, "test"), value); } @Test @@ -59,7 +60,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(TIME_0_STRING, "test"), TYPE_REF); map.put(TIME_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -67,7 +68,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(TIME_STRING, "test"), TYPE_REF); map.put(TIME, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeSerialization.java index 711d071f..b1f37486 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestLocalTimeSerialization.java @@ -16,37 +16,27 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.LocalTime; import java.time.temporal.Temporal; +import org.junit.jupiter.api.*; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestLocalTimeSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); } - @After - public void tearDown() - { - - } - @Test public void testSerializationAsTimestamp01() throws Exception { @@ -55,8 +45,8 @@ public void testSerializationAsTimestamp01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[15,43]", value); + assertNotNull(value); + assertEquals("[15,43]", value); } @Test @@ -67,8 +57,8 @@ public void testSerializationAsTimestamp02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[9,22,57]", value); + assertNotNull(value); + assertEquals("[9,22,57]", value); } @Test @@ -80,8 +70,8 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[9,22,0,57]", value); + assertNotNull(value); + assertEquals("[9,22,0,57]", value); } @Test @@ -93,8 +83,8 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[9,22,0,0]", value); + assertNotNull(value); + assertEquals("[9,22,0,0]", value); } @Test @@ -106,8 +96,8 @@ public void testSerializationAsTimestamp04Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[22,31,5,829837]", value); + assertNotNull(value); + assertEquals("[22,31,5,829837]", value); } @Test @@ -119,8 +109,8 @@ public void testSerializationAsTimestamp04Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[22,31,5,422]", value); + assertNotNull(value); + assertEquals("[22,31,5,422]", value); } @Test @@ -131,8 +121,8 @@ public void testSerializationAsString01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"15:43:20\"", value); + assertNotNull(value); + assertEquals("\"15:43:20\"", value); } @Test @@ -143,8 +133,8 @@ public void testSerializationAsString02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -155,8 +145,8 @@ public void testSerializationAsString03() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -169,8 +159,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"" + LocalTime.class.getName() + "\",[22,31,5,829837]]", value); + assertNotNull(value); + assertEquals("[\"" + LocalTime.class.getName() + "\",[22,31,5,829837]]", value); } @Test @@ -183,8 +173,8 @@ public void testSerializationWithTypeInfo02() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"" + LocalTime.class.getName() + "\",[22,31,5,422]]", value); + assertNotNull(value); + assertEquals("[\"" + LocalTime.class.getName() + "\",[22,31,5,422]]", value); } @Test @@ -196,9 +186,8 @@ public void testSerializationWithTypeInfo03() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + LocalTime.class.getName() + "\",\"" + time.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + LocalTime.class.getName() + "\",\"" + time.toString() + "\"]", value); } @Test @@ -208,8 +197,8 @@ public void testDeserializationAsTimestamp01() throws Exception LocalTime value = this.mapper.readValue("[15,43]", LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -219,8 +208,8 @@ public void testDeserializationAsTimestamp02() throws Exception LocalTime value = this.mapper.readValue("[9,22,57]", LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -231,8 +220,8 @@ public void testDeserializationAsTimestamp03Nanoseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); LocalTime value = this.mapper.readValue("[9,22,0,57]", LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -243,8 +232,8 @@ public void testDeserializationAsTimestamp03Milliseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); LocalTime value = this.mapper.readValue("[9,22,0,57]", LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -255,8 +244,8 @@ public void testDeserializationAsTimestamp04Nanoseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); LocalTime value = this.mapper.readValue("[22,31,5,829837]", LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -267,8 +256,8 @@ public void testDeserializationAsTimestamp04Milliseconds01() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); LocalTime value = this.mapper.readValue("[22,31,5,829837]", LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -279,8 +268,8 @@ public void testDeserializationAsTimestamp04Milliseconds02() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); LocalTime value = this.mapper.readValue("[22,31,5,829]", LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -290,8 +279,8 @@ public void testDeserializationAsString01() throws Exception LocalTime value = this.mapper.readValue('"' + time.toString() + '"', LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -301,8 +290,8 @@ public void testDeserializationAsString02() throws Exception LocalTime value = this.mapper.readValue('"' + time.toString() + '"', LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -312,8 +301,8 @@ public void testDeserializationAsString03() throws Exception LocalTime value = this.mapper.readValue('"' + time.toString() + '"', LocalTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -327,9 +316,9 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + LocalTime.class.getName() + "\",[22,31,5,829837]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalTime.", value instanceof LocalTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertInstanceOf(LocalTime.class, value); + assertEquals(time, value); } @Test @@ -343,9 +332,9 @@ public void testDeserializationWithTypeInfo02() throws Exception "[\"" + LocalTime.class.getName() + "\",[22,31,5,422]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalTime.", value instanceof LocalTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertInstanceOf(LocalTime.class, value); + assertEquals(time, value); } @Test @@ -358,8 +347,8 @@ public void testDeserializationWithTypeInfo03() throws Exception "[\"" + LocalTime.class.getName() + "\",\"" + time.toString() + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalTime.", value instanceof LocalTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertInstanceOf(LocalTime.class, value); + assertEquals(time, value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDayKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDayKeySerialization.java index 9c8145ee..34550857 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDayKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDayKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestMonthDayKeySerialization extends ModuleTestBase { @@ -21,7 +22,7 @@ public class TestMonthDayKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -37,7 +38,7 @@ public void testSerialization() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(MONTH_DAY_STRING, "test"), value); + assertEquals(map(MONTH_DAY_STRING, "test"), value); } @Test @@ -45,7 +46,7 @@ public void testDeserialization() throws Exception { Map value = om.readValue(map(MONTH_DAY_STRING, "test"), TYPE_REF); map.put(MONTH_DAY, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDaySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDaySerialization.java index 15cc2ea7..d7954e35 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDaySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestMonthDaySerialization.java @@ -16,33 +16,27 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Month; import java.time.MonthDay; import java.time.temporal.TemporalAccessor; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestMonthDaySerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); } - @After - public void tearDown() { } - @Test public void testSerialization01() throws Exception { @@ -50,8 +44,8 @@ public void testSerialization01() throws Exception String value = this.mapper.writeValueAsString(monthDay); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"--01-17\"", value); + assertNotNull(value); + assertEquals("\"--01-17\"", value); } @Test @@ -61,8 +55,8 @@ public void testSerialization02() throws Exception String value = this.mapper.writeValueAsString(monthDay); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"--08-21\"", value); + assertNotNull(value); + assertEquals("\"--08-21\"", value); } @Test @@ -73,8 +67,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(TemporalAccessor.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(monthDay); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"" + MonthDay.class.getName() + "\",\"--11-05\"]", value); + assertNotNull(value); + assertEquals("[\"" + MonthDay.class.getName() + "\",\"--11-05\"]", value); } @Test @@ -84,8 +78,8 @@ public void testDeserialization01() throws Exception MonthDay value = this.mapper.readValue("\"--01-17\"", MonthDay.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", monthDay, value); + assertNotNull(value); + assertEquals(monthDay, value); } @Test @@ -95,8 +89,8 @@ public void testDeserialization02() throws Exception MonthDay value = this.mapper.readValue("\"--08-21\"", MonthDay.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", monthDay, value); + assertNotNull(value); + assertEquals(monthDay, value); } @Test @@ -107,8 +101,8 @@ public void testDeserializationWithTypeInfo01() throws Exception this.mapper.addMixIn(TemporalAccessor.class, MockObjectConfiguration.class); TemporalAccessor value = this.mapper.readValue("[\"" + MonthDay.class.getName() + "\",\"--11-05\"]", TemporalAccessor.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a MonthDay.", value instanceof MonthDay); - assertEquals("The value is not correct.", monthDay, value); + assertNotNull(value); + assertInstanceOf(MonthDay.class, value); + assertEquals(monthDay, value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestNullKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestNullKeySerialization.java index 586055ba..763c9f3c 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestNullKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestNullKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestNullKeySerialization extends ModuleTestBase { @SuppressWarnings("deprecation") @@ -21,7 +22,7 @@ public class TestNullKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -35,7 +36,7 @@ public void testSerialization() throws Exception { map.put(null, "test"); String value = om.writeValueAsString(map); - Assert.assertEquals(map(NULL_KEY, "test"), value); + assertEquals(map(NULL_KEY, "test"), value); } @Test @@ -43,7 +44,7 @@ public void testDeserialization() throws Exception { Map value = om.readValue(map(NULL_KEY, "test"), TYPE_REF); map.put(null, "test"); - Assert.assertEquals(map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeKeySerialization.java index b3556ce2..bf062a0d 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeKeySerialization.java @@ -6,12 +6,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestOffsetDateTimeKeySerialization extends ModuleTestBase { @@ -27,7 +28,7 @@ public class TestOffsetDateTimeKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -43,7 +44,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(DATE_TIME_0_STRING, "test"), value); + assertEquals(map(DATE_TIME_0_STRING, "test"), value); } @Test @@ -52,7 +53,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(DATE_TIME_1_STRING, "test"), value); + assertEquals(map(DATE_TIME_1_STRING, "test"), value); } @Test @@ -61,7 +62,7 @@ public void testSerialization2() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(DATE_TIME_2_STRING, "test"), value); + assertEquals(map(DATE_TIME_2_STRING, "test"), value); } @Test @@ -69,7 +70,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(DATE_TIME_0_STRING, "test"), TYPE_REF); map.put(DATE_TIME_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -77,7 +78,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(DATE_TIME_1_STRING, "test"), TYPE_REF); map.put(DATE_TIME_1, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -85,7 +86,7 @@ public void testDeserialization2() throws Exception { Map value = om.readValue(map(DATE_TIME_2_STRING, "test"), TYPE_REF); map.put(DATE_TIME_2, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeSerialization.java index 89d2f478..35b12cfb 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetDateTimeSerialization.java @@ -16,10 +16,6 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; @@ -30,13 +26,15 @@ import java.time.temporal.Temporal; import java.util.TimeZone; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.DecimalUtils; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestOffsetDateTimeSerialization extends ModuleTestBase { @@ -52,7 +50,7 @@ public class TestOffsetDateTimeSerialization extends ModuleTestBase private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -67,8 +65,8 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "0.0", value); + assertNotNull(value); + assertEquals("0.0", value); } @Test @@ -80,8 +78,8 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "0", value); + assertNotNull(value); + assertEquals("0", value); } @Test @@ -93,8 +91,8 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertNotNull(value); + assertEquals("123456789.183917322", value); } @Test @@ -106,8 +104,8 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "123456789183", value); + assertNotNull(value); + assertEquals("123456789183", value); } @Test @@ -119,8 +117,8 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); + assertNotNull(value); + assertEquals(DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); } @Test @@ -131,7 +129,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", Long.toString(date.toInstant().toEpochMilli()), value); + assertEquals(Long.toString(date.toInstant().toEpochMilli()), value); } @Test @@ -141,8 +139,7 @@ public void testSerializationAsString01() throws Exception String value = mapper.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' - + FORMATTER.withZone(Z1).format(date) + '"', value); + assertEquals('"' + FORMATTER.withZone(Z1).format(date) + '"', value); } @Test @@ -152,8 +149,7 @@ public void testSerializationAsString02() throws Exception String value = mapper.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' - + FORMATTER.withZone(Z2).format(date) + '"', value); + assertEquals('"' + FORMATTER.withZone(Z2).format(date) + '"', value); } @Test @@ -163,8 +159,7 @@ public void testSerializationAsString03() throws Exception String value = mapper.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' - + FORMATTER.withZone(Z3).format(date) + '"', value); + assertEquals('"' + FORMATTER.withZone(Z3).format(date) + '"', value); } @Test @@ -175,7 +170,7 @@ public void testSerializationAsStringWithMapperTimeZone01() throws Exception .setTimeZone(TimeZone.getTimeZone(Z1)) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -186,7 +181,7 @@ public void testSerializationAsStringWithMapperTimeZone02() throws Exception .setTimeZone(TimeZone.getTimeZone(Z2)) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -197,7 +192,7 @@ public void testSerializationAsStringWithMapperTimeZone03() throws Exception .setTimeZone(TimeZone.getTimeZone(Z3)) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -209,8 +204,7 @@ public void testSerializationWithTypeInfo01() throws Exception .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true) .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", value); + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", value); } @Test @@ -222,8 +216,7 @@ public void testSerializationWithTypeInfo02() throws Exception .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true) .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",123456789183]", value); + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",123456789183]", value); } @Test @@ -234,8 +227,7 @@ public void testSerializationWithTypeInfo03() throws Exception .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .addMixIn(Temporal.class, MockObjectConfiguration.class) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",\"" + + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER_UTC.withZone(Z3).format(date) + "\"]", value); } @@ -249,8 +241,7 @@ public void testSerializationWithTypeInfoAndMapperTimeZone() throws Exception .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .addMixIn(Temporal.class, MockObjectConfiguration.class) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); } @Test @@ -260,9 +251,9 @@ public void testDeserializationAsFloat01WithoutTimeZone() throws Exception OffsetDateTime value = this.mapper.readValue("0.000000000", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -273,9 +264,9 @@ public void testDeserializationAsFloat01WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue("0.000000000", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -285,9 +276,9 @@ public void testDeserializationAsFloat02WithoutTimeZone() throws Exception OffsetDateTime value = this.mapper.readValue("123456789.183917322", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -298,9 +289,9 @@ public void testDeserializationAsFloat02WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue("123456789.183917322", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -312,9 +303,9 @@ public void testDeserializationAsFloat03WithoutTimeZone() throws Exception DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), OffsetDateTime.class ); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -327,9 +318,9 @@ public void testDeserializationAsFloat03WithTimeZone() throws Exception DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), OffsetDateTime.class ); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -340,9 +331,9 @@ public void testDeserializationAsInt01NanosecondsWithoutTimeZone() throws Except this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetDateTime value = this.mapper.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -354,9 +345,9 @@ public void testDeserializationAsInt01NanosecondsWithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -367,9 +358,9 @@ public void testDeserializationAsInt01MillisecondsWithoutTimeZone() throws Excep this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); OffsetDateTime value = this.mapper.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -381,9 +372,9 @@ public void testDeserializationAsInt01MillisecondsWithTimeZone() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -394,9 +385,9 @@ public void testDeserializationAsInt02NanosecondsWithoutTimeZone() throws Except this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetDateTime value = this.mapper.readValue("123456789", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -408,9 +399,9 @@ public void testDeserializationAsInt02NanosecondsWithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue("123456789", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -421,9 +412,9 @@ public void testDeserializationAsInt02MillisecondsWithoutTimeZone() throws Excep this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); OffsetDateTime value = this.mapper.readValue("123456789422", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -435,9 +426,9 @@ public void testDeserializationAsInt02MillisecondsWithTimeZone() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue("123456789422", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -449,9 +440,9 @@ public void testDeserializationAsInt03NanosecondsWithoutTimeZone() throws Except this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetDateTime value = this.mapper.readValue(Long.toString(date.toEpochSecond()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -464,9 +455,9 @@ public void testDeserializationAsInt03NanosecondsWithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue(Long.toString(date.toEpochSecond()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -479,9 +470,9 @@ public void testDeserializationAsInt03MillisecondsWithoutTimeZone() throws Excep OffsetDateTime value = this.mapper.readValue(Long.toString(date.toInstant().toEpochMilli()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -495,9 +486,9 @@ public void testDeserializationAsInt03MillisecondsWithTimeZone() throws Exceptio OffsetDateTime value = this.mapper.readValue(Long.toString(date.toInstant().toEpochMilli()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -508,9 +499,9 @@ public void testDeserializationAsString01WithoutTimeZone() throws Exception this.mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -522,9 +513,9 @@ public void testDeserializationAsString01WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -536,9 +527,9 @@ public void testDeserializationAsString01WithTimeZoneTurnedOff() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z1), value.getOffset()); + assertEquals(getOffset(value, Z1), value.getOffset(), "The time zone is not correct."); } @Test @@ -549,9 +540,9 @@ public void testDeserializationAsString02WithoutTimeZone() throws Exception this.mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -563,9 +554,9 @@ public void testDeserializationAsString02WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -577,9 +568,9 @@ public void testDeserializationAsString02WithTimeZoneTurnedOff() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z2), value.getOffset()); + assertEquals(getOffset(value, Z2), value.getOffset(), "The time zone is not correct."); } @Test @@ -590,9 +581,9 @@ public void testDeserializationAsString03WithoutTimeZone() throws Exception this.mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -604,9 +595,9 @@ public void testDeserializationAsString03WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -618,9 +609,9 @@ public void testDeserializationAsString03WithTimeZoneTurnedOff() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); OffsetDateTime value = this.mapper.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z3), value.getOffset()); + assertEquals(getOffset(value, Z3), value.getOffset(), "The time zone is not correct."); } @Test @@ -633,10 +624,10 @@ public void testDeserializationWithTypeInfo01WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -650,10 +641,10 @@ public void testDeserializationWithTypeInfo01WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -667,10 +658,10 @@ public void testDeserializationWithTypeInfo02WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -685,10 +676,10 @@ public void testDeserializationWithTypeInfo02WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -702,10 +693,10 @@ public void testDeserializationWithTypeInfo03WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789422]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -720,10 +711,10 @@ public void testDeserializationWithTypeInfo03WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789422]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -737,10 +728,10 @@ public void testDeserializationWithTypeInfo04WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -755,10 +746,10 @@ public void testDeserializationWithTypeInfo04WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -773,17 +764,17 @@ public void testDeserializationWithTypeInfo04WithTimeZoneTurnedOff() throws Exce "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); OffsetDateTime cast = (OffsetDateTime) value; assertIsEqual(date, cast); - assertEquals("The time zone is not correct.", getOffset(cast, Z3), cast.getOffset()); + assertEquals(getOffset(cast, Z3), cast.getOffset(), "The time zone is not correct."); } private static void assertIsEqual(OffsetDateTime expected, OffsetDateTime actual) { - assertTrue("The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">.", - expected.isEqual(actual)); + assertTrue(expected.isEqual(actual), + "The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">."); } private static ZoneOffset getDefaultOffset(OffsetDateTime date) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeKeySerialization.java index 577a6760..daed6941 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeKeySerialization.java @@ -5,12 +5,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestOffsetTimeKeySerialization extends ModuleTestBase { @@ -26,7 +27,7 @@ public class TestOffsetTimeKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -42,7 +43,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals(map(TIME_0_STRING, "test"), value); + assertEquals(map(TIME_0_STRING, "test"), value); } @Test @@ -51,7 +52,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(TIME_1_STRING, "test"), value); + assertEquals(map(TIME_1_STRING, "test"), value); } @Test @@ -60,7 +61,7 @@ public void testSerialization2() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(TIME_2_STRING, "test"), value); + assertEquals(map(TIME_2_STRING, "test"), value); } @Test @@ -68,7 +69,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(TIME_0_STRING, "test"), TYPE_REF); map.put(TIME_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -76,7 +77,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(TIME_1_STRING, "test"), TYPE_REF); map.put(TIME_1, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -84,7 +85,7 @@ public void testDeserialization2() throws Exception { Map value = om.readValue(map(TIME_2_STRING, "test"), TYPE_REF); map.put(TIME_2, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeSerialization.java index 169197ed..0b9a32ed 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestOffsetTimeSerialization.java @@ -16,26 +16,24 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.OffsetTime; import java.time.ZoneOffset; import java.time.temporal.Temporal; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestOffsetTimeSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -49,8 +47,8 @@ public void testSerializationAsTimestamp01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[15,43,\"+03:00\"]", value); + assertNotNull(value); + assertEquals("[15,43,\"+03:00\"]", value); } @Test @@ -61,8 +59,8 @@ public void testSerializationAsTimestamp02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[9,22,57,\"-06:30\"]", value); + assertNotNull(value); + assertEquals("[9,22,57,\"-06:30\"]", value); } @Test @@ -74,8 +72,8 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[9,22,0,57,\"-06:30\"]", value); + assertNotNull(value); + assertEquals("[9,22,0,57,\"-06:30\"]", value); } @Test @@ -87,8 +85,8 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[9,22,0,0,\"-06:30\"]", value); + assertNotNull(value); + assertEquals("[9,22,0,0,\"-06:30\"]", value); } @Test @@ -100,8 +98,8 @@ public void testSerializationAsTimestamp04Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[22,31,5,829837,\"+11:00\"]", value); + assertNotNull(value); + assertEquals("[22,31,5,829837,\"+11:00\"]", value); } @Test @@ -113,8 +111,8 @@ public void testSerializationAsTimestamp04Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[22,31,5,422,\"+11:00\"]", value); + assertNotNull(value); + assertEquals("[22,31,5,422,\"+11:00\"]", value); } @Test @@ -125,8 +123,8 @@ public void testSerializationAsString01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -137,8 +135,8 @@ public void testSerializationAsString02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -149,8 +147,8 @@ public void testSerializationAsString03() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -163,9 +161,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + OffsetTime.class.getName() + "\",[22,31,5,829837,\"+11:00\"]]", value); + assertNotNull(value); + assertEquals("[\"" + OffsetTime.class.getName() + "\",[22,31,5,829837,\"+11:00\"]]", value); } @Test @@ -178,9 +175,8 @@ public void testSerializationWithTypeInfo02() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + OffsetTime.class.getName() + "\",[22,31,5,422,\"+11:00\"]]", value); + assertNotNull(value); + assertEquals("[\"" + OffsetTime.class.getName() + "\",[22,31,5,422,\"+11:00\"]]", value); } @Test @@ -192,9 +188,8 @@ public void testSerializationWithTypeInfo03() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + OffsetTime.class.getName() + "\",\"" + time.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + OffsetTime.class.getName() + "\",\"" + time.toString() + "\"]", value); } @Test @@ -204,8 +199,8 @@ public void testDeserializationAsTimestamp01() throws Exception OffsetTime value = this.mapper.readValue("[15,43,\"+0300\"]", OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -215,8 +210,8 @@ public void testDeserializationAsTimestamp02() throws Exception OffsetTime value = this.mapper.readValue("[9,22,57,\"-06:30\"]", OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -227,8 +222,8 @@ public void testDeserializationAsTimestamp03Nanoseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetTime value = this.mapper.readValue("[9,22,0,57,\"-06:30\"]", OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -239,8 +234,8 @@ public void testDeserializationAsTimestamp03Milliseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); OffsetTime value = this.mapper.readValue("[9,22,0,57,\"-06:30\"]", OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -251,8 +246,8 @@ public void testDeserializationAsTimestamp04Nanoseconds() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetTime value = this.mapper.readValue("[22,31,5,829837,\"+11:00\"]", OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -263,8 +258,8 @@ public void testDeserializationAsTimestamp04Milliseconds01() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); OffsetTime value = this.mapper.readValue("[22,31,5,829837,\"+11:00\"]", OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -275,8 +270,8 @@ public void testDeserializationAsTimestamp04Milliseconds02() throws Exception this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); OffsetTime value = this.mapper.readValue("[22,31,5,829,\"+11:00\"]", OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -286,8 +281,8 @@ public void testDeserializationAsString01() throws Exception OffsetTime value = this.mapper.readValue('"' + time.toString() + '"', OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -297,8 +292,8 @@ public void testDeserializationAsString02() throws Exception OffsetTime value = this.mapper.readValue('"' + time.toString() + '"', OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -308,8 +303,8 @@ public void testDeserializationAsString03() throws Exception OffsetTime value = this.mapper.readValue('"' + time.toString() + '"', OffsetTime.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertEquals(time, value); } @Test @@ -323,9 +318,9 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + OffsetTime.class.getName() + "\",[22,31,5,829837,\"+11:00\"]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a OffsetTime.", value instanceof OffsetTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertInstanceOf(OffsetTime.class, value, "The value should be a OffsetTime."); + assertEquals(time, value); } @Test @@ -339,9 +334,9 @@ public void testDeserializationWithTypeInfo02() throws Exception "[\"" + OffsetTime.class.getName() + "\",[22,31,5,422,\"+11:00\"]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a OffsetTime.", value instanceof OffsetTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertInstanceOf(OffsetTime.class, value, "The value should be a OffsetTime."); + assertEquals(time, value); } @Test @@ -354,8 +349,8 @@ public void testDeserializationWithTypeInfo03() throws Exception "[\"" + OffsetTime.class.getName() + "\",\"" + time.toString() + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a OffsetTime.", value instanceof OffsetTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value); + assertInstanceOf(OffsetTime.class, value, "The value should be a OffsetTime."); + assertEquals(time, value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodKeySerialization.java index de5f9ec0..e6e0e567 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestPeriodKeySerialization extends ModuleTestBase { @@ -23,7 +24,7 @@ public class TestPeriodKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -39,7 +40,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(PERIOD_0_STRING, "test"), value); + assertEquals(map(PERIOD_0_STRING, "test"), value); } @Test @@ -48,7 +49,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(PERIOD_STRING, "test"), value); + assertEquals(map(PERIOD_STRING, "test"), value); } @Test @@ -56,7 +57,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(PERIOD_0_STRING, "test"), TYPE_REF); map.put(PERIOD_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -64,7 +65,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(PERIOD_STRING, "test"), TYPE_REF); map.put(PERIOD, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodSerialization.java index 4d362efd..5b77e414 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestPeriodSerialization.java @@ -16,32 +16,26 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Period; import java.time.temporal.TemporalAmount; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestPeriodSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); } - @After - public void tearDown() { } - @Test public void testSerialization01() throws Exception { @@ -49,8 +43,8 @@ public void testSerialization01() throws Exception String value = this.mapper.writeValueAsString(period); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + period.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + period.toString() + '"', value); } @Test @@ -60,8 +54,8 @@ public void testSerialization02() throws Exception String value = this.mapper.writeValueAsString(period); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + period.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + period.toString() + '"', value); } @Test @@ -72,9 +66,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(period); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + Period.class.getName() + "\",\"" + period.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + Period.class.getName() + "\",\"" + period.toString() + "\"]", value); } @Test @@ -84,8 +77,8 @@ public void testDeserialization01() throws Exception Period value = this.mapper.readValue('"' + period.toString() + '"', Period.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", period, value); + assertNotNull(value); + assertEquals(period, value); } @Test @@ -95,8 +88,8 @@ public void testDeserialization02() throws Exception Period value = this.mapper.readValue('"' + period.toString() + '"', Period.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", period, value); + assertNotNull(value); + assertEquals(period, value); } @Test @@ -109,8 +102,8 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + Period.class.getName() + "\",\"" + period.toString() + "\"]", TemporalAmount.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a Period.", value instanceof Period); - assertEquals("The value is not correct.", period, value); + assertNotNull(value); + assertInstanceOf(Period.class, value, "The value should be a Period."); + assertEquals(period, value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearKeySerialization.java index ee9f0919..8574d2d2 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestYearKeySerialization extends ModuleTestBase { @@ -18,7 +19,7 @@ public class TestYearKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -34,7 +35,7 @@ public void testSerialization() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map("3141", "test"), value); + assertEquals(map("3141", "test"), value); } @Test @@ -42,7 +43,7 @@ public void testDeserialization() throws Exception { Map value = om.readValue(map("3141", "test"), TYPE_REF); map.put(Year.of(3141), "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthKeySerialization.java index 00e16599..9dda0745 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestYearMonthKeySerialization extends ModuleTestBase { @@ -19,7 +20,7 @@ public class TestYearMonthKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -35,7 +36,7 @@ public void testSerialization() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map("3141-05", "test"), value); + assertEquals(map("3141-05", "test"), value); } @Test @@ -43,7 +44,7 @@ public void testDeserialization() throws Exception { Map value = om.readValue(map("3141-05", "test"), TYPE_REF); map.put(YearMonth.of(3141, 5), "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthSerialization.java index 110baec5..fd7c1996 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearMonthSerialization.java @@ -16,28 +16,26 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Month; import java.time.YearMonth; import java.time.temporal.Temporal; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestYearMonthSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -51,8 +49,8 @@ public void testSerializationAsTimestamp01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[1986,1]", value); + assertNotNull(value); + assertEquals("[1986,1]", value); } @Test @@ -63,8 +61,8 @@ public void testSerializationAsTmestamp02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String value = this.mapper.writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2013,8]", value); + assertNotNull(value); + assertEquals("[2013,8]", value); } @Test @@ -75,8 +73,8 @@ public void testSerializationAsString01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + yearMonth.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + yearMonth.toString() + '"', value); } @Test @@ -87,8 +85,8 @@ public void testSerializationAsString02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + yearMonth.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + yearMonth.toString() + '"', value); } @Test @@ -100,9 +98,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + YearMonth.class.getName() + "\",\"" + yearMonth.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + YearMonth.class.getName() + "\",\"" + yearMonth.toString() + "\"]", value); } @Test @@ -113,8 +110,8 @@ public void testDeserializationAsTimestamp01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); YearMonth value = this.mapper.readValue("[1986,1]", YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -125,8 +122,8 @@ public void testDeserializationAsTimestamp02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); YearMonth value = this.mapper.readValue("[2013,8]", YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -137,8 +134,8 @@ public void testDeserializationAsString01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); YearMonth value = this.mapper.readValue('"' + yearMonth.toString() + '"', YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -149,8 +146,8 @@ public void testDeserializationAsString02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); YearMonth value = this.mapper.readValue('"' + yearMonth.toString() + '"', YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -161,9 +158,9 @@ public void testDeserializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue("[\"" + YearMonth.class.getName() + "\",\"" + yearMonth.toString() + "\"]", Temporal.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a YearMonth.", value instanceof YearMonth); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertInstanceOf(YearMonth.class, value, "The value should be a YearMonth."); + assertEquals(yearMonth, value); } private static class SimpleAggregate @@ -187,8 +184,8 @@ public void testSerializationWithPattern01() throws Exception String value = this.mapper.writeValueAsString(simpleAggregate); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "{\"yearMonth\":\"1308\"}", value); + assertNotNull(value); + assertEquals("{\"yearMonth\":\"1308\"}", value); } @Test @@ -199,7 +196,7 @@ public void testDeserializationWithPattern01() throws Exception SimpleAggregate value = this.mapper.readValue("{\"yearMonth\":\"1308\"}", SimpleAggregate.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", simpleAggregate.yearMonth, value.yearMonth); + assertNotNull(value); + assertEquals(simpleAggregate.yearMonth, value.yearMonth); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearSerialization.java index 371596ee..e493d60e 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestYearSerialization.java @@ -16,23 +16,21 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Year; import java.time.temporal.Temporal; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestYearSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -45,8 +43,8 @@ public void testSerialization01() throws Exception String value = this.mapper.writeValueAsString(year); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "1986", value); + assertNotNull(value); + assertEquals("1986", value); } @Test @@ -56,8 +54,8 @@ public void testSerialization02() throws Exception String value = this.mapper.writeValueAsString(year); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "2013", value); + assertNotNull(value); + assertEquals("2013", value); } @Test @@ -68,8 +66,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(year); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"" + Year.class.getName() + "\",2005]", value); + assertNotNull(value); + assertEquals("[\"" + Year.class.getName() + "\",2005]", value); } @Test @@ -77,8 +75,8 @@ public void testDeserialization01() throws Exception { Year value = this.mapper.readValue("1986", Year.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Year.of(1986), value); + assertNotNull(value); + assertEquals(Year.of(1986), value); } @Test @@ -86,8 +84,8 @@ public void testDeserialization02() throws Exception { Year value = this.mapper.readValue("2013", Year.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Year.of(2013), value); + assertNotNull(value); + assertEquals(Year.of(2013), value); } @Test @@ -96,8 +94,8 @@ public void testDeserializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue("[\"" + Year.class.getName() + "\",2005]", Temporal.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a Year.", value instanceof Year); - assertEquals("The value is not correct.", Year.of(2005), value); + assertNotNull(value); + assertInstanceOf(Year.class, value, "The value should be a Year."); + assertEquals(Year.of(2005), value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdKeySerialization.java index 289192b0..268149fb 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestZoneIdKeySerialization extends ModuleTestBase { @@ -25,7 +26,7 @@ public class TestZoneIdKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -41,7 +42,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(ZONE_0_STRING, "test"), value); + assertEquals(map(ZONE_0_STRING, "test"), value); } @Test @@ -50,7 +51,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(ZONE_1_STRING, "test"), value); + assertEquals(map(ZONE_1_STRING, "test"), value); } @Test @@ -59,7 +60,7 @@ public void testSerialization2() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(ZONE_2_STRING, "test"), value); + assertEquals(map(ZONE_2_STRING, "test"), value); } @Test @@ -67,7 +68,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(ZONE_0_STRING, "test"), TYPE_REF); map.put(ZONE_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -75,7 +76,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(ZONE_1_STRING, "test"), TYPE_REF); map.put(ZONE_1, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -83,7 +84,7 @@ public void testDeserialization2() throws Exception { Map value = om.readValue(map(ZONE_2_STRING, "test"), TYPE_REF); map.put(ZONE_2, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdSerialization.java index 8c6f1f1f..ce5c3056 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneIdSerialization.java @@ -16,21 +16,20 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.ZoneId; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestZoneIdSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -43,8 +42,8 @@ public void testSerialization01() throws Exception String value = this.mapper.writeValueAsString(id); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"America/Chicago\"", value); + assertNotNull(value); + assertEquals("\"America/Chicago\"", value); } @Test @@ -54,8 +53,8 @@ public void testSerialization02() throws Exception String value = this.mapper.writeValueAsString(id); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"America/Anchorage\"", value); + assertNotNull(value); + assertEquals("\"America/Anchorage\"", value); } @Test @@ -66,8 +65,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(ZoneId.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(id); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"java.time.ZoneId\",\"America/Denver\"]", value); + assertNotNull(value); + assertEquals("[\"java.time.ZoneId\",\"America/Denver\"]", value); } @Test @@ -75,8 +74,8 @@ public void testDeserialization01() throws Exception { ZoneId value = this.mapper.readValue("\"America/Chicago\"", ZoneId.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", ZoneId.of("America/Chicago"), value); + assertNotNull(value); + assertEquals(ZoneId.of("America/Chicago"), value); } @Test @@ -84,8 +83,8 @@ public void testDeserialization02() throws Exception { ZoneId value = this.mapper.readValue("\"America/Anchorage\"", ZoneId.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", ZoneId.of("America/Anchorage"), value); + assertNotNull(value); + assertEquals(ZoneId.of("America/Anchorage"), value); } @Test @@ -94,7 +93,7 @@ public void testDeserializationWithTypeInfo02() throws Exception this.mapper.addMixIn(ZoneId.class, MockObjectConfiguration.class); ZoneId value = this.mapper.readValue("[\"" + ZoneId.class.getName() + "\",\"America/Denver\"]", ZoneId.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", ZoneId.of("America/Denver"), value); + assertNotNull(value); + assertEquals(ZoneId.of("America/Denver"), value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetKeySerialization.java index b9e2d00e..b034056e 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetKeySerialization.java @@ -4,12 +4,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestZoneOffsetKeySerialization extends ModuleTestBase { @@ -23,7 +24,7 @@ public class TestZoneOffsetKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -39,7 +40,7 @@ public void testSerialization0() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(OFFSET_0_STRING, "test"), value); + assertEquals(map(OFFSET_0_STRING, "test"), value); } @Test @@ -48,7 +49,7 @@ public void testSerialization1() throws Exception { String value = om.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(OFFSET_1_STRING, "test"), value); + assertEquals(map(OFFSET_1_STRING, "test"), value); } @Test @@ -56,7 +57,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(OFFSET_0_STRING, "test"), TYPE_REF); map.put(OFFSET_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -64,7 +65,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(OFFSET_1_STRING, "test"), TYPE_REF); map.put(OFFSET_1, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetSerialization.java index c526c66f..63596cd0 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZoneOffsetSerialization.java @@ -16,23 +16,21 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.ZoneId; import java.time.ZoneOffset; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestZoneOffsetSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); @@ -45,8 +43,8 @@ public void testSerialization01() throws Exception String value = this.mapper.writeValueAsString(offset); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"Z\"", value); + assertNotNull(value); + assertEquals("\"Z\"", value); } @Test @@ -56,8 +54,8 @@ public void testSerialization02() throws Exception String value = this.mapper.writeValueAsString(offset); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"+03:00\"", value); + assertNotNull(value); + assertEquals("\"+03:00\"", value); } @Test @@ -67,8 +65,8 @@ public void testSerialization03() throws Exception String value = this.mapper.writeValueAsString(offset); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"-06:30\"", value); + assertNotNull(value); + assertEquals("\"-06:30\"", value); } @Test @@ -79,8 +77,8 @@ public void testSerializationWithTypeInfo03() throws Exception this.mapper.addMixIn(ZoneId.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(offset); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[\"" + ZoneOffset.class.getName() + "\",\"+04:15\"]", value); + assertNotNull(value); + assertEquals("[\"" + ZoneOffset.class.getName() + "\",\"+04:15\"]", value); } @Test @@ -88,8 +86,8 @@ public void testDeserialization01() throws Exception { ZoneOffset value = this.mapper.readValue("\"Z\"", ZoneOffset.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", ZoneOffset.of("Z"), value); + assertNotNull(value); + assertEquals(ZoneOffset.of("Z"), value); } @Test @@ -97,8 +95,8 @@ public void testDeserialization02() throws Exception { ZoneOffset value = this.mapper.readValue("\"+0300\"", ZoneOffset.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", ZoneOffset.of("+0300"), value); + assertNotNull(value); + assertEquals(ZoneOffset.of("+0300"), value); } @Test @@ -106,8 +104,8 @@ public void testDeserialization03() throws Exception { ZoneOffset value = this.mapper.readValue("\"-06:30\"", ZoneOffset.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", ZoneOffset.of("-0630"), value); + assertNotNull(value); + assertEquals(ZoneOffset.of("-0630"), value); } @Test @@ -116,8 +114,8 @@ public void testDeserializationWithTypeInfo03() throws Exception this.mapper.addMixIn(ZoneId.class, MockObjectConfiguration.class); ZoneId value = this.mapper.readValue("[\"" + ZoneOffset.class.getName() + "\",\"+0415\"]", ZoneId.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a ZoneOffset.", value instanceof ZoneOffset); - assertEquals("The value is not correct.", ZoneOffset.of("+0415"), value); + assertNotNull(value); + assertInstanceOf(ZoneOffset.class, value); + assertEquals(ZoneOffset.of("+0415"), value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeKeySerialization.java index 0c1e4cac..23c951c6 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeKeySerialization.java @@ -7,12 +7,13 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestZonedDateTimeKeySerialization extends ModuleTestBase { @@ -37,7 +38,7 @@ public class TestZonedDateTimeKeySerialization extends ModuleTestBase { private ObjectMapper om; private Map map; - @Before + @BeforeEach public void setUp() { this.om = newMapper(); map = new HashMap<>(); @@ -53,7 +54,7 @@ public void testSerialization0() throws Exception { String value = om.writerFor(TYPE_REF).writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(DATE_TIME_0_STRING, "test"), value); + assertEquals(map(DATE_TIME_0_STRING, "test"), value); } @Test @@ -62,7 +63,7 @@ public void testSerialization1() throws Exception { String value = om.writerFor(TYPE_REF).writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(DATE_TIME_1_STRING, "test"), value); + assertEquals(map(DATE_TIME_1_STRING, "test"), value); } @Test @@ -71,7 +72,7 @@ public void testSerialization2() throws Exception { String value = om.writerFor(TYPE_REF).writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(DATE_TIME_2_STRING, "test"), value); + assertEquals(map(DATE_TIME_2_STRING, "test"), value); } @Test @@ -79,7 +80,7 @@ public void testDeserialization0() throws Exception { Map value = om.readValue(map(DATE_TIME_0_STRING, "test"), TYPE_REF); map.put(DATE_TIME_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -87,7 +88,7 @@ public void testDeserialization1() throws Exception { Map value = om.readValue(map(DATE_TIME_1_STRING, "test"), TYPE_REF); map.put(DATE_TIME_1, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -95,7 +96,7 @@ public void testDeserialization2() throws Exception { Map value = om.readValue(map(DATE_TIME_2_STRING, "test"), TYPE_REF); map.put(DATE_TIME_2_OFFSET, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeSerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeSerialization.java index 188092fa..49c8a3c7 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeSerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/old/TestZonedDateTimeSerialization.java @@ -16,10 +16,6 @@ package com.fasterxml.jackson.datatype.jsr310.old; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Instant; import java.time.ZoneId; import java.time.ZoneOffset; @@ -29,14 +25,15 @@ import java.time.temporal.Temporal; import java.util.TimeZone; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.DecimalUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class TestZonedDateTimeSerialization extends ModuleTestBase { private static final ZoneId Z1 = ZoneId.of("America/Chicago"); @@ -51,18 +48,12 @@ public class TestZonedDateTimeSerialization extends ModuleTestBase { private ObjectMapper mapper; - @Before + @BeforeEach public void setUp() { this.mapper = newMapper(); } - @After - public void tearDown() - { - - } - @Test public void testSerializationAsTimestamp01Nanoseconds() throws Exception { @@ -72,8 +63,8 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "0.0", value); + assertNotNull(value); + assertEquals("0.0", value); } @Test @@ -85,8 +76,8 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "0", value); + assertNotNull(value); + assertEquals("0", value); } @Test @@ -98,8 +89,8 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertNotNull(value); + assertEquals("123456789.183917322", value); } @Test @@ -111,8 +102,8 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "123456789183", value); + assertNotNull(value); + assertEquals("123456789183", value); } @Test @@ -124,8 +115,8 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); + assertNotNull(value); + assertEquals(DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); } @Test @@ -137,8 +128,8 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", Long.toString(date.toInstant().toEpochMilli()), value); + assertNotNull(value); + assertEquals(Long.toString(date.toInstant().toEpochMilli()), value); } @Test @@ -149,8 +140,8 @@ public void testSerializationAsString01() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + date.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + date.toString() + '"', value); } @Test @@ -161,8 +152,8 @@ public void testSerializationAsString02() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + date.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + date.toString() + '"', value); } @Test @@ -173,8 +164,8 @@ public void testSerializationAsString03() throws Exception this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + date.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + date.toString() + '"', value); } @Test @@ -186,7 +177,7 @@ public void testSerializationAsStringWithZoneIdOff() throws Exception { String value = mapper.writeValueAsString(date); - assertEquals("The value is incorrect", "\"" + date.toString() + "\"", value); + assertEquals("\"" + date.toString() + "\"", value); } @Test @@ -199,9 +190,8 @@ public void testSerializationWithTypeInfo01() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", value); + assertNotNull(value); + assertEquals("[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", value); } @Test @@ -214,9 +204,8 @@ public void testSerializationWithTypeInfo02() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + ZonedDateTime.class.getName() + "\",123456789183]", value); + assertNotNull(value); + assertEquals("[\"" + ZonedDateTime.class.getName() + "\",123456789183]", value); } @Test @@ -228,9 +217,8 @@ public void testSerializationWithTypeInfo03() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = this.mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + ZonedDateTime.class.getName() + "\",\"" + date.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + ZonedDateTime.class.getName() + "\",\"" + date.toString() + "\"]", value); } @Test @@ -240,9 +228,9 @@ public void testDeserializationAsFloat01WithoutTimeZone() throws Exception ZonedDateTime value = this.mapper.readValue("0.000000000", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -253,9 +241,9 @@ public void testDeserializationAsFloat01WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue("0.000000000", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -265,9 +253,9 @@ public void testDeserializationAsFloat02WithoutTimeZone() throws Exception ZonedDateTime value = this.mapper.readValue("123456789.183917322", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -278,9 +266,9 @@ public void testDeserializationAsFloat02WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue("123456789.183917322", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -290,11 +278,11 @@ public void testDeserializationAsFloat03WithoutTimeZone() throws Exception ZonedDateTime value = this.mapper.readValue( DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), ZonedDateTime.class - ); + ); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -305,11 +293,11 @@ public void testDeserializationAsFloat03WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue( DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), ZonedDateTime.class - ); + ); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -320,9 +308,9 @@ public void testDeserializationAsInt01NanosecondsWithoutTimeZone() throws Except this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); ZonedDateTime value = this.mapper.readValue("0", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -334,9 +322,9 @@ public void testDeserializationAsInt01NanosecondsWithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue("0", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -347,9 +335,9 @@ public void testDeserializationAsInt01MillisecondsWithoutTimeZone() throws Excep this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); ZonedDateTime value = this.mapper.readValue("0", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -361,9 +349,9 @@ public void testDeserializationAsInt01MillisecondsWithTimeZone() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue("0", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -374,9 +362,9 @@ public void testDeserializationAsInt02NanosecondsWithoutTimeZone() throws Except this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); ZonedDateTime value = this.mapper.readValue("123456789", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -388,9 +376,9 @@ public void testDeserializationAsInt02NanosecondsWithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue("123456789", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -401,9 +389,9 @@ public void testDeserializationAsInt02MillisecondsWithoutTimeZone() throws Excep this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); ZonedDateTime value = this.mapper.readValue("123456789422", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -415,9 +403,9 @@ public void testDeserializationAsInt02MillisecondsWithTimeZone() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue("123456789422", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -429,9 +417,9 @@ public void testDeserializationAsInt03NanosecondsWithoutTimeZone() throws Except this.mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); ZonedDateTime value = this.mapper.readValue(Long.toString(date.toEpochSecond()), ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -444,9 +432,9 @@ public void testDeserializationAsInt03NanosecondsWithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue(Long.toString(date.toEpochSecond()), ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -459,9 +447,9 @@ public void testDeserializationAsInt03MillisecondsWithoutTimeZone() throws Excep ZonedDateTime value = this.mapper.readValue(Long.toString(date.toInstant().toEpochMilli()), ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -475,9 +463,9 @@ public void testDeserializationAsInt03MillisecondsWithTimeZone() throws Exceptio ZonedDateTime value = this.mapper.readValue(Long.toString(date.toInstant().toEpochMilli()), ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -488,9 +476,9 @@ public void testDeserializationAsString01WithoutTimeZone() throws Exception this.mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -502,9 +490,9 @@ public void testDeserializationAsString01WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -516,9 +504,9 @@ public void testDeserializationAsString01WithTimeZoneTurnedOff() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", Z1, value.getZone()); + assertEquals(Z1, value.getZone(), "The time zone is not correct."); } @Test @@ -529,9 +517,9 @@ public void testDeserializationAsString02WithoutTimeZone() throws Exception this.mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -543,9 +531,9 @@ public void testDeserializationAsString02WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -557,9 +545,9 @@ public void testDeserializationAsString02WithTimeZoneTurnedOff() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", Z2, value.getZone()); + assertEquals(Z2, value.getZone(), "The time zone is not correct."); } @Test @@ -570,9 +558,9 @@ public void testDeserializationAsString03WithoutTimeZone() throws Exception this.mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -584,9 +572,9 @@ public void testDeserializationAsString03WithTimeZone() throws Exception this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -598,9 +586,9 @@ public void testDeserializationAsString03WithTimeZoneTurnedOff() throws Exceptio this.mapper.setTimeZone(TimeZone.getDefault()); ZonedDateTime value = this.mapper.readValue('"' + date.toString() + '"', ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", Z3, value.getZone()); + assertEquals(Z3, value.getZone(), "The time zone is not correct."); } @Test @@ -611,12 +599,12 @@ public void testDeserializationWithTypeInfo01WithoutTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -628,12 +616,12 @@ public void testDeserializationWithTypeInfo01WithTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -645,12 +633,12 @@ public void testDeserializationWithTypeInfo02WithoutTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -663,12 +651,12 @@ public void testDeserializationWithTypeInfo02WithTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -680,12 +668,12 @@ public void testDeserializationWithTypeInfo03WithoutTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789422]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -698,12 +686,12 @@ public void testDeserializationWithTypeInfo03WithTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789422]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -715,12 +703,12 @@ public void testDeserializationWithTypeInfo04WithoutTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",\"" + date.toString() + "\"]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -733,12 +721,12 @@ public void testDeserializationWithTypeInfo04WithTimeZone() throws Exception this.mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = this.mapper.readValue( "[\"" + ZonedDateTime.class.getName() + "\",\"" + date.toString() + "\"]", Temporal.class - ); + ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -753,15 +741,16 @@ public void testDeserializationWithTypeInfo04WithTimeZoneTurnedOff() throws Exce "[\"" + ZonedDateTime.class.getName() + "\",\"" + date.toString() + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", Z3, ((ZonedDateTime) value).getZone()); + assertEquals(Z3, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } private static void assertIsEqual(ZonedDateTime expected, ZonedDateTime actual) { - assertTrue("The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">.", - expected.isEqual(actual)); + assertTrue(expected.isEqual(actual), + "The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">."); } } + From 0b949e8f7ad4ec904a28b15584f4a28f60fb4130 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Tue, 28 Jan 2025 08:37:57 +0900 Subject: [PATCH 013/140] [JSTEP-10] Migrate remaining `datetime` module tests to JUnit 5 (#348) --- datetime/pom.xml | 7 - .../datatype/jsr310/ModuleTestBase.java | 3 + .../datatype/jsr310/TestDecimalUtils.java | 37 ++-- .../jackson/datatype/jsr310/TestFeatures.java | 17 +- .../jsr310/deser/DefaultTypingTest.java | 6 +- .../jsr310/deser/DurationDeserTest.java | 80 ++++---- .../jsr310/deser/InstantDeserTest.java | 71 ++++--- .../jsr310/deser/LocalDateDeserTest.java | 100 +++++---- .../jsr310/deser/LocalDateTimeDeserTest.java | 116 ++++++----- .../jsr310/deser/LocalTimeDeserTest.java | 68 +++--- .../jsr310/deser/MonthDayDeserTest.java | 24 +-- .../jsr310/deser/OffsetDateTimeDeserTest.java | 184 ++++++++--------- .../jsr310/deser/OffsetTimeDeserTest.java | 98 +++++---- .../jsr310/deser/OneBasedMonthDeserTest.java | 10 +- .../jsr310/deser/PeriodDeserTest.java | 23 +-- .../datatype/jsr310/deser/YearDeserTest.java | 24 +-- .../jsr310/deser/YearMonthDeserTest.java | 19 +- .../jsr310/deser/ZoneIdDeserTest.java | 26 +-- .../jsr310/deser/ZoneOffsetDeserTest.java | 31 ++- .../jsr310/deser/ZonedDateTimeDeserTest.java | 64 +++--- .../key/ZonedDateTimeKeyDeserializerTest.java | 9 +- .../jsr310/failing/DurationDeser337Test.java | 4 +- .../failing/InstanceViaBigDecimal307Test.java | 4 +- .../failing/JDKSerializabilityTest.java | 4 +- .../failing/OffsetDateTimeDeser279Test.java | 4 +- .../failing/ZonedDateTimeIssue244Test.java | 5 +- .../jsr310/key/DurationAsKeyTest.java | 11 +- .../datatype/jsr310/key/InstantAsKeyTest.java | 15 +- .../jsr310/key/LocalDateAsKeyTest.java | 11 +- .../jsr310/key/LocalDateTimeAsKeyTest.java | 14 +- .../jsr310/key/LocalTimeAsKeyTest.java | 17 +- .../jsr310/key/MonthDayAsKeyTest.java | 13 +- .../jsr310/key/OffsetDateTimeAsKeyTest.java | 31 +-- .../jsr310/key/OffsetTimeAsKeyTest.java | 32 +-- .../datatype/jsr310/key/PeriodAsKeyTest.java | 25 ++- .../jsr310/key/TestNullKeySerialization.java | 10 +- .../datatype/jsr310/key/YearAsKeyTest.java | 34 +-- .../jsr310/key/YearMonthAsKeyTest.java | 15 +- .../datatype/jsr310/key/ZoneIdAsKeyTest.java | 17 +- .../jsr310/key/ZoneOffsetAsKeyTest.java | 17 +- .../jsr310/key/ZonedDateTimeAsKeyTest.java | 22 +- .../jsr310/misc/DateTimeExceptionTest.java | 4 +- .../jsr310/misc/DateTimeSchemasTest.java | 25 +-- .../DeductionTypeSerialization296Test.java | 19 +- .../jsr310/misc/UnsupportedTypesTest.java | 7 +- .../datatype/jsr310/ser/DurationSerTest.java | 13 +- .../datatype/jsr310/ser/InstantSerTest.java | 35 ++-- .../datatype/jsr310/ser/LocalDateSerTest.java | 28 ++- .../jsr310/ser/LocalDateTimeSerTest.java | 39 ++-- .../datatype/jsr310/ser/LocalTimeSerTest.java | 51 +++-- .../datatype/jsr310/ser/MonthDaySerTest.java | 10 +- .../jsr310/ser/OffsetDateTimeSerTest.java | 46 ++--- .../jsr310/ser/OffsetTimeSerTest.java | 33 ++- .../jsr310/ser/OneBasedMonthSerTest.java | 6 +- .../datatype/jsr310/ser/PeriodSerTest.java | 9 +- ...lDateSerializationWithCustomFormatter.java | 58 +++--- ...eTimeSerializationWithCustomFormatter.java | 45 ++-- ...lTimeSerializationWithCustomFormatter.java | 52 ++--- ...MonthSerializationWithCustomFormatter.java | 51 ++--- ...tYearSerializationWithCustomFormatter.java | 51 ++--- ...eTimeSerializationWithCustomFormatter.java | 43 ++-- .../jsr310/ser/WriteNanosecondsTest.java | 34 +-- .../datatype/jsr310/ser/WriteZoneIdTest.java | 19 +- .../ser/YearMonthSerializationTest.java | 59 +++--- .../datatype/jsr310/ser/YearSerTest.java | 12 +- .../datatype/jsr310/ser/ZoneIdSerTest.java | 12 +- .../jsr310/ser/ZoneOffsetSerTest.java | 12 +- .../jsr310/ser/ZonedDateTimeSerTest.java | 193 +++++++++--------- ...ZonedDateTimeSerWithJsonFormat333Test.java | 4 +- .../util/DurationUnitConverterTest.java | 11 +- 70 files changed, 1126 insertions(+), 1177 deletions(-) diff --git a/datetime/pom.xml b/datetime/pom.xml index f46a4a87..c6ed129d 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -58,13 +58,6 @@ junit-jupiter-api test - - - - junit - junit - test - diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ModuleTestBase.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ModuleTestBase.java index cc6725a8..b0041a94 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ModuleTestBase.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ModuleTestBase.java @@ -12,6 +12,9 @@ import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ModuleTestBase { protected static final ZoneId UTC = ZoneId.of("UTC"); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestDecimalUtils.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestDecimalUtils.java index 5b9be3dc..ad25ea07 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestDecimalUtils.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestDecimalUtils.java @@ -1,10 +1,12 @@ package com.fasterxml.jackson.datatype.jsr310; -import org.junit.Test; - import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class TestDecimalUtils extends ModuleTestBase { @@ -12,35 +14,35 @@ public class TestDecimalUtils extends ModuleTestBase public void testToDecimal01() { String decimal = DecimalUtils.toDecimal(0, 0); - assertEquals("The returned decimal is not correct.", NO_NANOSECS_SER, decimal); + assertEquals(NO_NANOSECS_SER, decimal, "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(15, 72); - assertEquals("The returned decimal is not correct.", "15.000000072", decimal); + assertEquals("15.000000072", decimal, "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(19827342231L, 192837465); - assertEquals("The returned decimal is not correct.", "19827342231.192837465", decimal); + assertEquals("19827342231.192837465", decimal, "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(19827342231L, 0); - assertEquals("The returned decimal is not correct.", - "19827342231"+NO_NANOSECS_SUFFIX, decimal); + assertEquals("19827342231"+NO_NANOSECS_SUFFIX, decimal, + "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(19827342231L, 999888000); - assertEquals("The returned decimal is not correct.", - "19827342231.999888000", decimal); + assertEquals("19827342231.999888000", decimal, + "The returned decimal is not correct."); decimal = DecimalUtils.toDecimal(-22704862, 599000000); - assertEquals("The returned decimal is not correct.", - "-22704862.599000000", decimal); + assertEquals("-22704862.599000000", decimal, + "The returned decimal is not correct."); } @SuppressWarnings("deprecation") private void checkExtractNanos(long expectedSeconds, int expectedNanos, BigDecimal decimal) { long seconds = decimal.longValue(); - assertEquals("The second part is not correct.", expectedSeconds, seconds); + assertEquals(expectedSeconds, seconds, "The second part is not correct."); int nanoseconds = DecimalUtils.extractNanosecondDecimal(decimal, seconds); - assertEquals("The nanosecond part is not correct.", expectedNanos, nanoseconds); + assertEquals(expectedNanos, nanoseconds, "The nanosecond part is not correct."); } @Test @@ -89,8 +91,8 @@ public void testExtractNanosecondDecimal06() private void checkExtractSecondsAndNanos(long expectedSeconds, int expectedNanos, BigDecimal decimal) { DecimalUtils.extractSecondsAndNanos(decimal, (Long s, Integer ns) -> { - assertEquals("The second part is not correct.", expectedSeconds, s.longValue()); - assertEquals("The nanosecond part is not correct.", expectedNanos, ns.intValue()); + assertEquals(expectedSeconds, s.longValue(), "The second part is not correct."); + assertEquals(expectedNanos, ns.intValue(), "The nanosecond part is not correct."); return null; }); } @@ -144,7 +146,8 @@ public void testExtractSecondsAndNanosFromNegativeBigDecimal() checkExtractSecondsAndNanos(-22704862L, 599000000, value); } - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testExtractSecondsAndNanos07() { BigDecimal value = new BigDecimal("1e10000000"); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestFeatures.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestFeatures.java index 7b1952a9..a327a8c5 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestFeatures.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestFeatures.java @@ -16,32 +16,33 @@ package com.fasterxml.jackson.datatype.jsr310; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class TestFeatures { @Test public void testWriteDateTimestampsAsNanosecondsSettingEnabledByDefault() { - assertTrue("Write date timestamps as nanoseconds setting should be enabled by default.", - SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault()); + assertTrue(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault(), + "Write date timestamps as nanoseconds setting should be enabled by default."); } @Test public void testReadDateTimestampsAsNanosecondsSettingEnabledByDefault() { - assertTrue("Read date timestamps as nanoseconds setting should be enabled by default.", - DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault()); + assertTrue(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS.enabledByDefault(), + "Read date timestamps as nanoseconds setting should be enabled by default."); } @Test public void testAdjustDatesToContextTimeZoneSettingEnabledByDefault() { - assertTrue("Adjust dates to context time zone setting should be enabled by default.", - DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE.enabledByDefault()); + assertTrue(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE.enabledByDefault(), + "Adjust dates to context time zone setting should be enabled by default."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DefaultTypingTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DefaultTypingTest.java index 17bf71e5..ffdb92f1 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DefaultTypingTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DefaultTypingTest.java @@ -2,13 +2,13 @@ import java.time.ZoneId; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class DefaultTypingTest extends ModuleTestBase { private final ObjectMapper TYPING_MAPPER = newMapper(); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserTest.java index 9e891477..2be9a3c1 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserTest.java @@ -5,6 +5,10 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAmount; import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; @@ -17,12 +21,8 @@ import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class DurationDeserTest extends ModuleTestBase { @@ -63,7 +63,7 @@ public void testDeserializationAsFloat01() throws Exception { Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60.0"); - assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value); + assertEquals(Duration.ofSeconds(60L, 0), value, "The value is not correct."); } @Test @@ -71,7 +71,7 @@ public void testDeserializationAsFloat02() throws Exception { Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60.0"); - assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value); + assertEquals(Duration.ofSeconds(60L, 0), value, "The value is not correct."); } @Test @@ -79,7 +79,7 @@ public void testDeserializationAsFloat03() throws Exception { Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498.000008374"); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 8374), value); + assertEquals(Duration.ofSeconds(13498L, 8374), value, "The value is not correct."); } @Test @@ -87,7 +87,7 @@ public void testDeserializationAsFloat04() throws Exception { Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498.000008374"); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 8374), value); + assertEquals(Duration.ofSeconds(13498L, 8374), value, "The value is not correct."); } /** @@ -116,12 +116,14 @@ public void testDeserializationAsFloatEdgeCase02() throws Exception assertEquals(0, value.getNano()); } - @Test(expected = ArithmeticException.class) + @Test public void testDeserializationAsFloatEdgeCase03() throws Exception { // Duration can't go this low - READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) - .readValue(Long.MIN_VALUE + ".1"); + assertThrows(ArithmeticException.class, () -> { + READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) + .readValue(Long.MIN_VALUE + ".1"); + }); } /* @@ -174,7 +176,8 @@ public void testDeserializationAsFloatEdgeCase07() throws Exception * Numbers with very large exponents can take a long time, but still result in zero. * https://github.com/FasterXML/jackson-databind/issues/2141 */ - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase08() throws Exception { String input = "1e10000000"; @@ -183,7 +186,8 @@ public void testDeserializationAsFloatEdgeCase08() throws Exception assertEquals(0, value.getSeconds()); } - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase09() throws Exception { String input = "-1e10000000"; @@ -195,7 +199,8 @@ public void testDeserializationAsFloatEdgeCase09() throws Exception /** * Same for large negative exponents. */ - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase10() throws Exception { String input = "1e-10000000"; @@ -204,7 +209,8 @@ public void testDeserializationAsFloatEdgeCase10() throws Exception assertEquals(0, value.getSeconds()); } - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase11() throws Exception { String input = "-1e-10000000"; @@ -218,7 +224,7 @@ public void testDeserializationAsInt01() throws Exception { Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60"); - assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value); + assertEquals(Duration.ofSeconds(60L, 0), value, "The value is not correct."); } @Test @@ -226,7 +232,7 @@ public void testDeserializationAsInt02() throws Exception { Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("60000"); - assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value); + assertEquals(Duration.ofSeconds(60L, 0), value, "The value is not correct."); } @Test @@ -234,7 +240,7 @@ public void testDeserializationAsInt03() throws Exception { Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498"); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 0), value); + assertEquals(Duration.ofSeconds(13498L, 0), value, "The value is not correct."); } @Test @@ -242,7 +248,7 @@ public void testDeserializationAsInt04() throws Exception { Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("13498000"); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 0), value); + assertEquals(Duration.ofSeconds(13498L, 0), value, "The value is not correct."); } @Test @@ -253,7 +259,7 @@ public void testDeserializationAsInt05() throws Exception new WrapperWithReadTimestampsAsNanosEnabled(Duration.ofSeconds(13498L, 0)); WrapperWithReadTimestampsAsNanosEnabled actual = reader.readValue(wrapperPayload(13498)); - assertEquals("The value is not correct.", expected.value, actual.value); + assertEquals(expected.value, actual.value, "The value is not correct."); } @Test @@ -264,7 +270,7 @@ public void testDeserializationAsInt06() throws Exception new WrapperWithReadTimestampsAsNanosDisabled(Duration.ofSeconds(13498L, 0)); WrapperWithReadTimestampsAsNanosDisabled actual = reader.readValue(wrapperPayload(13498000)); - assertEquals("The value is not correct.", expected.value, actual.value); + assertEquals(expected.value, actual.value, "The value is not correct."); } @Test @@ -272,7 +278,7 @@ public void testDeserializationAsString01() throws Exception { Duration exp = Duration.ofSeconds(60L, 0); Duration value = READER.readValue('"' + exp.toString() + '"'); - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } @Test @@ -280,13 +286,13 @@ public void testDeserializationAsString02() throws Exception { Duration exp = Duration.ofSeconds(13498L, 8374); Duration value = READER.readValue('"' + exp.toString() + '"'); - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } @Test public void testDeserializationAsString03() throws Exception { - assertNull("The value should be null.", READER.readValue("\" \"")); + assertNull(READER.readValue("\" \""), "The value should be null."); } @Test @@ -301,8 +307,8 @@ public void testDeserializationWithTypeInfo01() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + "13498.000008374]", TemporalAmount.class); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", duration, value); + assertTrue(value instanceof Duration, "The value should be a Duration."); + assertEquals(duration, value, "The value is not correct."); } @Test @@ -315,8 +321,8 @@ public void testDeserializationWithTypeInfo02() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + "13498]", TemporalAmount.class); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L), value); + assertTrue(value instanceof Duration, "The value should be a Duration."); + assertEquals(Duration.ofSeconds(13498L), value, "The value is not correct."); } @Test @@ -329,8 +335,8 @@ public void testDeserializationWithTypeInfo03() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + "13498837]", TemporalAmount.class); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 837000000), value); + assertTrue(value instanceof Duration, "The value should be a Duration."); + assertEquals(Duration.ofSeconds(13498L, 837000000), value, "The value is not correct."); } @Test @@ -344,8 +350,8 @@ public void testDeserializationWithTypeInfo04() throws Exception mapper.addMixIn(TemporalAmount.class, MockObjectConfiguration.class); TemporalAmount value = mapper.readValue(prefix + '"' + duration.toString() + "\"]", TemporalAmount.class); - assertTrue("The value should be a Duration.", value instanceof Duration); - assertEquals("The value is not correct.", duration, value); + assertTrue(value instanceof Duration, "The value should be a Duration."); + assertEquals(duration, value, "The value is not correct."); } @Test @@ -386,7 +392,7 @@ public void testDeserializationAsArrayEnabled() throws Exception { .configure(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS, true) .readerFor(Duration.class).readValue("[\"" + exp.toString() + "\"]"); - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } @Test @@ -423,10 +429,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, dateValAsEmptyStr)); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); Duration actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting", null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test ( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "duration"; @@ -444,7 +450,7 @@ public void testStrictDeserializeFromEmptyString() throws Exception { String dateValAsEmptyStr = ""; String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, dateValAsEmptyStr)); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } /* diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java index cc0f7d12..3768276a 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java @@ -5,9 +5,11 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.exc.MismatchedInputException; @@ -22,8 +24,8 @@ import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; import static com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.ISO8601_COLONLESS_OFFSET_REGEX; -import static org.junit.Assert.*; -import static org.junit.Assume.assumeTrue; + +import static org.junit.jupiter.api.Assertions.*; public class InstantDeserTest extends ModuleTestBase { @@ -136,12 +138,12 @@ public void testDeserializationAsFloatEdgeCase02() throws Exception assertEquals(0, value.getNano()); } - @Test(expected = DateTimeException.class) + @Test public void testDeserializationAsFloatEdgeCase03() throws Exception { // Instant can't go this low String input = Instant.MIN.getEpochSecond() + ".1"; - READER.readValue(input); + assertThrows(DateTimeException.class, () -> READER.readValue(input)); } /* @@ -149,21 +151,20 @@ public void testDeserializationAsFloatEdgeCase03() throws Exception * for numbers outside the range of Long. Numbers less than 1e64 will result in the lower 64 bits. * Numbers at or above 1e64 will always result in zero. */ - - @Test(expected = DateTimeException.class) + @Test public void testDeserializationAsFloatEdgeCase04() throws Exception { // 1ns beyond the upper-bound of Instant. String input = (Instant.MAX.getEpochSecond() + 1) + ".0"; - READER.readValue(input); + assertThrows(DateTimeException.class, () -> READER.readValue(input)); } - @Test(expected = DateTimeException.class) + @Test public void testDeserializationAsFloatEdgeCase05() throws Exception { // 1ns beyond the lower-bound of Instant. String input = (Instant.MIN.getEpochSecond() - 1) + ".0"; - READER.readValue(input); + assertThrows(DateTimeException.class, () -> READER.readValue(input)); } @Test @@ -186,14 +187,16 @@ public void testDeserializationAsFloatEdgeCase07() throws Exception * Numbers with very large exponents can take a long time, but still result in zero. * https://github.com/FasterXML/jackson-databind/issues/2141 */ - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase08() throws Exception { Instant value = READER.readValue("1e10000000"); assertEquals(0, value.getEpochSecond()); } - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase09() throws Exception { Instant value = READER.readValue("-1e10000000"); @@ -203,14 +206,16 @@ public void testDeserializationAsFloatEdgeCase09() throws Exception /** * Same for large negative exponents. */ - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase10() throws Exception { Instant value = READER.readValue("1e-10000000"); assertEquals(0, value.getEpochSecond()); } - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase11() throws Exception { Instant value = READER.readValue("-1e-10000000"); @@ -366,7 +371,7 @@ public void testDeserializationWithTypeInfo01() throws Exception Temporal value = m.readValue( "[\"" + Instant.class.getName() + "\",123456789.183917322]", Temporal.class ); - assertTrue("The value should be an Instant.", value instanceof Instant); + assertTrue(value instanceof Instant, "The value should be an Instant."); assertEquals(date, value); } @@ -380,7 +385,7 @@ public void testDeserializationWithTypeInfo02() throws Exception Temporal value = m.readValue( "[\"" + Instant.class.getName() + "\",123456789]", Temporal.class ); - assertTrue("The value should be an Instant.", value instanceof Instant); + assertTrue(value instanceof Instant, "The value should be an Instant."); assertEquals(date, value); } @@ -395,7 +400,7 @@ public void testDeserializationWithTypeInfo03() throws Exception "[\"" + Instant.class.getName() + "\",123456789422]", Temporal.class ); - assertTrue("The value should be an Instant.", value instanceof Instant); + assertTrue(value instanceof Instant, "The value should be an Instant."); assertEquals(date, value); } @@ -408,7 +413,7 @@ public void testDeserializationWithTypeInfo04() throws Exception Temporal value = m.readValue( "[\"" + Instant.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertTrue("The value should be an Instant.", value instanceof Instant); + assertTrue(value instanceof Instant, "The value should be an Instant."); assertEquals(date, value); } @@ -442,12 +447,12 @@ public void testCustomPatternWithAnnotations02() throws Exception final WrapperWithCustomPattern input = new WrapperWithCustomPattern(instant); String json = MAPPER.writeValueAsString(input); - assertTrue("Instant in UTC timezone was not serialized as expected.", - json.contains(a2q("'valueInUTC':'" + valueInUTC + "'"))); + assertTrue(json.contains(a2q("'valueInUTC':'" + valueInUTC + "'")), + "Instant in UTC timezone was not serialized as expected."); WrapperWithCustomPattern result = MAPPER.readValue(json, WrapperWithCustomPattern.class); - assertEquals("Instant in UTC timezone was not deserialized as expected.", - input.valueInUTC, result.valueInUTC); + assertEquals(input.valueInUTC, result.valueInUTC, + "Instant in UTC timezone was not deserialized as expected."); } /* @@ -515,7 +520,7 @@ private String formatWithZeroZoneOffset(Instant date, String offset){ private static void assumeInstantCanParseOffsets() { // DateTimeFormatter.ISO_INSTANT didn't handle offsets until JDK 12+. // This was added by https://bugs.openjdk.org/browse/JDK-8166138 - assumeTrue(System.getProperty("java.specification.version").compareTo("12") > 0); + assertTrue(System.getProperty("java.specification.version").compareTo("12") > 0); } /* @@ -584,10 +589,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, dateValAsEmptyStr)); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); Duration actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting", null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test ( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "instant"; @@ -602,7 +607,7 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } /* @@ -614,30 +619,30 @@ public void testStrictDeserializeFromEmptyString() throws Exception { public void testISO8601ColonlessRegexFindsOffset() { Matcher matcher = ISO8601_COLONLESS_OFFSET_REGEX.matcher("2000-01-01T12:00+0100"); - assertTrue("Matcher finds +0100 as an colonless offset", matcher.find()); - assertEquals("Matcher groups +0100 as an colonless offset", matcher.group(), "+0100"); + assertTrue(matcher.find(), "Matcher finds +0100 as an colonless offset"); + assertEquals(matcher.group(), "+0100", "Matcher groups +0100 as an colonless offset"); } @Test public void testISO8601ColonlessRegexFindsOffsetWithTZ() { Matcher matcher = ISO8601_COLONLESS_OFFSET_REGEX.matcher("2000-01-01T12:00+0100[Europe/Paris]"); - assertTrue("Matcher finds +0100 as an colonless offset", matcher.find()); - assertEquals("Matcher groups +0100 as an colonless offset", matcher.group(), "+0100"); + assertTrue(matcher.find(), "Matcher finds +0100 as an colonless offset"); + assertEquals(matcher.group(), "+0100", "Matcher groups +0100 as an colonless offset"); } @Test public void testISO8601ColonlessRegexDoesNotAffectNegativeYears() { Matcher matcher = ISO8601_COLONLESS_OFFSET_REGEX.matcher("-2000-01-01T12:00+01:00[Europe/Paris]"); - assertFalse("Matcher does not find -2000 (years) as an offset without colon", matcher.find()); + assertFalse(matcher.find(), "Matcher does not find -2000 (years) as an offset without colon"); } @Test public void testISO8601ColonlessRegexDoesNotAffectNegativeYearsWithColonless() { Matcher matcher = ISO8601_COLONLESS_OFFSET_REGEX.matcher("-2000-01-01T12:00+0100[Europe/Paris]"); - assertTrue("Matcher finds +0100 as an colonless offset", matcher.find()); - assertEquals("Matcher groups +0100 as an colonless offset", matcher.group(), "+0100"); + assertTrue(matcher.find(), "Matcher finds +0100 as an colonless offset"); + assertEquals(matcher.group(), "+0100", "Matcher groups +0100 as an colonless offset"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserTest.java index e3fe9e92..ff8423b7 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserTest.java @@ -10,11 +10,12 @@ import java.time.temporal.Temporal; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.OptBoolean; import com.fasterxml.jackson.databind.cfg.CoercionAction; import com.fasterxml.jackson.databind.cfg.CoercionInputShape; import com.fasterxml.jackson.databind.exc.InvalidFormatException; -import org.junit.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; @@ -30,10 +31,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.*; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.*; public class LocalDateDeserTest extends ModuleTestBase { @@ -103,14 +101,14 @@ public StrictWrapperWithFormat() { } @Test public void testDeserializationAsTimestamp01() throws Exception { - assertEquals("The value is not correct.", LocalDate.of(1986, Month.JANUARY, 17), + assertEquals(LocalDate.of(1986, Month.JANUARY, 17), READER.readValue("[1986,1,17]")); } @Test public void testDeserializationAsTimestamp02() throws Exception { - assertEquals("The value is not correct.", LocalDate.of(2013, Month.AUGUST, 21), + assertEquals(LocalDate.of(2013, Month.AUGUST, 21), READER.readValue("[2013,8,21]")); } @@ -123,24 +121,20 @@ public void testDeserializationAsTimestamp02() throws Exception @Test public void testDeserializationAsString01() throws Exception { - assertEquals("The value is not correct.", LocalDate.of(2000, Month.JANUARY, 1), - READER.readValue(q("2000-01-01"))); + assertEquals(LocalDate.of(2000, Month.JANUARY, 1), READER.readValue(q("2000-01-01"))); LocalDate date = LocalDate.of(1986, Month.JANUARY, 17); - assertEquals("The value is not correct.", date, - READER.readValue('"' + date.toString() + '"')); + assertEquals(date, READER.readValue('"' + date.toString() + '"')); date = LocalDate.of(2013, Month.AUGUST, 21); - assertEquals("The value is not correct.", date, - READER.readValue('"' + date.toString() + '"')); + assertEquals(date, READER.readValue('"' + date.toString() + '"')); } @Test public void testDeserializationAsString02() throws Exception { LocalDateTime date = LocalDateTime.now(); - assertEquals("The value is not correct.", date.toLocalDate(), - READER.readValue('"' + date.toString() + '"')); + assertEquals(date.toLocalDate(), READER.readValue('"' + date.toString() + '"')); } @Test @@ -148,8 +142,7 @@ public void testDeserializationAsString03() throws Exception { Instant instant = Instant.now(); LocalDate value = READER.readValue('"' + instant.toString() + '"'); - assertEquals("The value is not correct.", - LocalDateTime.ofInstant(instant, ZoneOffset.UTC).toLocalDate(), + assertEquals(LocalDateTime.ofInstant(instant, ZoneOffset.UTC).toLocalDate(), value); } @@ -187,7 +180,7 @@ public void testDeserializationWithTypeInfo01() throws Exception Temporal value = mapper.readValue( "[\"" + LocalDate.class.getName() + "\",\"" + date.toString() + "\"]", Temporal.class ); - assertEquals("The value is not correct.", date, value); + assertEquals(date, value); } /* @@ -201,11 +194,9 @@ public void testDeserializationWithTypeInfo01() throws Exception @Test public void testLenientDeserializeFromInt() throws Exception { - assertEquals("The value is not correct.", LocalDate.of(1970, Month.JANUARY, 3), - READER.readValue("2")); + assertEquals(LocalDate.of(1970, Month.JANUARY, 3), READER.readValue("2")); - assertEquals("The value is not correct.", LocalDate.of(1970, Month.FEBRUARY, 10), - READER.readValue("40")); + assertEquals(LocalDate.of(1970, Month.FEBRUARY, 10), READER.readValue("40")); } // But with alternate setting, not so @@ -252,10 +243,11 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, dateValAsEmptyStr)); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); LocalDate actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting",actualDateFromNullStr, actualDateFromEmptyStr); + assertEquals(actualDateFromNullStr, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test( expected = MismatchedInputException.class) + @Test + // ( expected = MismatchedInputException.class) public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "date"; @@ -274,7 +266,7 @@ public void testStrictDeserializeFromEmptyString() throws Exception { // TODO: nothing stops us from writing an empty string, maybe there should be a check there too? String valueFromEmptyStr = mapper.writeValueAsString(asMap("date", dateValAsEmptyStr)); // with strict, deserializing an empty string is not permitted - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } /* @@ -307,7 +299,7 @@ public void testDeserializationAsArrayEnabled() throws Throwable LocalDate actual = READER .with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) .readValue("[\"2000-01-01\"]"); - assertEquals("The value is not correct.", LocalDate.of(2000, 1, 1), actual); + assertEquals(LocalDate.of(2000, 1, 1), actual); } @Test @@ -358,22 +350,28 @@ public void testStrictCustomFormat() throws Exception */ // for [modules-java8#148] - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidFormat() throws Exception { - /*StrictWrapper w =*/ MAPPER.readValue("{\"value\":\"2019-11-30\"}", StrictWrapper.class); + assertThrows(InvalidFormatException.class, () -> { + /*StrictWrapper w =*/ MAPPER.readValue("{\"value\":\"2019-11-30\"}", StrictWrapper.class); + }); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidFormatWithEra() throws Exception { - /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30\"}", StrictWrapperWithYearOfEra.class); + assertThrows(InvalidFormatException.class, () -> { + /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30\"}", StrictWrapperWithYearOfEra.class); + }); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidDateWithEra() throws Exception { - /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 AD\"}", StrictWrapperWithYearOfEra.class); + assertThrows(InvalidFormatException.class, () -> { + /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 AD\"}", StrictWrapperWithYearOfEra.class); + }); } @Test @@ -384,16 +382,20 @@ public void testStrictCustomFormatForValidDateWithEra() throws Exception assertEquals(w.value, LocalDate.of(2019, 11, 30)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidFormatWithoutEra() throws Exception { - /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 AD\"}", StrictWrapperWithYearWithoutEra.class); + assertThrows(InvalidFormatException.class, () -> { + /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 AD\"}", StrictWrapperWithYearWithoutEra.class); + }); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidDateWithoutEra() throws Exception { - /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31\"}", StrictWrapperWithYearWithoutEra.class); + assertThrows(InvalidFormatException.class, () -> { + /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31\"}", StrictWrapperWithYearWithoutEra.class); + }); } @Test @@ -478,8 +480,8 @@ public void testLenientDeserializeFromNumberInt() throws Exception { mapper.configOverride(LocalDate.class) .setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.NUMBER_INT)); - assertEquals("The value is not correct.", LocalDate.of(1970, Month.MAY, 4), - mapper.readValue("123", LocalDate.class)); + assertEquals(LocalDate.of(1970, Month.MAY, 4), + mapper.readValue("123", LocalDate.class)); } @Test @@ -492,18 +494,18 @@ public void testStrictDeserializeFromNumberInt() throws Exception ShapeWrapper w = mapper.readValue("{\"date\":123}", ShapeWrapper.class); LocalDate localDate = w.date; - assertEquals("The value is not correct.", LocalDate.of(1970, Month.MAY, 4), - localDate); + assertEquals(LocalDate.of(1970, Month.MAY, 4), localDate); } - @Test(expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromString() throws Exception { ObjectMapper mapper = newMapper(); mapper.configOverride(LocalDate.class) .setFormat(JsonFormat.Value.forLeniency(false)); - mapper.readValue("{\"value\":123}", Wrapper.class); + assertThrows(MismatchedInputException.class, + () -> mapper.readValue("{\"value\":123}", Wrapper.class)); } /********************************************************************** @@ -521,8 +523,7 @@ public void testDeserializeFromIntegerWithCoercionActionFail() { MismatchedInputException exception = assertThrows(MismatchedInputException.class, () -> mapper.readValue("123", LocalDate.class)); - assertThat(exception.getMessage(), - containsString("Cannot coerce Integer value (123) to `java.time.LocalDate`")); + assertTrue(exception.getMessage().contains("Cannot coerce Integer value (123) to `java.time.LocalDate`")); } @Test @@ -534,8 +535,7 @@ public void testDeserializeFromEmptyStringWithCoercionActionFail() { MismatchedInputException exception = assertThrows(MismatchedInputException.class, () -> mapper.readValue(a2q("{'value':''}"), Wrapper.class)); - assertThat(exception.getMessage(), - containsString("Cannot coerce empty String (\"\") to `java.time.LocalDate`")); + assertTrue(exception.getMessage().contains("Cannot coerce empty String (\"\") to `java.time.LocalDate`")); } /* @@ -559,10 +559,8 @@ private void expectFailure(ObjectReader reader, String json) throws Throwable { private void expectSuccess(ObjectReader reader, Object exp, String json) throws IOException { final LocalDate value = reader.readValue(a2q(json)); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", exp, value); + assertNotNull(value); + assertEquals(exp, value); } -} - - +} diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java index 3fb59fab..cecf6455 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java @@ -26,6 +26,8 @@ import java.util.Map; import java.util.TimeZone; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; import com.fasterxml.jackson.annotation.JsonFormat.Value; @@ -40,9 +42,8 @@ import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class LocalDateTimeDeserTest extends ModuleTestBase @@ -117,7 +118,7 @@ public void testDeserializationAsTimestamp01() throws Exception { LocalDateTime value = MAPPER.readValue("[1986,1,17,15,43]", LocalDateTime.class); LocalDateTime time = LocalDateTime.of(1986, Month.JANUARY, 17, 15, 43); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -125,7 +126,7 @@ public void testDeserializationAsTimestamp02() throws Exception { LocalDateTime value = MAPPER.readValue("[2013,8,21,9,22,57]", LocalDateTime.class); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 57); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -135,7 +136,7 @@ public void testDeserializationAsTimestamp03Nanoseconds() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2013,8,21,9,22,0,57]"); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -145,7 +146,7 @@ public void testDeserializationAsTimestamp03Milliseconds() throws Exception .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2013,8,21,9,22,0,57]"); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57000000); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -155,7 +156,7 @@ public void testDeserializationAsTimestamp04Nanoseconds() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2005,11,5,22,31,5,829837]"); LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829837); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -166,7 +167,7 @@ public void testDeserializationAsTimestamp04Milliseconds01() throws Exception LocalDateTime value = r.readValue("[2005,11,5,22,31,5,829837]"); LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829837); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -176,7 +177,7 @@ public void testDeserializationAsTimestamp04Milliseconds02() throws Exception .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS); LocalDateTime value = r.readValue("[2005,11,5,22,31,5,829]"); LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829000000); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -186,7 +187,7 @@ public void testDeserializationAsTimestamp05Nanoseconds() throws Exception WrapperWithReadTimestampsAsNanosEnabled actual = r.readValue(a2q("{'value':[2013,8,21,9,22,0,57]}")); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57); - assertEquals("The value is not correct.", time, actual.value); + assertEquals(time, actual.value, "The value is not correct."); } @Test @@ -196,7 +197,7 @@ public void testDeserializationAsTimestamp05Milliseconds01() throws Exception WrapperWithReadTimestampsAsNanosDisabled actual = r.readValue(a2q("{'value':[2013,8,21,9,22,0,57]}")); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57000000); - assertEquals("The value is not correct.", time, actual.value); + assertEquals(time, actual.value, "The value is not correct."); } @Test @@ -206,7 +207,7 @@ public void testDeserializationAsTimestamp05Milliseconds02() throws Exception WrapperWithReadTimestampsAsNanosDisabled actual = r.readValue(a2q("{'value':[2013,8,21,9,22,0,4257]}")); LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 4257); - assertEquals("The value is not correct.", time, actual.value); + assertEquals(time, actual.value, "The value is not correct."); } /* @@ -220,11 +221,11 @@ public void testDeserializationAsString01() throws Exception { LocalDateTime exp = LocalDateTime.of(1986, Month.JANUARY, 17, 15, 43); LocalDateTime value = READER.readValue(q(exp.toString())); - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); - assertEquals("The value is not correct.", - LocalDateTime.of(2000, Month.JANUARY, 1, 12, 0), - READER.readValue(q("2000-01-01T12:00"))); + assertEquals(LocalDateTime.of(2000, Month.JANUARY, 1, 12, 0), + READER.readValue(q("2000-01-01T12:00")), + "The value is not correct."); } @Test @@ -232,7 +233,7 @@ public void testDeserializationAsString02() throws Exception { LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 57); LocalDateTime value = MAPPER.readValue(q(time.toString()), LocalDateTime.class); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -240,7 +241,7 @@ public void testDeserializationAsString03() throws Exception { LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829837); LocalDateTime value = MAPPER.readValue(q(time.toString()), LocalDateTime.class); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } /* @@ -259,16 +260,16 @@ public void testAllowZuluIfLenient() throws Exception final ObjectReader r = MAPPER.readerFor(LocalDateTime.class); // First, defaults: - assertEquals("The value is not correct.", EXP, r.readValue(input)); + assertEquals(EXP, r.readValue(input), "The value is not correct."); // but ensure that global timezone setting doesn't matter LocalDateTime value = r.with(TimeZone.getTimeZone(Z_CHICAGO)) .readValue(input); - assertEquals("The value is not correct.", EXP, value); + assertEquals(EXP, value, "The value is not correct."); value = r.with(TimeZone.getTimeZone(Z_BUDAPEST)) .readValue(input); - assertEquals("The value is not correct.", EXP, value); + assertEquals(EXP, value, "The value is not correct."); } // [modules-java#94]: "Z" offset not allowed if strict mode @@ -320,10 +321,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, dateValAsEmptyStr)); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); LocalDateTime actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting",actualDateFromNullStr, actualDateFromEmptyStr); + assertEquals(actualDateFromNullStr, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "datetime"; @@ -339,7 +340,8 @@ public void testStrictDeserializeFromEmptyString() throws Exception { // TODO: nothing stops us from writing an empty string, maybe there should be a check there too? String valueFromEmptyStr = STRICT_MAPPER.writeValueAsString(asMap("date", dateValAsEmptyStr)); // with strict, deserializing an empty string is not permitted - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, + () -> objectReader.readValue(valueFromEmptyStr)); } /* @@ -371,8 +373,8 @@ public void testDeserializationAsArrayEnabled() throws Throwable LocalDateTime value = READER .with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) .readValue("[\"2000-01-01T12:00\"]"); - assertEquals("The value is not correct.", - LocalDateTime.of(2000, 1, 1, 12, 0, 0, 0), value); + assertEquals(LocalDateTime.of(2000, 1, 1, 12, 0, 0, 0), + value, "The value is not correct."); } @Test @@ -400,8 +402,8 @@ public void testDeserializationWithTypeInfo01() throws Exception Temporal value = m.readValue( "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,829837]]", Temporal.class ); - assertTrue("The value should be a LocalDateTime.", value instanceof LocalDateTime); - assertEquals("The value is not correct.", time, value); + assertTrue(value instanceof LocalDateTime, "The value should be a LocalDateTime."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -414,8 +416,8 @@ public void testDeserializationWithTypeInfo02() throws Exception Temporal value = m.readValue( "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,422]]", Temporal.class ); - assertTrue("The value should be a LocalDateTime.", value instanceof LocalDateTime); - assertEquals("The value is not correct.", time, value); + assertTrue(value instanceof LocalDateTime, "The value should be a LocalDateTime."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -427,8 +429,8 @@ public void testDeserializationWithTypeInfo03() throws Exception Temporal value = m.readValue( "[\"" + LocalDateTime.class.getName() + "\",\"" + time.toString() + "\"]", Temporal.class ); - assertTrue("The value should be a LocalDateTime.", value instanceof LocalDateTime); - assertEquals("The value is not correct.", time, value); + assertTrue(value instanceof LocalDateTime, "The value should be a LocalDateTime."); + assertEquals(time, value, "The value is not correct."); } /* @@ -584,34 +586,40 @@ public void testDeserializationCaseInsensitiveDisabled_InvalidDate() throws Thro */ // [modules-java8#148]: handle strict deserializaiton for date/time - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidFormat() throws Exception { - /*StrictWrapper w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 15:45\"}", StrictWrapper.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapper w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 15:45\"}", StrictWrapper.class)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidFormatWithEra() throws Exception { - /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 15:45\"}", StrictWrapperWithYearOfEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 15:45\"}", StrictWrapperWithYearOfEra.class)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidDateWithEra() throws Exception { - /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 15:45 AD\"}", StrictWrapperWithYearOfEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 15:45 AD\"}", StrictWrapperWithYearOfEra.class)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidTimeWithEra() throws Exception { - /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 25:45 AD\"}", StrictWrapperWithYearOfEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 25:45 AD\"}", StrictWrapperWithYearOfEra.class)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidDateAndTimeWithEra() throws Exception { - /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 25:45 AD\"}", StrictWrapperWithYearOfEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearOfEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 25:45 AD\"}", StrictWrapperWithYearOfEra.class)); + } @Test @@ -622,28 +630,32 @@ public void testStrictCustomFormatValidDateAndTimeWithEra() throws Exception assertEquals(w.value, LocalDateTime.of(2019, 11, 30, 20, 45)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidFormatWithoutEra() throws Exception { - /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 15:45 AD\"}", StrictWrapperWithYearWithoutEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 15:45 AD\"}", StrictWrapperWithYearWithoutEra.class)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidTimeWithoutEra() throws Exception { - /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 25:45\"}", StrictWrapperWithYearWithoutEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-30 25:45\"}", StrictWrapperWithYearWithoutEra.class)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidDateWithoutEra() throws Exception { - /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 15:45\"}", StrictWrapperWithYearWithoutEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 15:45\"}", StrictWrapperWithYearWithoutEra.class)); } - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatForInvalidDateAndTimeWithoutEra() throws Exception { - /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 25:45\"}", StrictWrapperWithYearWithoutEra.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapperWithYearWithoutEra w =*/ MAPPER.readValue("{\"value\":\"2019-11-31 25:45\"}", StrictWrapperWithYearWithoutEra.class)); } @Test @@ -680,8 +692,8 @@ private void _testLocalDateTimeRoundTrip(ObjectMapper mapper, LocalDateTime loca private void expectSuccess(ObjectReader reader, Object exp, String json) throws IOException { final LocalDateTime value = reader.readValue(a2q(json)); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", exp, value); + assertNotNull(value, "The value should not be null."); + assertEquals(exp, value, "The value is not correct."); } private void expectFailure(ObjectReader reader, String json) throws Throwable { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserTest.java index 785f6ff1..5c7cc070 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserTest.java @@ -22,11 +22,7 @@ import java.time.temporal.Temporal; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; @@ -41,7 +37,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class LocalTimeDeserTest extends ModuleTestBase { @@ -83,7 +79,7 @@ public void testDeserializationAsTimestamp01() throws Exception { LocalTime time = LocalTime.of(15, 43); LocalTime value = reader.readValue("[15,43]"); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -91,7 +87,7 @@ public void testDeserializationAsTimestamp02() throws Exception { LocalTime time = LocalTime.of(9, 22, 57); LocalTime value = reader.readValue("[9,22,57]"); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -100,7 +96,7 @@ public void testDeserializationAsTimestamp03Nanoseconds() throws Exception LocalTime value = reader .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[9,22,0,57]"); - assertEquals("The value is not correct.", LocalTime.of(9, 22, 0, 57), value); + assertEquals(LocalTime.of(9, 22, 0, 57), value, "The value is not correct."); } @Test @@ -109,7 +105,7 @@ public void testDeserializationAsTimestamp03Milliseconds() throws Exception LocalTime value = reader .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[9,22,0,57]"); - assertEquals("The value is not correct.", LocalTime.of(9, 22, 0, 57000000), value); + assertEquals(LocalTime.of(9, 22, 0, 57000000), value, "The value is not correct."); } @Test @@ -118,7 +114,7 @@ public void testDeserializationAsTimestamp04Nanoseconds() throws Exception LocalTime value = reader .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[22,31,5,829837]"); - assertEquals("The value is not correct.", LocalTime.of(22, 31, 5, 829837), value); + assertEquals(LocalTime.of(22, 31, 5, 829837), value, "The value is not correct."); } @Test @@ -127,7 +123,7 @@ public void testDeserializationAsTimestamp04Milliseconds01() throws Exception LocalTime value = reader .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[22,31,5,829837]"); - assertEquals("The value is not correct.", LocalTime.of(22, 31, 5, 829837), value); + assertEquals(LocalTime.of(22, 31, 5, 829837), value, "The value is not correct."); } @Test @@ -136,7 +132,7 @@ public void testDeserializationAsTimestamp04Milliseconds02() throws Exception LocalTime value = reader .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[22,31,5,829]"); - assertEquals("The value is not correct.", LocalTime.of(22, 31, 5, 829000000), value); + assertEquals(LocalTime.of(22, 31, 5, 829000000), value, "The value is not correct."); } @Test @@ -146,7 +142,7 @@ public void testDeserializationAsTimestamp05Nanoseconds() throws Exception newMapper().readerFor(WrapperWithReadTimestampsAsNanosEnabled.class); WrapperWithReadTimestampsAsNanosEnabled actual = wrapperReader .readValue(a2q("{'value':[9,22,0,57]}")); - assertEquals("The value is not correct.", LocalTime.of(9, 22, 0, 57), actual.value); + assertEquals(LocalTime.of(9, 22, 0, 57), actual.value, "The value is not correct."); } @Test @@ -156,7 +152,7 @@ public void testDeserializationAsTimestamp05Milliseconds01() throws Exception newMapper().readerFor(WrapperWithReadTimestampsAsNanosDisabled.class); WrapperWithReadTimestampsAsNanosDisabled actual = wrapperReader .readValue(a2q("{'value':[9,22,0,57]}")); - assertEquals("The value is not correct.", LocalTime.of(9, 22, 0, 57000000), actual.value); + assertEquals(LocalTime.of(9, 22, 0, 57000000), actual.value, "The value is not correct."); } @Test @@ -166,7 +162,7 @@ public void testDeserializationAsTimestamp05Milliseconds02() throws Exception newMapper().readerFor(WrapperWithReadTimestampsAsNanosDisabled.class); WrapperWithReadTimestampsAsNanosDisabled actual = wrapperReader .readValue(a2q("{'value':[9,22,0,4257]}")); - assertEquals("The value is not correct.", LocalTime.of(9, 22, 0, 4257), actual.value); + assertEquals(LocalTime.of(9, 22, 0, 4257), actual.value, "The value is not correct."); } @Test @@ -174,17 +170,17 @@ public void testDeserializationFromString() throws Exception { LocalTime time = LocalTime.of(15, 43); LocalTime value = reader.readValue('"' + time.toString() + '"'); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); expectSuccess(LocalTime.of(12, 0), "'12:00'"); time = LocalTime.of(9, 22, 57); value = reader.readValue('"' + time.toString() + '"'); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); time = LocalTime.of(22, 31, 5, 829837); value = reader.readValue('"' + time.toString() + '"'); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -239,9 +235,9 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + LocalTime.class.getName() + "\",[22,31,5,829837]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalTime.", value instanceof LocalTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertTrue(value instanceof LocalTime, "The value should be a LocalTime."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -256,9 +252,9 @@ public void testDeserializationWithTypeInfo02() throws Exception "[\"" + LocalTime.class.getName() + "\",[22,31,5,422]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalTime.", value instanceof LocalTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertTrue(value instanceof LocalTime, "The value should be a LocalTime."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -271,9 +267,9 @@ public void testDeserializationWithTypeInfo03() throws Exception "[\"" + LocalTime.class.getName() + "\",\"" + time.toString() + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a LocalTime.", value instanceof LocalTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertTrue(value instanceof LocalTime, "The value should be a LocalTime."); + assertEquals(time, value, "The value is not correct."); } /* @@ -299,10 +295,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, dateValAsEmptyStr)); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); LocalTime actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting",null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "localTime"; @@ -316,7 +312,8 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap("date", "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, + () -> objectReader.readValue(valueFromEmptyStr)); } /* @@ -327,10 +324,11 @@ public void testStrictDeserializeFromEmptyString() throws Exception { // [modules-java8#148]: handle strict deserializaiton for date/time - @Test(expected = InvalidFormatException.class) + @Test public void testStrictCustomFormatInvalidTime() throws Exception { - /*StrictWrapper w =*/ MAPPER.readValue("{\"value\":\"25:45\"}", StrictWrapper.class); + assertThrows(InvalidFormatException.class, + () -> /*StrictWrapper w =*/ MAPPER.readValue("{\"value\":\"25:45\"}", StrictWrapper.class)); } private void expectFailure(String aposJson) throws Throwable { @@ -354,10 +352,10 @@ private void expectSuccess(Object exp, String aposJson) throws IOException { } private static void notNull(Object value) { - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); } private static void expect(Object exp, Object value) { - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserTest.java index 7d115df0..9774e971 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserTest.java @@ -7,6 +7,8 @@ import java.time.temporal.TemporalAccessor; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.JsonProcessingException; @@ -21,12 +23,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class MonthDayDeserTest extends ModuleTestBase { @@ -111,15 +108,16 @@ public void testDeserializationAsEmptyArrayEnabled() throws Throwable @Test public void testDeserialization01() throws Exception { - assertEquals("The value is not correct.", MonthDay.of(Month.JANUARY, 17), - MAPPER.readValue("\"--01-17\"", MonthDay.class)); + assertEquals(MonthDay.of(Month.JANUARY, 17), MAPPER.readValue("\"--01-17\"", MonthDay.class), + "The value is not correct."); } @Test public void testDeserialization02() throws Exception { - assertEquals("The value is not correct.", MonthDay.of(Month.AUGUST, 21), - MAPPER.readValue("\"--08-21\"", MonthDay.class)); + assertEquals(MonthDay.of(Month.AUGUST, 21), + MAPPER.readValue("\"--08-21\"", MonthDay.class), + "The value is not correct."); } @Test @@ -131,7 +129,7 @@ public void testDeserializationWithTypeInfo01() throws Exception MonthDay monthDay = MonthDay.of(Month.NOVEMBER, 5); TemporalAccessor value = mapper.readValue("[\"" + MonthDay.class.getName() + "\",\"--11-05\"]", TemporalAccessor.class); - assertEquals("The value is not correct.", monthDay, value); + assertEquals(monthDay, value, "The value is not correct."); } @Test @@ -220,10 +218,10 @@ private MonthDay read(final String aposJson) throws IOException { } private static void notNull(Object value) { - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); } private static void expect(Object exp, Object value) { - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java index 83e46d0e..26b7423b 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java @@ -9,6 +9,8 @@ import java.util.Map; import java.util.TimeZone; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; import com.fasterxml.jackson.core.type.TypeReference; @@ -21,9 +23,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class OffsetDateTimeDeserTest extends ModuleTestBase @@ -75,9 +75,9 @@ public void testDeserializationAsFloat01WithoutTimeZone() throws Exception OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); OffsetDateTime value = MAPPER.readValue("0.000000000", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -88,9 +88,9 @@ public void testDeserializationAsFloat01WithTimeZone() throws Exception .setTimeZone(TimeZone.getDefault()); OffsetDateTime value = m.readValue("0.000000000", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -100,9 +100,9 @@ public void testDeserializationAsFloat02WithoutTimeZone() throws Exception OffsetDateTime value = MAPPER.readValue("123456789.183917322", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -114,9 +114,9 @@ public void testDeserializationAsFloat02WithTimeZone() throws Exception .with(TimeZone.getDefault()) .readValue("123456789.183917322"); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -128,9 +128,9 @@ public void testDeserializationAsFloat03WithoutTimeZone() throws Exception DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), OffsetDateTime.class ); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -144,9 +144,9 @@ public void testDeserializationAsFloat03WithTimeZone() throws Exception DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), OffsetDateTime.class ); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -157,9 +157,9 @@ public void testDeserializationAsInt01NanosecondsWithoutTimeZone() throws Except .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetDateTime value = m.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -171,9 +171,9 @@ public void testDeserializationAsInt01NanosecondsWithTimeZone() throws Exception .setTimeZone(TimeZone.getDefault()); OffsetDateTime value = m.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -184,9 +184,9 @@ public void testDeserializationAsInt01MillisecondsWithoutTimeZone() throws Excep .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); OffsetDateTime value = m.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -198,9 +198,9 @@ public void testDeserializationAsInt01MillisecondsWithTimeZone() throws Exceptio .setTimeZone(TimeZone.getDefault()); OffsetDateTime value = m.readValue("0", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -212,9 +212,9 @@ public void testDeserializationAsInt02NanosecondsWithoutTimeZone() throws Except .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetDateTime value = m.readValue("123456789", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -226,9 +226,9 @@ public void testDeserializationAsInt02NanosecondsWithTimeZone() throws Exception .setTimeZone(TimeZone.getDefault()); OffsetDateTime value = m.readValue("123456789", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -239,9 +239,9 @@ public void testDeserializationAsInt02MillisecondsWithoutTimeZone() throws Excep .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); OffsetDateTime value = m.readValue("123456789422", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -253,9 +253,9 @@ public void testDeserializationAsInt02MillisecondsWithTimeZone() throws Exceptio .setTimeZone(TimeZone.getDefault()); OffsetDateTime value = m.readValue("123456789422", OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -268,9 +268,9 @@ public void testDeserializationAsInt03NanosecondsWithoutTimeZone() throws Except .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, true); OffsetDateTime value = m.readValue(Long.toString(date.toEpochSecond()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -284,9 +284,9 @@ public void testDeserializationAsInt03NanosecondsWithTimeZone() throws Exception .setTimeZone(TimeZone.getDefault()); OffsetDateTime value = m.readValue(Long.toString(date.toEpochSecond()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -300,9 +300,9 @@ public void testDeserializationAsInt03MillisecondsWithoutTimeZone() throws Excep OffsetDateTime value = m.readValue(Long.toString(date.toInstant().toEpochMilli()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -317,9 +317,9 @@ public void testDeserializationAsInt03MillisecondsWithTimeZone() throws Exceptio OffsetDateTime value = m.readValue(Long.toString(date.toInstant().toEpochMilli()), OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -331,10 +331,10 @@ public void testDeserializationAsInt04NanosecondsWithoutTimeZone() throws Except a2q("{'value':123456789}"), WrapperWithReadTimestampsAsNanosEnabled.class); - assertNotNull("The actual should not be null.", actual); - assertNotNull("The actual value should not be null.", actual.value); + assertNotNull(actual, "The actual should not be null."); + assertNotNull(actual.value, "The actual value should not be null."); assertIsEqual(date, actual.value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, actual.value.getOffset()); + assertEquals(ZoneOffset.UTC, actual.value.getOffset(), "The time zone is not correct."); } @Test @@ -347,10 +347,10 @@ public void testDeserializationAsInt04NanosecondsWithTimeZone() throws Exception a2q("{'value':123456789}"), WrapperWithReadTimestampsAsNanosEnabled.class); - assertNotNull("The actual should not be null.", actual); - assertNotNull("The actual value should not be null.", actual.value); + assertNotNull(actual, "The actual should not be null."); + assertNotNull(actual.value, "The actual value should not be null."); assertIsEqual(date, actual.value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), actual.value.getOffset()); + assertEquals(getDefaultOffset(date), actual.value.getOffset(), "The time zone is not correct."); } @Test @@ -362,10 +362,10 @@ public void testDeserializationAsInt04MillisecondsWithoutTimeZone() throws Excep a2q("{'value':123456789422}"), WrapperWithReadTimestampsAsNanosDisabled.class); - assertNotNull("The actual should not be null.", actual); - assertNotNull("The actual value should not be null.", actual.value); + assertNotNull(actual, "The actual should not be null."); + assertNotNull(actual.value, "The actual value should not be null."); assertIsEqual(date, actual.value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, actual.value.getOffset()); + assertEquals(ZoneOffset.UTC, actual.value.getOffset(), "The time zone is not correct."); } @Test @@ -378,10 +378,10 @@ public void testDeserializationAsInt04MillisecondsWithTimeZone() throws Exceptio a2q("{'value':123456789422}"), WrapperWithReadTimestampsAsNanosDisabled.class); - assertNotNull("The actual should not be null.", actual); - assertNotNull("The actual value should not be null.", actual.value); + assertNotNull(actual, "The actual should not be null."); + assertNotNull(actual.value, "The actual value should not be null."); assertIsEqual(date, actual.value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), actual.value.getOffset()); + assertEquals(getDefaultOffset(date), actual.value.getOffset(), "The time zone is not correct."); } @Test @@ -393,7 +393,7 @@ public void testDeserializationAsString01WithoutTimeZone() throws Exception OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -406,7 +406,7 @@ public void testDeserializationAsString01WithTimeZone() throws Exception OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -419,7 +419,7 @@ public void testDeserializationAsString01WithTimeZoneTurnedOff() throws Exceptio OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z1), value.getOffset()); + assertEquals(getOffset(value, Z1), value.getOffset(), "The time zone is not correct."); } @Test @@ -433,7 +433,7 @@ public void testDeserializationAsString01WithTimeZoneColonless() throws Exceptio OffsetDateTime value = r.readValue('"' + sDate + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z1), value.getOffset()); + assertEquals(getOffset(value, Z1), value.getOffset(), "The time zone is not correct."); } @Test @@ -445,7 +445,7 @@ public void testDeserializationAsString02WithoutTimeZone() throws Exception OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -458,7 +458,7 @@ public void testDeserializationAsString02WithTimeZone() throws Exception OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -470,9 +470,9 @@ public void testDeserializationAsString02WithTimeZoneTurnedOff() throws Exceptio .setTimeZone(TimeZone.getDefault()); OffsetDateTime value = m.readValue('"' + FORMATTER.format(date) + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z2), value.getOffset()); + assertEquals(getOffset(value, Z2), value.getOffset(), "The time zone is not correct."); } @Test @@ -486,9 +486,9 @@ public void testDeserializationAsString02WithTimeZoneColonless() throws Exceptio OffsetDateTime value = m.readValue('"' + sDate + '"', OffsetDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z2), value.getOffset()); + assertEquals(getOffset(value, Z2), value.getOffset(), "The time zone is not correct."); } @Test @@ -500,7 +500,7 @@ public void testDeserializationAsString03WithoutTimeZone() throws Exception OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, value.getOffset()); + assertEquals(ZoneOffset.UTC, value.getOffset(), "The time zone is not correct."); } @Test @@ -513,7 +513,7 @@ public void testDeserializationAsString03WithTimeZone() throws Exception OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), value.getOffset()); + assertEquals(getDefaultOffset(date), value.getOffset(), "The time zone is not correct."); } @Test @@ -526,7 +526,7 @@ public void testDeserializationAsString03WithTimeZoneTurnedOff() throws Exceptio OffsetDateTime value = r.readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z3), value.getOffset()); + assertEquals(getOffset(value, Z3), value.getOffset(), "The time zone is not correct."); } @@ -541,7 +541,7 @@ public void testDeserializationAsString03WithTimeZoneColonless() throws Exceptio OffsetDateTime value = r.readValue('"' + sDate + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", getOffset(value, Z3), value.getOffset()); + assertEquals(getOffset(value, Z3), value.getOffset(), "The time zone is not correct."); } @Test @@ -554,9 +554,9 @@ public void testDeserializationWithTypeInfo01WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -570,9 +570,9 @@ public void testDeserializationWithTypeInfo01WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -586,9 +586,9 @@ public void testDeserializationWithTypeInfo02WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -603,9 +603,9 @@ public void testDeserializationWithTypeInfo02WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -619,9 +619,9 @@ public void testDeserializationWithTypeInfo03WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789422]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -636,9 +636,9 @@ public void testDeserializationWithTypeInfo03WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",123456789422]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -652,9 +652,9 @@ public void testDeserializationWithTypeInfo04WithoutTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", ZoneOffset.UTC, ((OffsetDateTime) value).getOffset()); + assertEquals(ZoneOffset.UTC, ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -669,9 +669,9 @@ public void testDeserializationWithTypeInfo04WithTimeZone() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); assertIsEqual(date, (OffsetDateTime) value); - assertEquals("The time zone is not correct.", getDefaultOffset(date), ((OffsetDateTime) value).getOffset()); + assertEquals(getDefaultOffset(date), ((OffsetDateTime) value).getOffset(), "The time zone is not correct."); } @Test @@ -687,10 +687,10 @@ public void testDeserializationWithTypeInfo04WithTimeZoneTurnedOff() throws Exce "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); OffsetDateTime cast = (OffsetDateTime) value; assertIsEqual(date, cast); - assertEquals("The time zone is not correct.", getOffset(cast, Z3), cast.getOffset()); + assertEquals(getOffset(cast, Z3), cast.getOffset(), "The time zone is not correct."); } @Test @@ -744,10 +744,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); OffsetDateTime actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting", null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test ( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "OffsetDateTime"; @@ -762,7 +762,7 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } // [module-java8#166] @@ -778,8 +778,8 @@ public void testDeserializationNoAdjustIfMIN() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value, "The value should not be null."); + assertTrue(value instanceof OffsetDateTime, "The value should be an OffsetDateTime."); OffsetDateTime actualValue = (OffsetDateTime) value; assertIsEqual(date, actualValue); assertEquals(date.getOffset(),actualValue.getOffset()); @@ -797,8 +797,8 @@ public void testDeserializationNoAdjustIfMAX() throws Exception "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an OffsetDateTime.", value instanceof OffsetDateTime); + assertNotNull(value, "The value should not be null."); + assertInstanceOf(OffsetDateTime.class, value, "The value should be an OffsetDateTime."); OffsetDateTime actualValue = (OffsetDateTime) value; assertIsEqual(date, actualValue); assertEquals(date.getOffset(),actualValue.getOffset()); @@ -856,8 +856,8 @@ private void _testOffsetDateTimeMinOrMax(OffsetDateTime offsetDateTime) private static void assertIsEqual(OffsetDateTime expected, OffsetDateTime actual) { - assertTrue("The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">.", - expected.isEqual(actual)); + assertTrue(expected.isEqual(actual), + "The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">."); } private static ZoneOffset getDefaultOffset(OffsetDateTime date) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java index aadf62fc..4ddbb78f 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java @@ -12,8 +12,6 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - import java.io.IOException; import java.time.OffsetTime; import java.time.ZoneOffset; @@ -22,11 +20,9 @@ import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class OffsetTimeDeserTest extends ModuleTestBase { @@ -39,7 +35,7 @@ static class Pojo45s { public List objects; } - static class Pojo45 { + static class Pojo45 { public java.time.LocalDate partDate; public java.time.OffsetTime starttime; public java.time.OffsetTime endtime; @@ -76,8 +72,8 @@ public void testDeserializationAsTimestamp01() throws Exception .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[15,43,\"+0300\"]"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -86,8 +82,8 @@ public void testDeserializationAsTimestamp02() throws Exception OffsetTime time = OffsetTime.of(9, 22, 57, 0, ZoneOffset.of("-0630")); OffsetTime value = READER.readValue("[9,22,57,\"-06:30\"]"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -98,32 +94,30 @@ public void testDeserializationAsTimestamp03Nanoseconds() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[9,22,0,57,\"-06:30\"]"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertEquals(time, value, "The value is not correct."); } @Test - public void testDeserializationAsTimestamp03Milliseconds() throws Exception - { + public void testDeserializationAsTimestamp03Milliseconds() throws Exception { OffsetTime time = OffsetTime.of(9, 22, 0, 57000000, ZoneOffset.of("-0630")); OffsetTime value = READER .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[9,22,0,57,\"-06:30\"]"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertEquals(time, value, "The value is not correct."); } @Test - public void testDeserializationAsTimestamp04Nanoseconds() throws Exception - { + public void testDeserializationAsTimestamp04Nanoseconds() throws Exception { OffsetTime time = OffsetTime.of(22, 31, 5, 829837, ZoneOffset.of("+1100")); OffsetTime value = READER .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[22,31,5,829837,\"+11:00\"]"); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -133,7 +127,7 @@ public void testDeserializationAsTimestamp04Milliseconds01() throws Exception OffsetTime value = READER .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[22,31,5,829837,\"+11:00\"]"); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -143,7 +137,7 @@ public void testDeserializationAsTimestamp04Milliseconds02() throws Exception OffsetTime value = READER .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("[22,31,5,829,\"+11:00\"]"); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); } @Test @@ -155,8 +149,8 @@ public void testDeserializationAsTimestamp05Nanoseconds() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(a2q("{'value':[9,22,0,57,'-06:30']}")); - assertNotNull("The value should not be null.", actual); - assertEquals("The value is not correct.", time, actual.value); + assertNotNull(actual, "The value should not be null."); + assertEquals(time, actual.value, "The value is not correct."); } @Test @@ -168,8 +162,8 @@ public void testDeserializationAsTimestamp05Milliseconds01() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(a2q("{'value':[9,22,0,57,'-06:30']}")); - assertNotNull("The value should not be null.", actual); - assertEquals("The value is not correct.", time, actual.value); + assertNotNull(actual, "The value should not be null."); + assertEquals(time, actual.value, "The value is not correct."); } @Test @@ -181,8 +175,8 @@ public void testDeserializationAsTimestamp05Milliseconds02() throws Exception .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(a2q("{'value':[9,22,0,4257,'-06:30']}")); - assertNotNull("The value should not be null.", actual); - assertEquals("The value is not correct.", time, actual.value); + assertNotNull(actual, "The value should not be null."); + assertEquals(time, actual.value, "The value is not correct."); } @Test @@ -190,15 +184,15 @@ public void testDeserializationFromString01() throws Exception { OffsetTime time = OffsetTime.of(15, 43, 0, 0, ZoneOffset.of("+0300")); OffsetTime value = READER.readValue('"' + time.toString() + '"'); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); time = OffsetTime.of(9, 22, 57, 0, ZoneOffset.of("-0630")); value = READER.readValue('"' + time.toString() + '"'); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); time = OffsetTime.of(22, 31, 5, 829837, ZoneOffset.of("+1100")); value = READER.readValue('"' + time.toString() + '"'); - assertEquals("The value is not correct.", time, value); + assertEquals(time, value, "The value is not correct."); expectSuccess(OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC), "'12:00Z'"); } @@ -208,7 +202,7 @@ public void testBadDeserializationFromString01() throws Throwable { expectFailure(q("notanoffsettime")); } - + @Test public void testDeserializationWithTypeInfo01() throws Exception { @@ -221,9 +215,9 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + OffsetTime.class.getName() + "\",[22,31,5,829837,\"+11:00\"]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a OffsetTime.", value instanceof OffsetTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertInstanceOf(OffsetTime.class, value, "The value should be a OffsetTime."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -238,9 +232,9 @@ public void testDeserializationWithTypeInfo02() throws Exception "[\"" + OffsetTime.class.getName() + "\",[22,31,5,422,\"+11:00\"]]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a OffsetTime.", value instanceof OffsetTime); - assertEquals("The value is not correct.", time, value); + assertNotNull(value, "The value should not be null."); + assertInstanceOf(OffsetTime.class, value, "The value should be a OffsetTime."); + assertEquals(time, value, "The value is not correct."); } @Test @@ -252,9 +246,9 @@ public void testDeserializationWithTypeInfo03() throws Exception mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = mapper.readValue( "[\"" + OffsetTime.class.getName() + "\",\"" + time.toString() + "\"]", Temporal.class - ); - assertTrue("The value should be a OffsetTime.", value instanceof OffsetTime); - assertEquals("The value is not correct.", time, value); + ); + assertTrue(value instanceof OffsetTime, "The value should be a OffsetTime."); + assertEquals(time, value, "The value is not correct."); } // for [datatype-jsr310#45] @@ -279,14 +273,14 @@ public void testDeserializationAsArrayDisabled() throws Throwable // OK } } - + @Test public void testDeserializationAsEmptyArrayDisabled() throws Throwable { // works even without the feature enabled assertNull(read("[]")); } - + @Test public void testDeserializationAsArrayEnabled() throws Throwable { @@ -325,10 +319,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); OffsetTime actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting", null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test ( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "OffsetTime"; @@ -343,7 +337,7 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } private void expectFailure(String json) throws Throwable { @@ -362,8 +356,8 @@ private void expectFailure(String json) throws Throwable { private void expectSuccess(Object exp, String json) throws IOException { final OffsetTime value = read(json); - notNull(value); - expect(exp, value); + assertNotNull(value, "The value should not be null."); + assertEquals(exp, value, "The value is not correct."); } private OffsetTime read(final String json) throws IOException { @@ -371,10 +365,10 @@ private OffsetTime read(final String json) throws IOException { } private static void notNull(Object value) { - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); } private static void expect(Object exp, Object value) { - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java index 223552db..0e4d3eea 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java @@ -3,8 +3,8 @@ import java.time.Month; import java.time.temporal.TemporalAccessor; -import org.junit.Test; -import org.junit.function.ThrowingRunnable; +import org.junit.jupiter.api.function.Executable; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; @@ -18,7 +18,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class OneBasedMonthDeserTest extends ModuleTestBase { @@ -63,9 +63,9 @@ public void testBadDeserializationAsString01_oneBased() { ); } - static void assertError(ThrowingRunnable codeToRun, Class expectedException, String expectedMessage) { + static void assertError(Executable codeToRun, Class expectedException, String expectedMessage) { try { - codeToRun.run(); + codeToRun.execute(); fail(String.format("Expecting %s, but nothing was thrown!", expectedException.getName())); } catch (Throwable actualException) { if (!expectedException.isInstance(actualException)) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/PeriodDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/PeriodDeserTest.java index b1190924..53f5ff29 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/PeriodDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/PeriodDeserTest.java @@ -20,6 +20,8 @@ import java.time.temporal.TemporalAmount; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -28,10 +30,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.*; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.*; public class PeriodDeserTest extends ModuleTestBase { @@ -43,7 +42,7 @@ public void testDeserialization01() throws Exception { Period period = Period.of(1, 6, 15); Period value = MAPPER.readValue('"' + period.toString() + '"', Period.class); - assertEquals("The value is not correct.", period, value); + assertEquals(period, value, "The value is not correct."); } @Test @@ -51,7 +50,7 @@ public void testDeserialization02() throws Exception { Period period = Period.of(0, 0, 21); Period value = MAPPER.readValue('"' + period.toString() + '"', Period.class); - assertEquals("The value is not correct.", period, value); + assertEquals(period, value, "The value is not correct."); } @Test @@ -66,9 +65,9 @@ public void testDeserializationWithTypeInfo01() throws Exception "[\"" + Period.class.getName() + "\",\"" + period.toString() + "\"]", TemporalAmount.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a Period.", value instanceof Period); - assertEquals("The value is not correct.", period, value); + assertNotNull(value, "The value should not be null."); + assertInstanceOf(Period.class, value, "The value should be a Period."); + assertEquals(period, value, "The value is not correct."); } /* @@ -92,10 +91,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); Period actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting",null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "period"; @@ -109,6 +108,6 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap("date", "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserTest.java index 3ca84695..dffd53e2 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserTest.java @@ -23,6 +23,8 @@ import java.util.Map; import java.util.Objects; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -34,13 +36,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class YearDeserTest extends ModuleTestBase { @@ -62,8 +58,8 @@ public FormattedYear(Year year) { @Test public void testDeserializationAsString01() throws Exception { - assertEquals("The value is not correct.",Year.of(2000), - READER.readValue(q("2000"))); + assertEquals(Year.of(2000), READER.readValue(q("2000")), + "The value is not correct."); } @Test @@ -115,7 +111,7 @@ public void testDeserializationAsArrayEnabled() throws Throwable Year value= newMapper() .configure(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS, true) .readerFor(Year.class).readValue("[\"2000\"]"); - assertEquals("The value is not correct.", Year.of(2000), value); + assertEquals(Year.of(2000), value, "The value is not correct."); } @Test @@ -133,9 +129,9 @@ public void testDeserializationAsEmptyArrayEnabled() throws Throwable public void testDefaultDeserialization() throws Exception { Year value = READER.readValue("1986"); - assertEquals("The value is not correct.", Year.of(1986), value); + assertEquals(Year.of(1986), value, "The value is not correct."); value = READER.readValue("2013"); - assertEquals("The value is not correct.", Year.of(2013), value); + assertEquals(Year.of(2013), value, "The value is not correct."); } @Test @@ -144,8 +140,8 @@ public void testDeserializationWithTypeInfo() throws Exception ObjectMapper mapper = newMapper() .addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = mapper.readValue("[\"" + Year.class.getName() + "\",2005]", Temporal.class); - assertTrue("The value should be a Year.", value instanceof Year); - assertEquals("The value is not correct.", Year.of(2005), value); + assertTrue(value instanceof Year, "The value should be a Year."); + assertEquals(Year.of(2005), value, "The value is not correct."); } @Test diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserTest.java index b4740b4e..dc8bc2ae 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserTest.java @@ -6,6 +6,8 @@ import java.time.format.DateTimeParseException; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -17,12 +19,7 @@ import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class YearMonthDeserTest extends ModuleTestBase { @@ -119,10 +116,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, dateValAsEmptyStr)); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); YearMonth actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting",null, actualDateFromEmptyStr); + assertNull(actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "YearMonth"; @@ -136,7 +133,7 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap("date", "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } private void expectFailure(String json) throws Exception { @@ -166,10 +163,10 @@ private YearMonth read(final String json) throws Exception { } private static void notNull(Object value) { - assertNotNull("The value should not be null.", value); + assertNotNull(value, "The value should not be null."); } private static void expect(Object exp, Object value) { - assertEquals("The value is not correct.", exp, value); + assertEquals(exp, value, "The value is not correct."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneIdDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneIdDeserTest.java index 84e0f000..c1420f12 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneIdDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneIdDeserTest.java @@ -16,12 +16,11 @@ package com.fasterxml.jackson.datatype.jsr310.deser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - import java.time.ZoneId; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -30,7 +29,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class ZoneIdDeserTest extends ModuleTestBase { @@ -44,22 +43,25 @@ public class ZoneIdDeserTest extends ModuleTestBase @Test public void testDeserialization01() throws Exception { - assertEquals("The value is not correct.", ZoneId.of("America/Chicago"), - MAPPER.readValue("\"America/Chicago\"", ZoneId.class)); + assertEquals(ZoneId.of("America/Chicago"), + MAPPER.readValue("\"America/Chicago\"", ZoneId.class), + "The value is not correct."); } @Test public void testDeserialization02() throws Exception { - assertEquals("The value is not correct.", ZoneId.of("America/Anchorage"), - MAPPER.readValue("\"America/Anchorage\"", ZoneId.class)); + assertEquals(ZoneId.of("America/Anchorage"), + MAPPER.readValue("\"America/Anchorage\"", ZoneId.class), + "The value is not correct."); } @Test public void testDeserializationWithTypeInfo02() throws Exception { ZoneId value = MOCK_OBJECT_MIXIN_MAPPER.readValue("[\"" + ZoneId.class.getName() + "\",\"America/Denver\"]", ZoneId.class); - assertEquals("The value is not correct.", ZoneId.of("America/Denver"), value); + assertEquals(ZoneId.of("America/Denver"), value, + "The value is not correct."); } /* @@ -83,10 +85,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); ZoneId actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting", null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test ( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "zoneId"; @@ -101,6 +103,6 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneOffsetDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneOffsetDeserTest.java index e67ffe09..f067ea30 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneOffsetDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZoneOffsetDeserTest.java @@ -20,10 +20,7 @@ import java.time.ZoneOffset; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.type.TypeReference; @@ -35,7 +32,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class ZoneOffsetDeserTest extends ModuleTestBase { @@ -46,12 +43,12 @@ public class ZoneOffsetDeserTest extends ModuleTestBase @Test public void testDeserializationFromString() throws Exception { - assertEquals("The value is not correct.", ZoneOffset.of("Z"), - READER.readValue("\"Z\"")); - assertEquals("The value is not correct.", ZoneOffset.of("+0300"), - READER.readValue(q("+0300"))); - assertEquals("The value is not correct.", ZoneOffset.of("-0630"), - READER.readValue("\"-06:30\"")); + assertEquals(ZoneOffset.of("Z"), READER.readValue("\"Z\""), + "The value is not correct."); + assertEquals(ZoneOffset.of("+0300"), READER.readValue(q("+0300")), + "The value is not correct."); + assertEquals(ZoneOffset.of("-0630"), READER.readValue("\"-06:30\""), + "The value is not correct."); } @Test @@ -60,8 +57,8 @@ public void testDeserializationWithTypeInfo03() throws Exception ObjectMapper mapper = newMapper() .addMixIn(ZoneId.class, MockObjectConfiguration.class); ZoneId value = mapper.readValue("[\"" + ZoneOffset.class.getName() + "\",\"+0415\"]", ZoneId.class); - assertTrue("The value should be a ZoneOffset.", value instanceof ZoneOffset); - assertEquals("The value is not correct.", ZoneOffset.of("+0415"), value); + assertTrue(value instanceof ZoneOffset, "The value should be a ZoneOffset."); + assertEquals(ZoneOffset.of("+0415"), value, "The value is not correct."); } @Test @@ -111,7 +108,7 @@ public void testDeserializationAsArrayEnabled() throws Throwable ZoneOffset value = READER .with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) .readValue("[\"+0300\"]"); - assertEquals("The value is not correct.", ZoneOffset.of("+0300"), value); + assertEquals(ZoneOffset.of("+0300"), value, "The value is not correct."); } @Test @@ -145,10 +142,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); ZoneId actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting", null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test ( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "zoneOffset"; @@ -163,6 +160,6 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java index 4f6388cd..1b101cfa 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/ZonedDateTimeDeserTest.java @@ -14,7 +14,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.time.LocalDateTime; @@ -28,9 +28,7 @@ import java.util.Map; import java.util.TimeZone; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class ZonedDateTimeDeserTest extends ModuleTestBase { @@ -71,9 +69,9 @@ public WrapperWithReadTimestampsAsNanosEnabled() { } @Test public void testDeserFromString() throws Exception { - assertEquals("The value is not correct.", - ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC), - READER.readValue(q("2000-01-01T12:00Z"))); + assertEquals(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC), + READER.readValue(q("2000-01-01T12:00Z")), + "The value is not correct."); } // [modules-java#281] @@ -82,9 +80,9 @@ public void testDeserFromStringNoZoneIdNormalization() throws Exception { // 11-Nov-2023, tatu: Not sure this is great test but... does show diff // behavior with and without `JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID` - assertEquals("The value is not correct.", - ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, TimeZone.getTimeZone("UTC").toZoneId()), - READER_NON_NORMALIZED_ZONEID.readValue(q("2000-01-01T12:00Z"))); + assertEquals(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, TimeZone.getTimeZone("UTC").toZoneId()), + READER_NON_NORMALIZED_ZONEID.readValue(q("2000-01-01T12:00Z")), + "The value is not correct."); } @Test @@ -96,7 +94,7 @@ public void testDeserializationAsInt01() throws Exception ZoneOffset.UTC); WrapperWithReadTimestampsAsNanosDisabled actual = reader.readValue(a2q("{'value':1001}")); - assertEquals("The value is not correct.", date, actual.value); + assertEquals(date, actual.value, "The value is not correct."); } @Test @@ -108,7 +106,7 @@ public void testDeserializationAsInt02() throws Exception ZoneOffset.UTC); WrapperWithReadTimestampsAsNanosEnabled actual = reader.readValue(a2q("{'value':1}")); - assertEquals("The value is not correct.", date, actual.value); + assertEquals(date, actual.value, "The value is not correct."); } @Test @@ -116,9 +114,9 @@ public void testDeserializationComparedToStandard() throws Throwable { String inputString = "2021-02-01T19:49:04.0513486Z"; - assertEquals("The value is not correct.", - DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(inputString, ZonedDateTime::from), - READER.readValue(q(inputString))); + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(inputString, ZonedDateTime::from), + READER.readValue(q(inputString)), + "The value is not correct."); } @Test @@ -130,9 +128,9 @@ public void testDeserializationComparedToStandard2() throws Throwable .configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, false) .readerFor(ZonedDateTime.class).readValue(q(inputString)); - assertEquals("The value is not correct.", - DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(inputString, ZonedDateTime::from), - converted); + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(inputString, ZonedDateTime::from), + converted, + "The value is not correct."); } @Test @@ -185,9 +183,9 @@ public void testDeserializationAsArrayEnabled() throws Throwable ZonedDateTime value = newMapper() .configure(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS, true) .readerFor(ZonedDateTime.class).readValue(a2q(json)); - assertEquals("The value is not correct.", - ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC), - value); + assertEquals(ZonedDateTime.of(2000, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC), + value, + "The value is not correct."); } @@ -208,9 +206,9 @@ public void testDeserializationWithZonePreserved() throws Throwable WrapperWithFeatures wrapper = newMapper() .readerFor(WrapperWithFeatures.class) .readValue("{\"value\":\"2000-01-01T12:00+01:00\"}"); - assertEquals("Timezone should be preserved.", - ZonedDateTime.of(2000, 1, 1, 12, 0, 0 ,0, ZoneOffset.ofHours(1)), - wrapper.value); + assertEquals(ZonedDateTime.of(2000, 1, 1, 12, 0, 0 ,0, ZoneOffset.ofHours(1)), + wrapper.value, + "Timezone should be preserved."); } /* @@ -234,10 +232,10 @@ public void testLenientDeserializeFromEmptyString() throws Exception { String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); Map actualMapFromEmptyStr = objectReader.readValue(valueFromEmptyStr); ZonedDateTime actualDateFromEmptyStr = actualMapFromEmptyStr.get(key); - assertEquals("empty string failed to deserialize to null with lenient setting", null, actualDateFromEmptyStr); + assertEquals(null, actualDateFromEmptyStr, "empty string failed to deserialize to null with lenient setting"); } - @Test ( expected = MismatchedInputException.class) + @Test public void testStrictDeserializeFromEmptyString() throws Exception { final String key = "zonedDateTime"; @@ -252,7 +250,7 @@ public void testStrictDeserializeFromEmptyString() throws Exception { assertNull(actualMapFromNullStr.get(key)); String valueFromEmptyStr = mapper.writeValueAsString(asMap(key, "")); - objectReader.readValue(valueFromEmptyStr); + assertThrows(MismatchedInputException.class, () -> objectReader.readValue(valueFromEmptyStr)); } /* @@ -268,9 +266,9 @@ public void testDeserializationWithoutColonInOffset() throws Throwable .readerFor(WrapperWithFeatures.class) .readValue("{\"value\":\"2000-01-01T12:00+0100\"}"); - assertEquals("Value parses as if it were with colon", - ZonedDateTime.of(2000, 1, 1, 12, 0, 0 ,0, ZoneOffset.ofHours(1)), - wrapper.value); + assertEquals(ZonedDateTime.of(2000, 1, 1, 12, 0, 0 ,0, ZoneOffset.ofHours(1)), + wrapper.value, + "Value parses as if it were with colon"); } @Test @@ -279,9 +277,9 @@ public void testDeserializationWithoutColonInTimeZoneWithTZDB() throws Throwable WrapperWithFeatures wrapper = newMapper() .readerFor(WrapperWithFeatures.class) .readValue("{\"value\":\"2000-01-01T12:00+0100[Europe/Paris]\"}"); - assertEquals("Timezone should be preserved.", - ZonedDateTime.of(2000, 1, 1, 12, 0, 0 ,0, ZoneId.of("Europe/Paris")), - wrapper.value); + assertEquals(ZonedDateTime.of(2000, 1, 1, 12, 0, 0 ,0, ZoneId.of("Europe/Paris")), + wrapper.value, + "Timezone should be preserved."); } @Test diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java index 02b23c9a..096e2255 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.type.TypeReference; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; @@ -10,8 +10,7 @@ import java.time.ZonedDateTime; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assume.*; +import static org.junit.jupiter.api.Assertions.*; // for [modules-java8#306] public class ZonedDateTimeKeyDeserializerTest @@ -41,7 +40,7 @@ public void ZonedDateTime_with_zone_name_can_be_deserialized() throws Exception @Test public void ZonedDateTime_with_place_name_can_be_deserialized() throws Exception { - assumeFalse(System.getProperty("java.version").startsWith("1.8")); + assertFalse(System.getProperty("java.version").startsWith("1.8")); Map map = MAPPER.readValue(getMap("2015-07-24T12:23:34.184Z[Europe/London]"), MAP_TYPE_REF); @@ -52,7 +51,7 @@ public void ZonedDateTime_with_place_name_can_be_deserialized() throws Exception @Test public void ZonedDateTime_with_place_name_can_be_deserialized_Java_8() throws Exception { // Java 8 parses this format incorrectly due to https://bugs.openjdk.org/browse/JDK-8066982 - assumeTrue(System.getProperty("java.version").startsWith("1.8")); + assertTrue(System.getProperty("java.version").startsWith("1.8")); Map map = MAPPER.readValue(getMap("2015-07-24T12:23:34.184Z[Europe/London]"), MAP_TYPE_REF); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/DurationDeser337Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/DurationDeser337Test.java index 94f1f0f1..72d393fb 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/DurationDeser337Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/DurationDeser337Test.java @@ -2,13 +2,13 @@ import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DurationDeser337Test extends ModuleTestBase { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/InstanceViaBigDecimal307Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/InstanceViaBigDecimal307Test.java index 5f27f033..ee71a563 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/InstanceViaBigDecimal307Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/InstanceViaBigDecimal307Test.java @@ -2,13 +2,13 @@ import java.time.Instant; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; // [modules-java8#307]: Loss of precision via JsonNode for BigDecimal-valued // things (like Instant) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/JDKSerializabilityTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/JDKSerializabilityTest.java index 6e2487b7..60e98f96 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/JDKSerializabilityTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/JDKSerializabilityTest.java @@ -3,13 +3,13 @@ import java.io.*; import java.time.Year; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.datatype.jsr310.*; import com.fasterxml.jackson.databind.*; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class JDKSerializabilityTest extends ModuleTestBase { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java index c0a29463..e0eada25 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java @@ -4,13 +4,13 @@ import java.time.ZoneId; import java.time.temporal.ChronoUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class OffsetDateTimeDeser279Test extends ModuleTestBase { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/ZonedDateTimeIssue244Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/ZonedDateTimeIssue244Test.java index eedb7699..93ae95a6 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/ZonedDateTimeIssue244Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/ZonedDateTimeIssue244Test.java @@ -4,12 +4,13 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; /** * Test case for https://github.com/FasterXML/jackson-modules-java8/issues/244 diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/DurationAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/DurationAsKeyTest.java index 9ef5bef8..03f5910f 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/DurationAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/DurationAsKeyTest.java @@ -1,17 +1,17 @@ package com.fasterxml.jackson.datatype.jsr310.key; -import static org.junit.Assert.assertEquals; - import java.time.Duration; import java.util.Collections; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class DurationAsKeyTest extends ModuleTestBase { @@ -23,13 +23,12 @@ public class DurationAsKeyTest extends ModuleTestBase @Test public void testSerialization() throws Exception { - assertEquals("Value is not correct", mapAsString(DURATION_STRING, "test"), + assertEquals(mapAsString(DURATION_STRING, "test"), MAPPER.writeValueAsString(Collections.singletonMap(DURATION, "test"))); } @Test public void testDeserialization() throws Exception { - assertEquals("Value is not correct", Collections.singletonMap(DURATION, "test"), - READER.readValue(mapAsString(DURATION_STRING, "test"))); + assertEquals(Collections.singletonMap(DURATION, "test"), READER.readValue(mapAsString(DURATION_STRING, "test"))); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/InstantAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/InstantAsKeyTest.java index 8f4748d3..41ef8900 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/InstantAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/InstantAsKeyTest.java @@ -1,17 +1,16 @@ package com.fasterxml.jackson.datatype.jsr310.key; -import static org.junit.Assert.assertEquals; - import java.time.Instant; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class InstantAsKeyTest extends ModuleTestBase { @@ -26,26 +25,26 @@ public class InstantAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { String value = MAPPER.writeValueAsString(asMap(INSTANT_0, "test")); - Assert.assertEquals("Value is incorrect", mapAsString(INSTANT_0_STRING, "test"), value); + assertEquals(mapAsString(INSTANT_0_STRING, "test"), value); } @Test public void testSerialization1() throws Exception { String value = MAPPER.writeValueAsString(asMap(INSTANT, "test")); - assertEquals("Value is incorrect", mapAsString(INSTANT_STRING, "test"), value); + assertEquals(mapAsString(INSTANT_STRING, "test"), value); } @Test public void testDeserialization0() throws Exception { Map value = READER.readValue(mapAsString(INSTANT_0_STRING, "test")); Map EXP = asMap(INSTANT_0, "test"); - assertEquals("Value is incorrect", EXP, value); + assertEquals(EXP, value, "Value is incorrect"); } @Test public void testDeserialization1() throws Exception { Map value = READER.readValue(mapAsString(INSTANT_STRING, "test")); Map EXP = asMap(INSTANT, "test"); - assertEquals("Value is incorrect", EXP, value); + assertEquals(EXP, value, "Value is incorrect"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateAsKeyTest.java index 0cefbf03..23fb95aa 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateAsKeyTest.java @@ -1,16 +1,16 @@ package com.fasterxml.jackson.datatype.jsr310.key; -import static org.junit.Assert.assertEquals; - import java.time.LocalDate; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class LocalDateAsKeyTest extends ModuleTestBase { @@ -22,13 +22,12 @@ public class LocalDateAsKeyTest extends ModuleTestBase @Test public void testSerialization() throws Exception { - assertEquals("Incorrect value", mapAsString(DATE_STRING, "test"), + assertEquals(mapAsString(DATE_STRING, "test"), MAPPER.writeValueAsString(asMap(DATE, "test"))); } @Test public void testDeserialization() throws Exception { - assertEquals("Incorrect value", asMap(DATE, "test"), - READER.readValue(mapAsString(DATE_STRING, "test"))); + assertEquals(asMap(DATE, "test"), READER.readValue(mapAsString(DATE_STRING, "test"))); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateTimeAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateTimeAsKeyTest.java index d0da5f94..0c103104 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateTimeAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalDateTimeAsKeyTest.java @@ -1,12 +1,12 @@ package com.fasterxml.jackson.datatype.jsr310.key; -import static org.junit.Assert.assertEquals; - import java.io.IOException; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.ObjectMapper; @@ -14,7 +14,7 @@ import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class LocalDateTimeAsKeyTest extends ModuleTestBase { @@ -33,27 +33,27 @@ public class LocalDateTimeAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { String value = MAPPER.writeValueAsString(asMap(DATE_TIME_0, "test")); - assertEquals("Value is incorrect", mapAsString(DATE_TIME_0_STRING, "test"), value); + assertEquals(mapAsString(DATE_TIME_0_STRING, "test"), value); } @Test public void testSerialization1() throws Exception { String value = MAPPER.writeValueAsString(asMap(DATE_TIME, "test")); - assertEquals("Value is incorrect", mapAsString(DATE_TIME_STRING, "test"), value); + assertEquals(mapAsString(DATE_TIME_STRING, "test"), value); } @Test public void testDeserialization0() throws Exception { Map value = READER.readValue( mapAsString(DATE_TIME_0_STRING, "test")); - assertEquals("Value is incorrect", asMap(DATE_TIME_0, "test"), value); + assertEquals(asMap(DATE_TIME_0, "test"), value, "Value is incorrect"); } @Test public void testDeserialization1() throws Exception { Map value = READER.readValue( mapAsString(DATE_TIME_STRING, "test")); - assertEquals("Value is incorrect", asMap(DATE_TIME, "test"), value); + assertEquals(asMap(DATE_TIME, "test"), value, "Value is incorrect"); } @Test diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalTimeAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalTimeAsKeyTest.java index 3f349239..1416a2e4 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalTimeAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/LocalTimeAsKeyTest.java @@ -3,13 +3,14 @@ import java.time.LocalTime; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class LocalTimeAsKeyTest extends ModuleTestBase { @@ -28,25 +29,25 @@ public class LocalTimeAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(TIME_0_STRING, "test"), + assertEquals(mapAsString(TIME_0_STRING, "test"), MAPPER.writeValueAsString(asMap(TIME_0, "test"))); } @Test public void testSerialization1() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(TIME_STRING, "test"), + assertEquals(mapAsString(TIME_STRING, "test"), MAPPER.writeValueAsString(asMap(TIME, "test"))); } @Test public void testDeserialization0() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(TIME_0, "test"), - READER.readValue(mapAsString(TIME_0_STRING, "test"))); + assertEquals(asMap(TIME_0, "test"), READER.readValue(mapAsString(TIME_0_STRING, "test")), + "Value is incorrect"); } @Test public void testDeserialization1() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(TIME, "test"), - READER.readValue(mapAsString(TIME_STRING, "test"))); + assertEquals(asMap(TIME, "test"), READER.readValue(mapAsString(TIME_STRING, "test")), + "Value is incorrect"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/MonthDayAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/MonthDayAsKeyTest.java index add3bccc..99e4c168 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/MonthDayAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/MonthDayAsKeyTest.java @@ -3,13 +3,14 @@ import java.time.MonthDay; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class MonthDayAsKeyTest extends ModuleTestBase { @@ -23,13 +24,13 @@ public class MonthDayAsKeyTest extends ModuleTestBase @Test public void testSerialization() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(MONTH_DAY_STRING, "test"), - MAPPER.writeValueAsString(asMap(MONTH_DAY, "test"))); + assertEquals(mapAsString(MONTH_DAY_STRING, "test"), MAPPER.writeValueAsString(asMap(MONTH_DAY, "test")), + "Value is incorrect"); } @Test public void testDeserialization() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(MONTH_DAY, "test"), - READER.readValue(mapAsString(MONTH_DAY_STRING, "test"))); + assertEquals(asMap(MONTH_DAY, "test"), READER.readValue(mapAsString(MONTH_DAY_STRING, "test")), + "Value is incorrect"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetDateTimeAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetDateTimeAsKeyTest.java index 7c1ffe42..abbf5d56 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetDateTimeAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetDateTimeAsKeyTest.java @@ -5,13 +5,14 @@ import java.time.ZoneOffset; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class OffsetDateTimeAsKeyTest extends ModuleTestBase { @@ -30,36 +31,40 @@ public class OffsetDateTimeAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { String value = MAPPER.writeValueAsString(asMap(DATE_TIME_0, "test")); - Assert.assertEquals("Value is incorrect", mapAsString(DATE_TIME_0_STRING, "test"), value); + assertEquals(mapAsString(DATE_TIME_0_STRING, "test"), value, + "Value is incorrect"); } @Test public void testSerialization1() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(DATE_TIME_1_STRING, "test"), - MAPPER.writeValueAsString(asMap(DATE_TIME_1, "test"))); + assertEquals(mapAsString(DATE_TIME_1_STRING, "test"), + MAPPER.writeValueAsString(asMap(DATE_TIME_1, "test")), + "Value is incorrect"); } @Test public void testSerialization2() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(DATE_TIME_2_STRING, "test"), - MAPPER.writeValueAsString(asMap(DATE_TIME_2, "test"))); + assertEquals(mapAsString(DATE_TIME_2_STRING, "test"), + MAPPER.writeValueAsString(asMap(DATE_TIME_2, "test")), + "Value is incorrect"); } @Test public void testDeserialization0() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(DATE_TIME_0, "test"), - READER.readValue(mapAsString(DATE_TIME_0_STRING, "test"))); + assertEquals(asMap(DATE_TIME_0, "test"), READER.readValue(mapAsString(DATE_TIME_0_STRING, "test")), + "Value is incorrect"); } @Test public void testDeserialization1() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(DATE_TIME_1, "test"), - READER.readValue(mapAsString(DATE_TIME_1_STRING, "test"))); + assertEquals(asMap(DATE_TIME_1, "test"), READER.readValue(mapAsString(DATE_TIME_1_STRING, "test")), + "Value is incorrect"); } @Test public void testDeserialization2() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(DATE_TIME_2, "test"), - READER.readValue(mapAsString(DATE_TIME_2_STRING, "test"))); + assertEquals(asMap(DATE_TIME_2, "test"), + READER.readValue(mapAsString(DATE_TIME_2_STRING, "test")), + "Value is incorrect"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetTimeAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetTimeAsKeyTest.java index 00e59e13..f0517b5c 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetTimeAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/OffsetTimeAsKeyTest.java @@ -4,13 +4,14 @@ import java.time.ZoneOffset; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class OffsetTimeAsKeyTest extends ModuleTestBase { @@ -28,37 +29,42 @@ public class OffsetTimeAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { - Assert.assertEquals(mapAsString(TIME_0_STRING, "test"), + assertEquals(mapAsString(TIME_0_STRING, "test"), MAPPER.writeValueAsString(asMap(TIME_0, "test"))); } @Test public void testSerialization1() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(TIME_1_STRING, "test"), - MAPPER.writeValueAsString(asMap(TIME_1, "test"))); + assertEquals(mapAsString(TIME_1_STRING, "test"), + MAPPER.writeValueAsString(asMap(TIME_1, "test")), + "Value is incorrect"); } @Test public void testSerialization2() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(TIME_2_STRING, "test"), - MAPPER.writeValueAsString(asMap(TIME_2, "test"))); + assertEquals(mapAsString(TIME_2_STRING, "test"), + MAPPER.writeValueAsString(asMap(TIME_2, "test")), + "Value is incorrect"); } @Test public void testDeserialization0() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(TIME_0, "test"), - READER.readValue(mapAsString(TIME_0_STRING, "test"))); + assertEquals(asMap(TIME_0, "test"), + READER.readValue(mapAsString(TIME_0_STRING, "test")), + "Value is incorrect"); } @Test public void testDeserialization1() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(TIME_1, "test"), - READER.readValue(mapAsString(TIME_1_STRING, "test"))); + assertEquals(asMap(TIME_1, "test"), + READER.readValue(mapAsString(TIME_1_STRING, "test")), + "Value is incorrect"); } @Test public void testDeserialization2() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(TIME_2, "test"), - READER.readValue(mapAsString(TIME_2_STRING, "test"))); + assertEquals(asMap(TIME_2, "test"), + READER.readValue(mapAsString(TIME_2_STRING, "test")), + "Value is incorrect"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/PeriodAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/PeriodAsKeyTest.java index 603d22eb..610f35b8 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/PeriodAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/PeriodAsKeyTest.java @@ -3,13 +3,14 @@ import java.time.Period; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class PeriodAsKeyTest extends ModuleTestBase { @@ -25,25 +26,29 @@ public class PeriodAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(PERIOD_0_STRING, "test"), - MAPPER.writeValueAsString(asMap(PERIOD_0, "test"))); + assertEquals(mapAsString(PERIOD_0_STRING, "test"), + MAPPER.writeValueAsString(asMap(PERIOD_0, "test")), + "Value is incorrect"); } @Test public void testSerialization1() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(PERIOD_STRING, "test"), - MAPPER.writeValueAsString(asMap(PERIOD, "test"))); + assertEquals(mapAsString(PERIOD_STRING, "test"), + MAPPER.writeValueAsString(asMap(PERIOD, "test")), + "Value is incorrect"); } @Test public void testDeserialization0() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(PERIOD_0, "test"), - READER.readValue(mapAsString(PERIOD_0_STRING, "test"))); + assertEquals(asMap(PERIOD_0, "test"), + READER.readValue(mapAsString(PERIOD_0_STRING, "test")), + "Value is incorrect"); } @Test public void testDeserialization1() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(PERIOD, "test"), - READER.readValue(mapAsString(PERIOD_STRING, "test"))); + assertEquals(asMap(PERIOD, "test"), + READER.readValue(mapAsString(PERIOD_STRING, "test")), + "Value is incorrect"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/TestNullKeySerialization.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/TestNullKeySerialization.java index ba239b4a..569c5148 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/TestNullKeySerialization.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/TestNullKeySerialization.java @@ -3,12 +3,14 @@ import java.time.LocalDate; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.*; public class TestNullKeySerialization extends ModuleTestBase { @@ -22,13 +24,13 @@ public void testSerialization() throws Exception { final ObjectMapper mapper = newMapper(); mapper.getSerializerProvider().setNullKeySerializer(new com.fasterxml.jackson.datatype.jsr310.ser.key.Jsr310NullKeySerializer()); String value = mapper.writeValueAsString(asMap(null, "test")); - Assert.assertEquals(mapAsString(com.fasterxml.jackson.datatype.jsr310.ser.key.Jsr310NullKeySerializer.NULL_KEY, "test"), value); + assertEquals(mapAsString(com.fasterxml.jackson.datatype.jsr310.ser.key.Jsr310NullKeySerializer.NULL_KEY, "test"), value); } @SuppressWarnings("deprecation") @Test public void testDeserialization() throws Exception { Map value = READER.readValue(mapAsString(com.fasterxml.jackson.datatype.jsr310.ser.key.Jsr310NullKeySerializer.NULL_KEY, "test")); - Assert.assertEquals(asMap(null, "test"), value); + assertEquals(asMap(null, "test"), value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearAsKeyTest.java index a359c524..ebf79f25 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearAsKeyTest.java @@ -5,13 +5,14 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; import java.time.Year; import java.util.Collections; import java.util.Map; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class YearAsKeyTest extends ModuleTestBase { @@ -22,29 +23,34 @@ public class YearAsKeyTest extends ModuleTestBase @Test public void testKeySerialization() throws Exception { - assertEquals("Value is incorrect", mapAsString("3141", "test"), - MAPPER.writeValueAsString(asMap(Year.of(3141), "test"))); + assertEquals(mapAsString("3141", "test"), + MAPPER.writeValueAsString(asMap(Year.of(3141), "test")), + "Value is incorrect"); } @Test public void testKeyDeserialization() throws Exception { - assertEquals("Value is incorrect", asMap(Year.of(3141), "test"), - READER.readValue(mapAsString("3141", "test"))); + assertEquals(asMap(Year.of(3141), "test"), READER.readValue(mapAsString("3141", "test")), + "Value is incorrect"); // Test both padded, unpadded - assertEquals("Value is incorrect", asMap(Year.of(476), "test"), - READER.readValue(mapAsString("0476", "test"))); - assertEquals("Value is incorrect", asMap(Year.of(476), "test"), - READER.readValue(mapAsString("476", "test"))); + assertEquals(asMap(Year.of(476), "test"), READER.readValue(mapAsString("0476", "test")), + "Value is incorrect"); + assertEquals(asMap(Year.of(476), "test"), READER.readValue(mapAsString("476", "test")), + "Value is incorrect"); } - @Test(expected = InvalidFormatException.class) + @Test public void deserializeYearKey_notANumber() throws Exception { - READER.readValue(mapAsString("10000BC", "test")); + assertThrows(InvalidFormatException.class, () -> { + READER.readValue(mapAsString("10000BC", "test")); + }); } - @Test(expected = InvalidFormatException.class) + @Test public void deserializeYearKey_notAYear() throws Exception { - READER.readValue(mapAsString(Integer.toString(Year.MAX_VALUE+1), "test")); + assertThrows(InvalidFormatException.class, () -> { + READER.readValue(mapAsString(Integer.toString(Year.MAX_VALUE+1), "test")); + }); } @Test diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearMonthAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearMonthAsKeyTest.java index 9bfeeeab..b94af52f 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearMonthAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/YearMonthAsKeyTest.java @@ -3,13 +3,14 @@ import java.time.YearMonth; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class YearMonthAsKeyTest extends ModuleTestBase { @@ -19,13 +20,15 @@ public class YearMonthAsKeyTest extends ModuleTestBase @Test public void testSerialization() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString("3141-05", "test"), - MAPPER.writeValueAsString(asMap(YearMonth.of(3141, 5), "test"))); + assertEquals(mapAsString("3141-05", "test"), + MAPPER.writeValueAsString(asMap(YearMonth.of(3141, 5), "test")), + "Value is incorrect"); } @Test public void testDeserialization() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(YearMonth.of(3141, 5), "test"), - READER.readValue(mapAsString("3141-05", "test"))); + assertEquals(asMap(YearMonth.of(3141, 5), "test"), + READER.readValue(mapAsString("3141-05", "test")), + "Value is incorrect"); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneIdAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneIdAsKeyTest.java index 22dc496c..b2797535 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneIdAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneIdAsKeyTest.java @@ -3,13 +3,14 @@ import java.time.ZoneId; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class ZoneIdAsKeyTest extends ModuleTestBase { @@ -25,37 +26,37 @@ public class ZoneIdAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(ZONE_0_STRING, "test"), + assertEquals(mapAsString(ZONE_0_STRING, "test"), MAPPER.writeValueAsString(asMap(ZONE_0, "test"))); } @Test public void testSerialization1() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(ZONE_1_STRING, "test"), + assertEquals(mapAsString(ZONE_1_STRING, "test"), MAPPER.writeValueAsString(asMap(ZONE_1, "test"))); } @Test public void testSerialization2() throws Exception { - Assert.assertEquals("Value is incorrect", mapAsString(ZONE_2_STRING, "test"), + assertEquals(mapAsString(ZONE_2_STRING, "test"), MAPPER.writeValueAsString(asMap(ZONE_2, "test"))); } @Test public void testDeserialization0() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(ZONE_0, "test"), + assertEquals(asMap(ZONE_0, "test"), READER.readValue(mapAsString(ZONE_0_STRING, "test"))); } @Test public void testDeserialization1() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(ZONE_1, "test"), + assertEquals(asMap(ZONE_1, "test"), READER.readValue(mapAsString(ZONE_1_STRING, "test"))); } @Test public void testDeserialization2() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(ZONE_2, "test"), + assertEquals(asMap(ZONE_2, "test"), READER.readValue(mapAsString(ZONE_2_STRING, "test"))); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneOffsetAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneOffsetAsKeyTest.java index fca1c1a3..9b34a8ea 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneOffsetAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZoneOffsetAsKeyTest.java @@ -4,13 +4,14 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class ZoneOffsetAsKeyTest extends ModuleTestBase { @@ -25,7 +26,7 @@ public class ZoneOffsetAsKeyTest extends ModuleTestBase private Map map; - @Before + @BeforeEach public void setUp() { map = new HashMap<>(); } @@ -36,7 +37,7 @@ public void testSerialization0() throws Exception { String value = MAPPER.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(OFFSET_0_STRING, "test"), value); + assertEquals(map(OFFSET_0_STRING, "test"), value); } @Test @@ -45,7 +46,7 @@ public void testSerialization1() throws Exception { String value = MAPPER.writeValueAsString(map); - Assert.assertEquals("Value is incorrect", map(OFFSET_1_STRING, "test"), value); + assertEquals(map(OFFSET_1_STRING, "test"), value); } @Test @@ -53,7 +54,7 @@ public void testDeserialization0() throws Exception { Map value = MAPPER.readValue(map(OFFSET_0_STRING, "test"), TYPE_REF); map.put(OFFSET_0, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } @Test @@ -61,7 +62,7 @@ public void testDeserialization1() throws Exception { Map value = MAPPER.readValue(map(OFFSET_1_STRING, "test"), TYPE_REF); map.put(OFFSET_1, "test"); - Assert.assertEquals("Value is incorrect", map, value); + assertEquals(map, value); } private String map(String key, String value) { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZonedDateTimeAsKeyTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZonedDateTimeAsKeyTest.java index 73d29ea2..24807acd 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZonedDateTimeAsKeyTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/key/ZonedDateTimeAsKeyTest.java @@ -12,8 +12,8 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class ZonedDateTimeAsKeyTest extends ModuleTestBase { @@ -41,36 +41,36 @@ public class ZonedDateTimeAsKeyTest extends ModuleTestBase @Test public void testSerialization0() throws Exception { String value = MAPPER.writerFor(TYPE_REF).writeValueAsString(asMap(DATE_TIME_0, "test")); - Assert.assertEquals("Value is incorrect", mapAsString(DATE_TIME_0_STRING, "test"), value); + assertEquals(mapAsString(DATE_TIME_0_STRING, "test"), value); } @Test public void testSerialization1() throws Exception { String value = MAPPER.writerFor(TYPE_REF).writeValueAsString(asMap(DATE_TIME_1, "test")); - Assert.assertEquals("Value is incorrect", mapAsString(DATE_TIME_1_STRING, "test"), value); + assertEquals(mapAsString(DATE_TIME_1_STRING, "test"), value); } @Test public void testSerialization2() throws Exception { String value = MAPPER.writerFor(TYPE_REF).writeValueAsString(asMap(DATE_TIME_2, "test")); - Assert.assertEquals("Value is incorrect", mapAsString(DATE_TIME_2_STRING, "test"), value); + assertEquals(mapAsString(DATE_TIME_2_STRING, "test"), value); } @Test public void testDeserialization0() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(DATE_TIME_0, "test"), + assertEquals(asMap(DATE_TIME_0, "test"), READER.readValue(mapAsString(DATE_TIME_0_STRING, "test"))); } @Test public void testDeserialization1() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(DATE_TIME_1, "test"), + assertEquals(asMap(DATE_TIME_1, "test"), READER.readValue(mapAsString(DATE_TIME_1_STRING, "test"))); } @Test public void testDeserialization2() throws Exception { - Assert.assertEquals("Value is incorrect", asMap(DATE_TIME_2_OFFSET, "test"), + assertEquals(asMap(DATE_TIME_2_OFFSET, "test"), READER.readValue(mapAsString(DATE_TIME_2_STRING, "test"))); } @@ -78,8 +78,7 @@ public void testDeserialization2() throws Exception { public void testSerializationToInstantWithNanos() throws Exception { String value = mapperBuilder().enable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS).build() .writerFor(TYPE_REF).writeValueAsString(asMap(DATE_TIME_1, "test")); - Assert.assertEquals("Value is incorrect", - mapAsString(String.valueOf(DATE_TIME_1.toEpochSecond()) + '.' + DATE_TIME_1.getNano(), "test"), value); + assertEquals(mapAsString(String.valueOf(DATE_TIME_1.toEpochSecond()) + '.' + DATE_TIME_1.getNano(), "test"), value); } @Test @@ -87,7 +86,6 @@ public void testSerializationToInstantWithoutNanos() throws Exception { String value = mapperBuilder().enable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS) .disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build() .writerFor(TYPE_REF).writeValueAsString(asMap(DATE_TIME_1, "test")); - Assert.assertEquals("Value is incorrect", - mapAsString(String.valueOf(DATE_TIME_1.toInstant().toEpochMilli()), "test"), value); + assertEquals(mapAsString(String.valueOf(DATE_TIME_1.toInstant().toEpochMilli()), "test"), value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java index e9eb3bc5..1af7f228 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java @@ -2,12 +2,12 @@ import java.time.DateTimeException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class DateTimeExceptionTest extends ModuleTestBase { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeSchemasTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeSchemasTest.java index 984ef140..f3be7c98 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeSchemasTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeSchemasTest.java @@ -5,14 +5,15 @@ import java.time.ZonedDateTime; import java.util.*; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.*; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class DateTimeSchemasTest extends ModuleTestBase { static class VisitorWrapper implements JsonFormatVisitorWrapper { @@ -144,7 +145,7 @@ public void testLocalTimeSchema() throws Exception Map properties = wrapper.getTraversedProperties(); // By default, serialized as an int array, so: - Assert.assertEquals(1, properties.size()); + assertEquals(1, properties.size()); _verifyIntArrayType(properties.get("")); // but becomes date/time @@ -163,7 +164,7 @@ public void testLocalDateSchema() throws Exception Map properties = wrapper.getTraversedProperties(); // By default, serialized as an int array, so: - Assert.assertEquals(1, properties.size()); + assertEquals(1, properties.size()); _verifyIntArrayType(properties.get("")); // but becomes date/time @@ -184,7 +185,7 @@ public void testDateTimeSchema() throws Exception Map properties = wrapper.getTraversedProperties(); // By default, serialized as an int array, so: - Assert.assertEquals(1, properties.size()); + assertEquals(1, properties.size()); _verifyBigDecimalType(properties.get("")); // but becomes long @@ -205,30 +206,30 @@ public void testDateTimeSchema() throws Exception } private void _verifyIntArrayType(String desc) { - Assert.assertEquals("ARRAY/Ljava/util/List;", desc); + assertEquals("ARRAY/Ljava/util/List;", desc); } private void _verifyTimeType(String desc) { - Assert.assertEquals("STRING/TIME", desc); + assertEquals("STRING/TIME", desc); } private void _verifyDateType(String desc) { - Assert.assertEquals("STRING/DATE", desc); + assertEquals("STRING/DATE", desc); } private void _verifyDateTimeType(String desc) { - Assert.assertEquals("STRING/DATE_TIME", desc); + assertEquals("STRING/DATE_TIME", desc); } private void _verifyBigDecimalType(String desc) { - Assert.assertEquals("NUMBER/BIG_DECIMAL", desc); + assertEquals("NUMBER/BIG_DECIMAL", desc); } private void _verifyLongType(String desc) { - Assert.assertEquals("INTEGER/LONG", desc); + assertEquals("INTEGER/LONG", desc); } private void _verifyLongFormat(String desc) { - Assert.assertEquals("INTEGER/UTC_MILLISEC", desc); + assertEquals("INTEGER/UTC_MILLISEC", desc); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DeductionTypeSerialization296Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DeductionTypeSerialization296Test.java index 08ce9d08..50bc2add 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DeductionTypeSerialization296Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DeductionTypeSerialization296Test.java @@ -2,14 +2,15 @@ import java.time.*; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + // for [modules-java8#296]: problem with `JsonTypeInfo.Id.DEDUCTION` public class DeductionTypeSerialization296Test extends ModuleTestBase { @@ -30,7 +31,7 @@ public Wrapper(Object value) { public void testLocalDate() throws Exception { LocalDate date = LocalDate.of(1986, Month.JANUARY, 17); - Assert.assertEquals(a2q("{'value':'1986-01-17'}"), + assertEquals(a2q("{'value':'1986-01-17'}"), MAPPER.writeValueAsString(new Wrapper(date))); } @@ -38,7 +39,7 @@ public void testLocalDate() throws Exception public void testLocalDateTime() throws Exception { LocalDateTime datetime = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57); - Assert.assertEquals(a2q("{'value':'2013-08-21T09:22:00.000000057'}"), + assertEquals(a2q("{'value':'2013-08-21T09:22:00.000000057'}"), MAPPER.writeValueAsString(new Wrapper(datetime))); } @@ -46,7 +47,7 @@ public void testLocalDateTime() throws Exception public void testLocalTime() throws Exception { LocalTime time = LocalTime.of(9, 22, 57); - Assert.assertEquals(a2q("{'value':'09:22:57'}"), + assertEquals(a2q("{'value':'09:22:57'}"), MAPPER.writeValueAsString(new Wrapper(time))); } @@ -54,7 +55,7 @@ public void testLocalTime() throws Exception public void testMonthDate() throws Exception { MonthDay date = MonthDay.of(Month.JANUARY, 17); - Assert.assertEquals(a2q("{'value':'--01-17'}"), + assertEquals(a2q("{'value':'--01-17'}"), MAPPER.writeValueAsString(new Wrapper(date))); } @@ -62,7 +63,7 @@ public void testMonthDate() throws Exception public void testOffsetTime() throws Exception { OffsetTime time = OffsetTime.of(15, 43, 0, 0, ZoneOffset.of("+0300")); - Assert.assertEquals(a2q("{'value':'15:43+03:00'}"), + assertEquals(a2q("{'value':'15:43+03:00'}"), MAPPER.writeValueAsString(new Wrapper(time))); } @@ -70,7 +71,7 @@ public void testOffsetTime() throws Exception public void testYearMonth() throws Exception { YearMonth date = YearMonth.of(1986, Month.JANUARY); - Assert.assertEquals(a2q("{'value':'1986-01'}"), + assertEquals(a2q("{'value':'1986-01'}"), MAPPER.writeValueAsString(new Wrapper(date))); } @@ -78,7 +79,7 @@ public void testYearMonth() throws Exception public void testZoneId() throws Exception { ZoneId zone = ZoneId.of("America/Denver"); - Assert.assertEquals(a2q("{'value':'America/Denver'}"), + assertEquals(a2q("{'value':'America/Denver'}"), MAPPER.writeValueAsString(new Wrapper(zone))); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/UnsupportedTypesTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/UnsupportedTypesTest.java index 824705bf..22794bb9 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/UnsupportedTypesTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/UnsupportedTypesTest.java @@ -3,12 +3,13 @@ import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAdjusters; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class UnsupportedTypesTest extends ModuleTestBase { // [modules-java8#207] @@ -27,7 +28,7 @@ public void testTemporalAdjusterSerialization() throws Exception ObjectMapper mapper = newMapper(); // Not 100% sure how this happens, actually; should fail on empty "POJO"? - Assert.assertEquals(a2q("{'a':{}}"), + assertEquals(a2q("{'a':{}}"), mapper.writeValueAsString(new TAWrapper(TemporalAdjusters.firstDayOfMonth()))); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/DurationSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/DurationSerTest.java index 9f645d5c..913c77ef 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/DurationSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/DurationSerTest.java @@ -3,7 +3,7 @@ import java.time.Duration; import java.time.temporal.TemporalAmount; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; @@ -13,7 +13,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DurationSerTest extends ModuleTestBase { @@ -146,8 +146,7 @@ public void testSerializationWithTypeInfo01() throws Exception Duration duration = Duration.ofSeconds(13498L, 8374); String value = mapper.writeValueAsString(duration); - assertEquals( - "[\"" + Duration.class.getName() + "\",13498.000008374]", value); + assertEquals("[\"" + Duration.class.getName() + "\",13498.000008374]", value); } @Test @@ -161,8 +160,7 @@ public void testSerializationWithTypeInfo02() throws Exception Duration duration = Duration.ofSeconds(13498L, 837481723); String value = mapper.writeValueAsString(duration); - assertEquals( - "[\"" + Duration.class.getName() + "\",13498837]", value); + assertEquals("[\"" + Duration.class.getName() + "\",13498837]", value); } @Test @@ -175,8 +173,7 @@ public void testSerializationWithTypeInfo03() throws Exception Duration duration = Duration.ofSeconds(13498L, 8374); String value = mapper.writeValueAsString(duration); - assertEquals( - "[\"" + Duration.class.getName() + "\",\"" + duration.toString() + "\"]", value); + assertEquals("[\"" + Duration.class.getName() + "\",\"" + duration.toString() + "\"]", value); } /* diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerTest.java index 343efd83..951f0eb9 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerTest.java @@ -16,9 +16,6 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -29,7 +26,10 @@ import java.time.Instant; import java.time.format.DateTimeFormatter; import java.time.temporal.Temporal; -import org.junit.Test; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class InstantSerTest extends ModuleTestBase { @@ -46,8 +46,8 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", NO_NANOSECS_SER, value); + assertNotNull(value); + assertEquals(NO_NANOSECS_SER, value); } @Test @@ -58,7 +58,7 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "0", value); + assertEquals("0", value); } @Test @@ -69,7 +69,7 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertEquals("123456789.183917322", value); } @Test @@ -80,7 +80,7 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "123456789183", value); + assertEquals("123456789183", value); } @Test @@ -91,7 +91,7 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", DecimalUtils.toDecimal(date.getEpochSecond(), date.getNano()), value); + assertEquals(DecimalUtils.toDecimal(date.getEpochSecond(), date.getNano()), value); } @Test @@ -102,7 +102,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", Long.toString(date.toEpochMilli()), value); + assertEquals(Long.toString(date.toEpochMilli()), value); } @Test @@ -112,7 +112,7 @@ public void testSerializationAsString01() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -122,7 +122,7 @@ public void testSerializationAsString02() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -132,7 +132,7 @@ public void testSerializationAsString03() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -144,7 +144,7 @@ public void testSerializationWithTypeInfo01() throws Exception .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); m.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = m.writeValueAsString(date); - assertEquals("The value is not correct.", "[\"" + Instant.class.getName() + "\",123456789.183917322]", value); + assertEquals("[\"" + Instant.class.getName() + "\",123456789.183917322]", value); } @Test @@ -156,7 +156,7 @@ public void testSerializationWithTypeInfo02() throws Exception .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); m.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = m.writeValueAsString(date); - assertEquals("The value is not correct.", "[\"" + Instant.class.getName() + "\",123456789183]", value); + assertEquals("[\"" + Instant.class.getName() + "\",123456789183]", value); } @Test @@ -167,8 +167,7 @@ public void testSerializationWithTypeInfo03() throws Exception .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); m.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = m.writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + Instant.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); + assertEquals("[\"" + Instant.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); } static class Pojo1 { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateSerTest.java index 03703859..1ecee663 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateSerTest.java @@ -20,6 +20,8 @@ import java.time.Month; import java.time.temporal.Temporal; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -28,10 +30,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.*; public class LocalDateSerTest extends ModuleTestBase @@ -74,8 +73,8 @@ public void testSerializationAsTimestamp01() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[1986,1,17]", value); + assertNotNull(value); + assertEquals("[1986,1,17]", value); } @Test @@ -86,8 +85,8 @@ public void testSerializationAsTimestamp02() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2013,8,21]", value); + assertNotNull(value); + assertEquals("[2013,8,21]", value); } @Test @@ -98,8 +97,8 @@ public void testSerializationAsString01() throws Exception .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + date.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + date.toString() + '"', value); } @Test @@ -109,8 +108,8 @@ public void testSerializationAsString02() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + date.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + date.toString() + '"', value); } @Test @@ -122,9 +121,8 @@ public void testSerializationWithTypeInfo01() throws Exception LocalDate date = LocalDate.of(2005, Month.NOVEMBER, 5); String value = mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + LocalDate.class.getName() + "\",\"" + date.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + LocalDate.class.getName() + "\",\"" + date.toString() + "\"]", value); } // [modules-java8#46] diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerTest.java index a34a71ec..f7e66009 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerTest.java @@ -21,6 +21,8 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.Temporal; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -29,9 +31,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class LocalDateTimeSerTest extends ModuleTestBase @@ -49,7 +49,7 @@ static class LDTWrapper { public void testSerializationAsTimestamp01() throws Exception { LocalDateTime time = LocalDateTime.of(1986, Month.JANUARY, 17, 15, 43); - assertEquals("The value is not correct.", "[1986,1,17,15,43]", + assertEquals("[1986,1,17,15,43]", MAPPER.writeValueAsString(time)); } @@ -59,7 +59,7 @@ public void testSerializationAsTimestamp02() throws Exception LocalDateTime time = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 57); String value = MAPPER.writeValueAsString(time); - assertEquals("The value is not correct.", "[2013,8,21,9,22,57]", value); + assertEquals("[2013,8,21,9,22,57]", value); } @Test @@ -70,7 +70,7 @@ public void testSerializationAsTimestamp03Nanosecond() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(time); - assertEquals("The value is not correct.", "[2013,8,21,9,22,0,57]", value); + assertEquals("[2013,8,21,9,22,0,57]", value); } @Test @@ -81,7 +81,7 @@ public void testSerializationAsTimestamp03Millisecond() throws Exception ObjectMapper m = newMapper().disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS); String value = m.writeValueAsString(time); - assertEquals("The value is not correct.", "[2013,8,21,9,22,0,0]", value); + assertEquals("[2013,8,21,9,22,0,0]", value); } @Test @@ -93,7 +93,7 @@ public void testSerializationAsTimestamp04Nanosecond() throws Exception .enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS); String value = m.writeValueAsString(time); - assertEquals("The value is not correct.", "[2005,11,5,22,31,5,829837]", value); + assertEquals("[2005,11,5,22,31,5,829837]", value); } @Test @@ -105,7 +105,7 @@ public void testSerializationAsTimestamp04Millisecond() throws Exception .disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS); String value = m.writeValueAsString(time); - assertEquals("The value is not correct.", "[2005,11,5,22,31,5,422]", value); + assertEquals("[2005,11,5,22,31,5,422]", value); } @Test @@ -117,8 +117,8 @@ public void testSerializationAsString01() throws Exception m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "\"1986-01-17T15:43:05\"", value); + assertNotNull(value); + assertEquals("\"1986-01-17T15:43:05\"", value); } @Test @@ -130,8 +130,8 @@ public void testSerializationAsString02() throws Exception m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -143,8 +143,8 @@ public void testSerializationAsString03() throws Exception m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -171,8 +171,7 @@ public void testSerializationWithTypeInfo01() throws Exception m.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = m.writeValueAsString(time); - assertEquals("The value is not correct.", - "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,829837]]", value); + assertEquals("[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,829837]]", value); } @Test @@ -186,8 +185,7 @@ public void testSerializationWithTypeInfo02() throws Exception LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 422829837); String value = m.writeValueAsString(time); - assertEquals("The value is not correct.", - "[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,422]]", value); + assertEquals("[\"" + LocalDateTime.class.getName() + "\",[2005,11,5,22,31,5,422]]", value); } @Test @@ -199,8 +197,7 @@ public void testSerializationWithTypeInfo03() throws Exception LocalDateTime time = LocalDateTime.of(2005, Month.NOVEMBER, 5, 22, 31, 5, 829837); String value = m.writeValueAsString(time); - assertEquals("The value is not correct.", - "[\"" + LocalDateTime.class.getName() + "\",\"" + time.toString() + "\"]", value); + assertEquals("[\"" + LocalDateTime.class.getName() + "\",\"" + time.toString() + "\"]", value); } // [modules-java8#288] diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalTimeSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalTimeSerTest.java index 91d7e8de..d582661e 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalTimeSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalTimeSerTest.java @@ -20,8 +20,7 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.Temporal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; @@ -30,7 +29,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; @SuppressWarnings("serial") public class LocalTimeSerTest extends ModuleTestBase @@ -58,24 +57,24 @@ public void testSerializationAsTimestamp01() throws Exception { String json = writer.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(LocalTime.of(15, 43)); - assertEquals("The value is not correct.", "[15,43]", json); + assertEquals("[15,43]", json, "The value is not correct."); } @Test public void testSerializationAsTimestamp02() throws Exception { String json = writer.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .writeValueAsString( LocalTime.of(9, 22, 57)); - assertEquals("The value is not correct.", "[9,22,57]", json); + .writeValueAsString(LocalTime.of(9, 22, 57)); + assertEquals("[9,22,57]", json, "The value is not correct."); } @Test public void testSerializationAsTimestamp03Nanoseconds() throws Exception { String json = writer.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, - SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) - .writeValueAsString(LocalTime.of(9, 22, 0, 57)); - assertEquals("The value is not correct.", "[9,22,0,57]", json); + SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) + .writeValueAsString(LocalTime.of(9, 22, 0, 57)); + assertEquals("[9,22,0,57]", json, "The value is not correct."); } @Test @@ -88,7 +87,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = mapper.writeValueAsString(time); - assertEquals("The value is not correct.", "[9,22,0,0]", value); + assertEquals("[9,22,0,0]", value, "The value is not correct."); } @Test @@ -101,7 +100,7 @@ public void testSerializationAsTimestamp04Nanoseconds() throws Exception mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); String value = mapper.writeValueAsString(time); - assertEquals("The value is not correct.", "[22,31,5,829837]", value); + assertEquals("[22,31,5,829837]", value, "The value is not correct."); } @Test @@ -114,8 +113,8 @@ public void testSerializationAsTimestamp04Milliseconds() throws Exception mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); String value = mapper.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[22,31,5,422]", value); + assertNotNull(value, "The value should not be null."); + assertEquals("[22,31,5,422]", value, "The value is not correct."); } @Test @@ -127,7 +126,7 @@ public void testSerializationAsString01() throws Exception mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = mapper.writeValueAsString(time); - assertEquals("The value is not correct.", "\"15:43:20\"", value); + assertEquals("\"15:43:20\"", value, "The value is not correct."); } @Test @@ -139,7 +138,7 @@ public void testSerializationAsString02() throws Exception mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = mapper.writeValueAsString(time); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertEquals('"' + time.toString() + '"', value, "The value is not correct."); } @Test @@ -151,8 +150,8 @@ public void testSerializationAsString03() throws Exception m.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); String value = m.writeValueAsString(time); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertNotNull(value, "The value should not be null."); + assertEquals('"' + time.toString() + '"', value, "The value is not correct."); } // [modules-java8#115] @@ -160,9 +159,9 @@ public void testSerializationAsString03() throws Exception public void testWithCustomSerializer() throws Exception { String json = MAPPER.writeValueAsString(new CustomWrapper(LocalTime.of(15, 43))); - assertEquals("The value is not correct.", "{\"value\":\"15/43\"}", json); + assertEquals("{\"value\":\"15/43\"}", json, "The value is not correct."); } - + @Test public void testSerializationWithTypeInfo01() throws Exception { @@ -173,9 +172,8 @@ public void testSerializationWithTypeInfo01() throws Exception m.addMixIn(Temporal.class, MockObjectConfiguration.class); String json = m.writeValueAsString(time); - assertEquals("The value is not correct.", - "[\"" + LocalTime.class.getName() + "\",[22,31,5,829837]]", - json); + assertEquals("[\"" + LocalTime.class.getName() + "\",[22,31,5,829837]]", json, + "The value is not correct."); } @Test @@ -188,9 +186,8 @@ public void testSerializationWithTypeInfo02() throws Exception m.disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS); m.addMixIn(Temporal.class, MockObjectConfiguration.class); String json = m.writeValueAsString(time); - assertEquals("The value is not correct.", - "[\"" + LocalTime.class.getName() + "\",[22,31,5,422]]", - json); + assertEquals("[\"" + LocalTime.class.getName() + "\",[22,31,5,422]]", json, + "The value is not correct."); } @Test @@ -202,7 +199,7 @@ public void testSerializationWithTypeInfo03() throws Exception m.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = m.writeValueAsString(time); - assertEquals("The value is not correct.", - "[\"" + LocalTime.class.getName() + "\",\"" + time.toString() + "\"]", value); + assertEquals("[\"" + LocalTime.class.getName() + "\",\"" + time.toString() + "\"]", value, + "The value is not correct."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/MonthDaySerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/MonthDaySerTest.java index 8f73238f..5693bf40 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/MonthDaySerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/MonthDaySerTest.java @@ -20,14 +20,14 @@ import java.time.MonthDay; import java.time.temporal.TemporalAccessor; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class MonthDaySerTest extends ModuleTestBase @@ -37,14 +37,14 @@ public class MonthDaySerTest @Test public void testSerialization01() throws Exception { - assertEquals("The value is not correct.", "\"--01-17\"", + assertEquals("\"--01-17\"", MAPPER.writeValueAsString(MonthDay.of(Month.JANUARY, 17))); } @Test public void testSerialization02() throws Exception { - assertEquals("The value is not correct.", "\"--08-21\"", + assertEquals("\"--08-21\"", MAPPER.writeValueAsString(MonthDay.of(Month.AUGUST, 21))); } @@ -56,6 +56,6 @@ public void testSerializationWithTypeInfo01() throws Exception mapper.addMixIn(TemporalAccessor.class, MockObjectConfiguration.class); MonthDay monthDay = MonthDay.of(Month.NOVEMBER, 5); String value = mapper.writeValueAsString(monthDay); - assertEquals("The value is not correct.", "[\"" + MonthDay.class.getName() + "\",\"--11-05\"]", value); + assertEquals("[\"" + MonthDay.class.getName() + "\",\"--11-05\"]", value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java index 77811bf3..e41dcd12 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java @@ -1,7 +1,5 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.junit.Assert.assertEquals; - import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; @@ -10,7 +8,7 @@ import java.time.temporal.Temporal; import java.util.TimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; @@ -19,6 +17,8 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class OffsetDateTimeSerTest extends ModuleTestBase { @@ -50,7 +50,7 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "0.0", value); + assertEquals("0.0", value); } @Test @@ -61,7 +61,7 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "0", value); + assertEquals("0", value); } @Test @@ -72,7 +72,7 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertEquals("123456789.183917322", value); } @Test @@ -83,7 +83,7 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "123456789183", value); + assertEquals("123456789183", value); } @Test @@ -94,7 +94,7 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); + assertEquals(DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); } @Test @@ -105,7 +105,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", Long.toString(date.toInstant().toEpochMilli()), value); + assertEquals(Long.toString(date.toInstant().toEpochMilli()), value); } @Test @@ -115,7 +115,7 @@ public void testSerializationAsString01() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + assertEquals('"' + FORMATTER.withZone(Z1).format(date) + '"', value); } @@ -126,7 +126,7 @@ public void testSerializationAsString02() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + assertEquals('"' + FORMATTER.withZone(Z2).format(date) + '"', value); } @@ -137,7 +137,7 @@ public void testSerializationAsString03() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + assertEquals('"' + FORMATTER.withZone(Z3).format(date) + '"', value); } @@ -167,7 +167,7 @@ public void testSerializationAsStringWithMapperTimeZone01() throws Exception .writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -179,7 +179,7 @@ public void testSerializationAsStringWithMapperTimeZone02() throws Exception .writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -191,7 +191,7 @@ public void testSerializationAsStringWithMapperTimeZone03() throws Exception .writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -204,8 +204,7 @@ public void testSerializationWithTypeInfo01() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", value); + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", value); } @Test @@ -218,8 +217,7 @@ public void testSerializationWithTypeInfo02() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",123456789183]", value); + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",123456789183]", value); } @Test @@ -230,8 +228,7 @@ public void testSerializationWithTypeInfo03() throws Exception .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .addMixIn(Temporal.class, MockObjectConfiguration.class) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",\"" + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.withZone(Z3).format(date) + "\"]", value); } @@ -245,8 +242,7 @@ public void testSerializationWithTypeInfoAndMapperTimeZone() throws Exception .addMixIn(Temporal.class, MockObjectConfiguration.class) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); + assertEquals("[\"" + OffsetDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); } @Test @@ -260,7 +256,7 @@ public void testSerializationAsStringWithDefaultTimeZoneAndContextTimeZoneOn() t .writeValueAsString(date); // We expect to have the date written with the ZoneId Z2 - assertEquals("The value is incorrect", "\"" + FORMATTER.format(date.atZoneSameInstant(Z2)) + "\"", value); + assertEquals("\"" + FORMATTER.format(date.atZoneSameInstant(Z2)) + "\"", value); } @Test @@ -274,7 +270,7 @@ public void testSerializationAsStringWithDefaultTimeZoneAndContextTimeZoneOff() .writeValueAsString(date); // We expect to have the date written with the ZoneId Z3 - assertEquals("The value is incorrect", "\"" + FORMATTER.format(date) + "\"", value); + assertEquals("\"" + FORMATTER.format(date) + "\"", value); } static class Pojo1 { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerTest.java index c1e9e5ad..fa31d8a5 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerTest.java @@ -20,13 +20,13 @@ import java.time.ZoneOffset; import java.time.temporal.Temporal; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class OffsetTimeSerTest extends ModuleTestBase { @@ -39,7 +39,7 @@ public void testSerializationAsTimestamp01() throws Exception String value = MAPPER.writer() .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(time); - assertEquals("The value is not correct.", "[15,43,\"+03:00\"]", value); + assertEquals("[15,43,\"+03:00\"]", value); } @Test @@ -49,7 +49,7 @@ public void testSerializationAsTimestamp02() throws Exception String value = MAPPER.writer() .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(time); - assertEquals("The value is not correct.", "[9,22,57,\"-06:30\"]", value); + assertEquals("[9,22,57,\"-06:30\"]", value); } @Test @@ -60,7 +60,7 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(time); - assertEquals("The value is not correct.", "[9,22,0,57,\"-06:30\"]", value); + assertEquals("[9,22,0,57,\"-06:30\"]", value); } @Test @@ -71,7 +71,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(time); - assertEquals("The value is not correct.", "[9,22,0,0,\"-06:30\"]", value); + assertEquals("[9,22,0,0,\"-06:30\"]", value); } @Test @@ -82,7 +82,7 @@ public void testSerializationAsTimestamp04Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(time); - assertEquals("The value is not correct.", "[22,31,5,829837,\"+11:00\"]", value); + assertEquals("[22,31,5,829837,\"+11:00\"]", value); } @Test @@ -93,7 +93,7 @@ public void testSerializationAsTimestamp04Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(time); - assertEquals("The value is not correct.", "[22,31,5,422,\"+11:00\"]", value); + assertEquals("[22,31,5,422,\"+11:00\"]", value); } @Test @@ -103,7 +103,7 @@ public void testSerializationAsString01() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(time); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -113,7 +113,7 @@ public void testSerializationAsString02() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(time); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -123,7 +123,7 @@ public void testSerializationAsString03() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(time); - assertEquals("The value is not correct.", '"' + time.toString() + '"', value); + assertEquals('"' + time.toString() + '"', value); } @Test @@ -136,8 +136,7 @@ public void testSerializationWithTypeInfo01() throws Exception mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, true); mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); - assertEquals("The value is not correct.", - "[\"" + OffsetTime.class.getName() + "\",[22,31,5,829837,\"+11:00\"]]", + assertEquals("[\"" + OffsetTime.class.getName() + "\",[22,31,5,829837,\"+11:00\"]]", mapper.writeValueAsString(time)); } @@ -151,8 +150,7 @@ public void testSerializationWithTypeInfo02() throws Exception mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); - assertEquals("The value is not correct.", - "[\"" + OffsetTime.class.getName() + "\",[22,31,5,422,\"+11:00\"]]", + assertEquals("[\"" + OffsetTime.class.getName() + "\",[22,31,5,422,\"+11:00\"]]", mapper.writeValueAsString(time)); } @@ -166,7 +164,6 @@ public void testSerializationWithTypeInfo03() throws Exception mapper.addMixIn(Temporal.class, MockObjectConfiguration.class); String value = mapper.writeValueAsString(time); - assertEquals("The value is not correct.", - "[\"" + OffsetTime.class.getName() + "\",\"" + time.toString() + "\"]", value); + assertEquals("[\"" + OffsetTime.class.getName() + "\",\"" + time.toString() + "\"]", value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java index 7c1a3a4a..0a6d12cd 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java @@ -1,10 +1,8 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.junit.Assert.assertEquals; - import java.time.Month; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -13,6 +11,8 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class OneBasedMonthSerTest extends ModuleTestBase { static class Wrapper { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/PeriodSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/PeriodSerTest.java index 2a629abb..ebd8d6b3 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/PeriodSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/PeriodSerTest.java @@ -16,16 +16,16 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.junit.Assert.assertEquals; - import java.time.Period; import java.time.temporal.TemporalAmount; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class PeriodSerTest extends ModuleTestBase { @@ -51,8 +51,7 @@ public void testSerializationWithTypeInfo01() throws Exception .addMixIn(TemporalAmount.class, MockObjectConfiguration.class) .build(); String value = mapper.writeValueAsString(period); - assertEquals( - "[" + q(Period.class.getName()) + ",\"P5Y1M12D\"]", value); + assertEquals("[" + q(Period.class.getName()) + ",\"P5Y1M12D\"]", value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateSerializationWithCustomFormatter.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateSerializationWithCustomFormatter.java index 553f4abc..975b3cc0 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateSerializationWithCustomFormatter.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateSerializationWithCustomFormatter.java @@ -2,34 +2,25 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; +import java.util.stream.Stream; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.hamcrest.MatcherAssert.assertThat; - -import static org.hamcrest.core.StringContains.containsString; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -@RunWith(Parameterized.class) -public class TestLocalDateSerializationWithCustomFormatter { - private final DateTimeFormatter formatter; +import static org.junit.jupiter.api.Assertions.*; - public TestLocalDateSerializationWithCustomFormatter(DateTimeFormatter formatter) { - this.formatter = formatter; - } +public class TestLocalDateSerializationWithCustomFormatter { - @Test - public void testSerialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testSerialization(DateTimeFormatter formatter) throws Exception { LocalDate date = LocalDate.now(); - assertThat(serializeWith(date, formatter), containsString(date.format(formatter))); + assertTrue(serializeWith(date, formatter).contains(date.format(formatter)), + "Serialized value should contain the formatted date"); } private String serializeWith(LocalDate date, DateTimeFormatter f) throws Exception { @@ -38,10 +29,12 @@ private String serializeWith(LocalDate date, DateTimeFormatter f) throws Excepti return mapper.writeValueAsString(date); } - @Test - public void testDeserialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testDeserialization(DateTimeFormatter formatter) throws Exception { LocalDate date = LocalDate.now(); - assertThat(deserializeWith(date.format(formatter), formatter), equalTo(date)); + assertEquals(date, deserializeWith(date.format(formatter), formatter), + "Deserialized value should match the original date"); } private LocalDate deserializeWith(String json, DateTimeFormatter f) throws Exception { @@ -50,15 +43,14 @@ private LocalDate deserializeWith(String json, DateTimeFormatter f) throws Excep return mapper.readValue("\"" + json + "\"", LocalDate.class); } - @Parameters - public static Collection customFormatters() { - Collection formatters = new ArrayList<>(); - formatters.add(new Object[]{DateTimeFormatter.BASIC_ISO_DATE}); - formatters.add(new Object[]{DateTimeFormatter.ISO_DATE}); - formatters.add(new Object[]{DateTimeFormatter.ISO_LOCAL_DATE}); - formatters.add(new Object[]{DateTimeFormatter.ISO_ORDINAL_DATE}); - formatters.add(new Object[]{DateTimeFormatter.ISO_WEEK_DATE}); - formatters.add(new Object[]{DateTimeFormatter.ofPattern("MM/dd/yyyy")}); - return formatters; + static Stream customFormatters() { + return Stream.of( + DateTimeFormatter.BASIC_ISO_DATE, + DateTimeFormatter.ISO_DATE, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ORDINAL_DATE, + DateTimeFormatter.ISO_WEEK_DATE, + DateTimeFormatter.ofPattern("MM/dd/yyyy") + ); } -} +} \ No newline at end of file diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateTimeSerializationWithCustomFormatter.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateTimeSerializationWithCustomFormatter.java index 27de3d8e..bcd1562e 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateTimeSerializationWithCustomFormatter.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalDateTimeSerializationWithCustomFormatter.java @@ -2,33 +2,24 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; +import java.util.stream.Stream; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.hamcrest.core.StringContains.containsString; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -@RunWith(Parameterized.class) -public class TestLocalDateTimeSerializationWithCustomFormatter { - private final DateTimeFormatter formatter; +import static org.junit.jupiter.api.Assertions.*; - public TestLocalDateTimeSerializationWithCustomFormatter(DateTimeFormatter formatter) { - this.formatter = formatter; - } +public class TestLocalDateTimeSerializationWithCustomFormatter { - @Test - public void testSerialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testSerialization(DateTimeFormatter formatter) throws Exception { LocalDateTime dateTime = LocalDateTime.now(); - assertThat(serializeWith(dateTime, formatter), containsString(dateTime.format(formatter))); + assertTrue(serializeWith(dateTime, formatter).contains(dateTime.format(formatter))); } private String serializeWith(LocalDateTime dateTime, DateTimeFormatter f) throws Exception { @@ -36,10 +27,11 @@ private String serializeWith(LocalDateTime dateTime, DateTimeFormatter f) throws return mapper.writeValueAsString(dateTime); } - @Test - public void testDeserialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testDeserialization(DateTimeFormatter formatter) throws Exception { LocalDateTime dateTime = LocalDateTime.now(); - assertThat(deserializeWith(dateTime.format(formatter), formatter), equalTo(dateTime)); + assertEquals(dateTime, deserializeWith(dateTime.format(formatter), formatter)); } private LocalDateTime deserializeWith(String json, DateTimeFormatter f) throws Exception { @@ -47,11 +39,10 @@ private LocalDateTime deserializeWith(String json, DateTimeFormatter f) throws E return mapper.readValue("\"" + json + "\"", LocalDateTime.class); } - @Parameters - public static Collection customFormatters() { - Collection formatters = new ArrayList<>(); - formatters.add(new Object[]{DateTimeFormatter.ISO_DATE_TIME}); - formatters.add(new Object[]{DateTimeFormatter.ISO_LOCAL_DATE_TIME}); - return formatters; + static Stream customFormatters() { + return Stream.of( + DateTimeFormatter.ISO_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE_TIME + ); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalTimeSerializationWithCustomFormatter.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalTimeSerializationWithCustomFormatter.java index e5503c72..1cf70568 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalTimeSerializationWithCustomFormatter.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestLocalTimeSerializationWithCustomFormatter.java @@ -1,34 +1,26 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.hamcrest.core.StringContains.containsString; + +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; +import static org.junit.jupiter.api.Assertions.*; -@RunWith(Parameterized.class) public class TestLocalTimeSerializationWithCustomFormatter { - private final DateTimeFormatter formatter; - - public TestLocalTimeSerializationWithCustomFormatter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - @Test - public void testSerialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testSerialization(DateTimeFormatter formatter) throws Exception { LocalTime dateTime = LocalTime.now(); - assertThat(serializeWith(dateTime, formatter), containsString(dateTime.format(formatter))); + assertTrue(serializeWith(dateTime, formatter).contains(dateTime.format(formatter))); } private String serializeWith(LocalTime dateTime, DateTimeFormatter f) throws Exception { @@ -37,10 +29,11 @@ private String serializeWith(LocalTime dateTime, DateTimeFormatter f) throws Exc return mapper.writeValueAsString(dateTime); } - @Test - public void testDeserialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testDeserialization(DateTimeFormatter formatter) throws Exception { LocalTime dateTime = LocalTime.now(); - assertThat(deserializeWith(dateTime.format(formatter), formatter), equalTo(dateTime)); + assertEquals(dateTime, deserializeWith(dateTime.format(formatter), formatter)); } private LocalTime deserializeWith(String json, DateTimeFormatter f) throws Exception { @@ -49,11 +42,10 @@ private LocalTime deserializeWith(String json, DateTimeFormatter f) throws Excep return mapper.readValue("\"" + json + "\"", LocalTime.class); } - @Parameters - public static Collection customFormatters() { - Collection formatters = new ArrayList<>(); - formatters.add(new Object[]{DateTimeFormatter.ISO_LOCAL_TIME}); - formatters.add(new Object[]{DateTimeFormatter.ISO_TIME}); - return formatters; + static Stream customFormatters() { + return Stream.of( + DateTimeFormatter.ISO_LOCAL_TIME, + DateTimeFormatter.ISO_TIME + ); } -} +} \ No newline at end of file diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearMonthSerializationWithCustomFormatter.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearMonthSerializationWithCustomFormatter.java index c4e658a4..f59a18e8 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearMonthSerializationWithCustomFormatter.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearMonthSerializationWithCustomFormatter.java @@ -1,34 +1,25 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.hamcrest.core.StringContains.containsString; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.deser.YearMonthDeserializer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -import java.time.YearMonth; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; +import static org.junit.jupiter.api.Assertions.*; -@RunWith(Parameterized.class) public class TestYearMonthSerializationWithCustomFormatter { - private final DateTimeFormatter formatter; - - public TestYearMonthSerializationWithCustomFormatter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - @Test - public void testSerialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testSerialization(DateTimeFormatter formatter) throws Exception { YearMonth dateTime = YearMonth.now(); - assertThat(serializeWith(dateTime, formatter), containsString(dateTime.format(formatter))); + assertTrue(serializeWith(dateTime, formatter).contains(dateTime.format(formatter))); } private String serializeWith(YearMonth dateTime, DateTimeFormatter f) throws Exception { @@ -37,10 +28,11 @@ private String serializeWith(YearMonth dateTime, DateTimeFormatter f) throws Exc return mapper.writeValueAsString(dateTime); } - @Test - public void testDeserialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testDeserialization(DateTimeFormatter formatter) throws Exception { YearMonth dateTime = YearMonth.now(); - assertThat(deserializeWith(dateTime.format(formatter), formatter), equalTo(dateTime)); + assertEquals(dateTime, deserializeWith(dateTime.format(formatter), formatter)); } private YearMonth deserializeWith(String json, DateTimeFormatter f) throws Exception { @@ -49,11 +41,10 @@ private YearMonth deserializeWith(String json, DateTimeFormatter f) throws Excep return mapper.readValue("\"" + json + "\"", YearMonth.class); } - @Parameters - public static Collection customFormatters() { - Collection formatters = new ArrayList<>(); - formatters.add(new Object[]{DateTimeFormatter.ofPattern("uuuu-MM")}); - formatters.add(new Object[]{DateTimeFormatter.ofPattern("uu-M")}); - return formatters; + static Stream customFormatters() { + return Stream.of( + DateTimeFormatter.ofPattern("uuuu-MM"), + DateTimeFormatter.ofPattern("uu-M") + ); } -} +} \ No newline at end of file diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearSerializationWithCustomFormatter.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearSerializationWithCustomFormatter.java index 1bdd6c2b..93a1b130 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearSerializationWithCustomFormatter.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestYearSerializationWithCustomFormatter.java @@ -1,34 +1,27 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsEqual.equalTo; + +import java.time.Year; +import java.time.format.DateTimeFormatter; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.deser.YearDeserializer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -import java.time.Year; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; +import static org.junit.jupiter.api.Assertions.*; -@RunWith(Parameterized.class) public class TestYearSerializationWithCustomFormatter { - private final DateTimeFormatter formatter; - - public TestYearSerializationWithCustomFormatter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - @Test - public void testSerialization() throws Exception { + @ParameterizedTest + @MethodSource("customFormatters") + void testSerialization(DateTimeFormatter formatter) throws Exception { Year year = Year.now(); String expected = "\"" + year.format(formatter) + "\""; - assertThat(serializeWith(year, formatter), equalTo(expected)); + assertEquals(expected, serializeWith(year, formatter)); } private String serializeWith(Year dateTime, DateTimeFormatter f) throws Exception { @@ -37,10 +30,11 @@ private String serializeWith(Year dateTime, DateTimeFormatter f) throws Exceptio return mapper.writeValueAsString(dateTime); } - @Test - public void testDeserialization() throws Exception { - Year dateTime = Year.now(); - assertThat(deserializeWith(dateTime.format(formatter), formatter), equalTo(dateTime)); + @ParameterizedTest + @MethodSource("customFormatters") + void testDeserialization(DateTimeFormatter formatter) throws Exception { + Year year = Year.now(); + assertEquals(year, deserializeWith(year.format(formatter), formatter)); } private Year deserializeWith(String json, DateTimeFormatter f) throws Exception { @@ -49,11 +43,10 @@ private Year deserializeWith(String json, DateTimeFormatter f) throws Exception return mapper.readValue("\"" + json + "\"", Year.class); } - @Parameters - public static Collection customFormatters() { - Collection formatters = new ArrayList<>(); - formatters.add(new Object[]{DateTimeFormatter.ofPattern("yyyy")}); - formatters.add(new Object[]{DateTimeFormatter.ofPattern("yy")}); - return formatters; + static Stream customFormatters() { + return Stream.of( + DateTimeFormatter.ofPattern("yyyy"), + DateTimeFormatter.ofPattern("yy") + ); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestZonedDateTimeSerializationWithCustomFormatter.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestZonedDateTimeSerializationWithCustomFormatter.java index 283172c0..ce09a051 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestZonedDateTimeSerializationWithCustomFormatter.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/TestZonedDateTimeSerializationWithCustomFormatter.java @@ -4,34 +4,26 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.module.SimpleModule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; import java.util.TimeZone; +import java.util.stream.Stream; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.StringContains.containsString; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class TestZonedDateTimeSerializationWithCustomFormatter { - private final DateTimeFormatter formatter; +import static org.junit.jupiter.api.Assertions.assertTrue; - public TestZonedDateTimeSerializationWithCustomFormatter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - @Test - public void testSerialization() throws Exception { +public class TestZonedDateTimeSerializationWithCustomFormatter { + + @MethodSource("customFormatters") + @ParameterizedTest + public void testSerialization(DateTimeFormatter formatter) throws Exception { ZonedDateTime zonedDateTime = ZonedDateTime.now(); - assertThat(serializeWith(zonedDateTime, formatter), - containsString(zonedDateTime.format(formatter.withZone(ZoneOffset.UTC)))); + assertTrue(serializeWith(zonedDateTime, formatter).contains(zonedDateTime.format(formatter.withZone(ZoneOffset.UTC)))); } private String serializeWith(ZonedDateTime zonedDateTime, DateTimeFormatter f) throws Exception { @@ -44,13 +36,12 @@ private String serializeWith(ZonedDateTime zonedDateTime, DateTimeFormatter f) t return mapper.writeValueAsString(zonedDateTime); } - @Parameters - public static Collection customFormatters() { - Collection formatters = new ArrayList<>(); - formatters.add(new Object[]{DateTimeFormatter.ISO_ZONED_DATE_TIME}); - formatters.add(new Object[]{DateTimeFormatter.ISO_OFFSET_DATE_TIME}); - formatters.add(new Object[]{DateTimeFormatter.ISO_LOCAL_DATE_TIME}); - formatters.add(new Object[]{DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")}); - return formatters; + public static Stream customFormatters() { + return Stream.of( + DateTimeFormatter.ISO_ZONED_DATE_TIME, + DateTimeFormatter.ISO_OFFSET_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ") + ); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteNanosecondsTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteNanosecondsTest.java index c1080f5a..5768fd15 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteNanosecondsTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteNanosecondsTest.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; import java.time.Duration; import java.time.Instant; @@ -15,8 +14,9 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.CoreMatchers.containsString; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class WriteNanosecondsTest extends ModuleTestBase { public static final ZoneId UTC = ZoneId.of("UTC"); @@ -28,8 +28,8 @@ public void testSerializeDurationWithAndWithoutNanoseconds() throws Exception { String json = MAPPER.writeValueAsString(value); - assertThat(json, containsString("\"nanoseconds\":0.0")); - assertThat(json, containsString("\"notNanoseconds\":0")); + assertTrue(json.contains("\"nanoseconds\":0.0")); + assertTrue(json.contains("\"notNanoseconds\":0")); } @Test @@ -38,8 +38,8 @@ public void testSerializeInstantWithAndWithoutNanoseconds() throws Exception { String json = MAPPER.writeValueAsString(input); - assertThat(json, containsString("\"nanoseconds\":0.0")); - assertThat(json, containsString("\"notNanoseconds\":0")); + assertTrue(json.contains("\"nanoseconds\":0.0")); + assertTrue(json.contains("\"notNanoseconds\":0")); } @Test @@ -51,8 +51,8 @@ public void testSerializeLocalDateTimeWithAndWithoutNanoseconds() throws Excepti String json = MAPPER.writeValueAsString(input); - assertThat(json, containsString("\"nanoseconds\":[1970,1,1,0,0,0,1]")); - assertThat(json, containsString("\"notNanoseconds\":[1970,1,1,0,0,0,0]")); + assertTrue(json.contains("\"nanoseconds\":[1970,1,1,0,0,0,1]")); + assertTrue(json.contains("\"notNanoseconds\":[1970,1,1,0,0,0,0]")); } @Test @@ -64,8 +64,8 @@ public void testSerializeLocalTimeWithAndWithoutNanoseconds() throws Exception { String json = MAPPER.writeValueAsString(input); - assertThat(json, containsString("\"nanoseconds\":[0,0,0,1]")); - assertThat(json, containsString("\"notNanoseconds\":[0,0,0,0]")); + assertTrue(json.contains("\"nanoseconds\":[0,0,0,1]")); + assertTrue(json.contains("\"notNanoseconds\":[0,0,0,0]")); } @Test @@ -74,8 +74,8 @@ public void testSerializeOffsetDateTimeWithAndWithoutNanoseconds() throws Except String json = MAPPER.writeValueAsString(input); - assertThat(json, containsString("\"nanoseconds\":0.0")); - assertThat(json, containsString("\"notNanoseconds\":0")); + assertTrue(json.contains("\"nanoseconds\":0.0")); + assertTrue(json.contains("\"notNanoseconds\":0")); } @Test @@ -87,8 +87,8 @@ public void testSerializeOffsetTimeWithAndWithoutNanoseconds() throws Exception String json = MAPPER.writeValueAsString(input); - assertThat(json, containsString("\"nanoseconds\":[0,0,0,1,\"Z\"]")); - assertThat(json, containsString("\"notNanoseconds\":[0,0,0,0,\"Z\"]")); + assertTrue(json.contains("\"nanoseconds\":[0,0,0,1,\"Z\"]")); + assertTrue(json.contains("\"notNanoseconds\":[0,0,0,0,\"Z\"]")); } @Test @@ -97,8 +97,8 @@ public void testSerializeZonedDateTimeWithAndWithoutNanoseconds() throws Excepti String json = MAPPER.writeValueAsString(input); - assertThat(json, containsString("\"nanoseconds\":0.0")); - assertThat(json, containsString("\"notNanoseconds\":0")); + assertTrue(json.contains("\"nanoseconds\":0.0")); + assertTrue(json.contains("\"notNanoseconds\":0")); } private static class DummyClass { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteZoneIdTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteZoneIdTest.java index f9c2c0e1..957965eb 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteZoneIdTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/WriteZoneIdTest.java @@ -5,6 +5,8 @@ import java.time.ZonedDateTime; import java.util.HashMap; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -12,10 +14,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class WriteZoneIdTest extends ModuleTestBase { @@ -39,7 +38,7 @@ public void testSerialization01() throws Exception { ZoneId id = ZoneId.of("America/Chicago"); String value = MAPPER.writeValueAsString(id); - assertEquals("The value is not correct.", "\"America/Chicago\"", value); + assertEquals("\"America/Chicago\"", value); } @Test @@ -47,7 +46,7 @@ public void testSerialization02() throws Exception { ZoneId id = ZoneId.of("America/Anchorage"); String value = MAPPER.writeValueAsString(id); - assertEquals("The value is not correct.", "\"America/Anchorage\"", value); + assertEquals("\"America/Anchorage\"", value); } @Test @@ -59,7 +58,7 @@ public void testSerializationWithTypeInfo01() throws Exception .addModule(new JavaTimeModule()) .build(); String value = mapper.writeValueAsString(id); - assertEquals("The value is not correct.", "[\"java.time.ZoneId\",\"America/Denver\"]", value); + assertEquals("[\"java.time.ZoneId\",\"America/Denver\"]", value); } @Test @@ -74,11 +73,11 @@ public void testJacksonAnnotatedPOJOWithDateWithTimezoneToJson() throws Exceptio // just verify appending of timezone id itself: String json = MAPPER.writeValueAsString(input); if (!json.contains("\"01-01-1970T")) { - Assert.fail("Should contain time prefix, did not: "+json); + fail("Should contain time prefix, did not: "+json); } String match = String.format("[%s]", ZONE_ID_STR); if (!json.contains(match)) { - Assert.fail("Should contain zone id "+match+", does not: "+json); + fail("Should contain zone id "+match+", does not: "+json); } } @@ -91,6 +90,6 @@ public void testMapSerialization() throws Exception { String json = MAPPER.writer() .with(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) .writeValueAsString(map); - Assert.assertEquals("{\"2007-12-03T10:15:30+01:00[Europe/Warsaw]\":\"\"}", json); + assertEquals("{\"2007-12-03T10:15:30+01:00[Europe/Warsaw]\":\"\"}", json); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearMonthSerializationTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearMonthSerializationTest.java index 11984715..f7d48284 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearMonthSerializationTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearMonthSerializationTest.java @@ -16,14 +16,12 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.time.Month; import java.time.YearMonth; import java.time.temporal.Temporal; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; @@ -32,7 +30,7 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class YearMonthSerializationTest extends ModuleTestBase @@ -60,8 +58,8 @@ public void testSerializationAsTimestamp01() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[1986,1]", value); + assertNotNull(value); + assertEquals("[1986,1]", value); } @Test @@ -72,8 +70,8 @@ public void testSerializationAsTmestamp02() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "[2013,8]", value); + assertNotNull(value); + assertEquals("[2013,8]", value); } @Test @@ -84,8 +82,8 @@ public void testSerializationAsString01() throws Exception .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + yearMonth.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + yearMonth.toString() + '"', value); } @Test @@ -96,8 +94,8 @@ public void testSerializationAsString02() throws Exception .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", '"' + yearMonth.toString() + '"', value); + assertNotNull(value); + assertEquals('"' + yearMonth.toString() + '"', value); } @Test @@ -109,9 +107,8 @@ public void testSerializationWithTypeInfo01() throws Exception .addMixIn(Temporal.class, MockObjectConfiguration.class); String value = mapper.writeValueAsString(yearMonth); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", - "[\"" + YearMonth.class.getName() + "\",\"" + yearMonth.toString() + "\"]", value); + assertNotNull(value); + assertEquals("[\"" + YearMonth.class.getName() + "\",\"" + yearMonth.toString() + "\"]", value); } @Test @@ -120,8 +117,8 @@ public void testDeserializationAsTimestamp01() throws Exception YearMonth yearMonth = YearMonth.of(1986, Month.JANUARY); YearMonth value = MAPPER.readValue("[1986,1]", YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -130,8 +127,8 @@ public void testDeserializationAsTimestamp02() throws Exception YearMonth yearMonth = YearMonth.of(2013, Month.AUGUST); YearMonth value = MAPPER.readValue("[2013,8]", YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -140,8 +137,8 @@ public void testDeserializationAsString01() throws Exception YearMonth yearMonth = YearMonth.of(1986, Month.JANUARY); YearMonth value = MAPPER.readValue('"' + yearMonth.toString() + '"', YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -150,8 +147,8 @@ public void testDeserializationAsString02() throws Exception YearMonth yearMonth = YearMonth.of(2013, Month.AUGUST); YearMonth value = this.MAPPER.readValue('"' + yearMonth.toString() + '"', YearMonth.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertEquals(yearMonth, value); } @Test @@ -163,9 +160,9 @@ public void testDeserializationWithTypeInfo01() throws Exception .addMixIn(Temporal.class, MockObjectConfiguration.class); Temporal value = mapper.readValue("[\"" + YearMonth.class.getName() + "\",\"" + yearMonth.toString() + "\"]", Temporal.class); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be a YearMonth.", value instanceof YearMonth); - assertEquals("The value is not correct.", yearMonth, value); + assertNotNull(value); + assertInstanceOf(YearMonth.class, value, "The value should be a YearMonth."); + assertEquals(yearMonth, value); } @Test @@ -176,8 +173,8 @@ public void testSerializationWithPattern01() throws Exception String value = MAPPER.writeValueAsString(simpleAggregate); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "{\"yearMonth\":\"1308\"}", value); + assertNotNull(value); + assertEquals("{\"yearMonth\":\"1308\"}", value); } @Test @@ -188,7 +185,7 @@ public void testDeserializationWithPattern01() throws Exception SimpleAggregate value = MAPPER.readValue("{\"yearMonth\":\"1308\"}", SimpleAggregate.class); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", simpleAggregate.yearMonth, value.yearMonth); + assertNotNull(value); + assertEquals(simpleAggregate.yearMonth, value.yearMonth); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearSerTest.java index 23501ce4..ac67be3a 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/YearSerTest.java @@ -19,13 +19,13 @@ import java.time.Year; import java.time.temporal.Temporal; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class YearSerTest extends ModuleTestBase { @@ -34,9 +34,9 @@ public class YearSerTest extends ModuleTestBase @Test public void testDefaultSerialization() throws Exception { - assertEquals("The value is not correct.", "1986", + assertEquals("1986", MAPPER.writeValueAsString(Year.of(1986))); - assertEquals("The value is not correct.", "2013", + assertEquals("2013", MAPPER.writeValueAsString(Year.of(2013))); } @@ -46,6 +46,6 @@ public void testSerializationWithTypeInfo() throws Exception ObjectMapper mapper = newMapper() .addMixIn(Temporal.class, MockObjectConfiguration.class); String value = mapper.writeValueAsString(Year.of(2005)); - assertEquals("The value is not correct.", "[\"" + Year.class.getName() + "\",2005]", value); + assertEquals("[\"" + Year.class.getName() + "\",2005]", value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerTest.java index 6d74618f..b2a7c6d5 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerTest.java @@ -16,15 +16,15 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.junit.Assert.assertEquals; - import java.time.ZoneId; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class ZoneIdSerTest extends ModuleTestBase { @@ -38,20 +38,20 @@ public class ZoneIdSerTest extends ModuleTestBase public void testSerialization01() throws Exception { final String value = MAPPER.writeValueAsString(ZoneId.of("America/Chicago")); - assertEquals("The value is not correct.", "\"America/Chicago\"", value); + assertEquals("\"America/Chicago\"", value); } @Test public void testSerialization02() throws Exception { final String value = MAPPER.writeValueAsString(ZoneId.of("America/Anchorage")); - assertEquals("The value is not correct.", "\"America/Anchorage\"", value); + assertEquals("\"America/Anchorage\"", value); } @Test public void testSerializationWithTypeInfo01() throws Exception { String value = MOCK_OBJECT_MIXIN_MAPPER.writeValueAsString(ZoneId.of("America/Denver")); - assertEquals("The value is not correct.", "[\"java.time.ZoneId\",\"America/Denver\"]", value); + assertEquals("[\"java.time.ZoneId\",\"America/Denver\"]", value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneOffsetSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneOffsetSerTest.java index 11472215..97181f97 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneOffsetSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZoneOffsetSerTest.java @@ -19,13 +19,13 @@ import java.time.ZoneId; import java.time.ZoneOffset; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; public class ZoneOffsetSerTest extends ModuleTestBase { @@ -36,7 +36,7 @@ public void testSerialization01() throws Exception { ZoneOffset offset = ZoneOffset.of("Z"); String value = MAPPER.writeValueAsString(offset); - assertEquals("The value is not correct.", "\"Z\"", value); + assertEquals("\"Z\"", value); } @Test @@ -44,7 +44,7 @@ public void testSerialization02() throws Exception { ZoneOffset offset = ZoneOffset.of("+0300"); String value = MAPPER.writeValueAsString(offset); - assertEquals("The value is not correct.", "\"+03:00\"", value); + assertEquals("\"+03:00\"", value); } @Test @@ -52,7 +52,7 @@ public void testSerialization03() throws Exception { ZoneOffset offset = ZoneOffset.of("-0630"); String value = MAPPER.writeValueAsString(offset); - assertEquals("The value is not correct.", "\"-06:30\"", value); + assertEquals("\"-06:30\"", value); } @Test @@ -62,6 +62,6 @@ public void testSerializationWithTypeInfo03() throws Exception .addMixIn(ZoneId.class, MockObjectConfiguration.class); ZoneOffset offset = ZoneOffset.of("+0415"); String value = mapper.writeValueAsString(offset); - assertEquals("The value is not correct.", "[\"" + ZoneOffset.class.getName() + "\",\"+04:15\"]", value); + assertEquals("[\"" + ZoneOffset.class.getName() + "\",\"+04:15\"]", value); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java index 5c306770..aaca9ff6 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java @@ -16,10 +16,6 @@ package com.fasterxml.jackson.datatype.jsr310.ser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import com.fasterxml.jackson.core.JsonProcessingException; import java.time.Instant; import java.time.ZoneId; @@ -32,10 +28,11 @@ import java.util.Locale; import java.util.TimeZone; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import org.junit.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -46,6 +43,8 @@ import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class ZonedDateTimeSerTest extends ModuleTestBase { @@ -95,7 +94,7 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "0.0", value); + assertEquals("0.0", value); } @Test @@ -108,7 +107,7 @@ public void testSerializationAsTimestamp01NegativeSeconds() throws Exception .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); ZonedDateTime actual = MAPPER.readValue(serialized, ZonedDateTime.class); - assertEquals("The value is not correct.", date, actual); + assertEquals(date, actual); } @Test @@ -119,14 +118,14 @@ public void testSerializationAsTimestamp01NegativeSecondsWithDefaults() throws E ZonedDateTime original = ZonedDateTime.parse("Apr 13 1969 05:05:38.599 UTC", dtf); String serialized = MAPPER.writeValueAsString(original); ZonedDateTime deserialized = MAPPER.readValue(serialized, ZonedDateTime.class); - assertEquals("The day is not correct.", original.getDayOfMonth(), deserialized.getDayOfMonth()); - assertEquals("The month is not correct.", original.getMonthValue(), deserialized.getMonthValue()); - assertEquals("The year is not correct.", original.getYear(), deserialized.getYear()); - assertEquals("The hour is not correct.", original.getHour(), deserialized.getHour()); - assertEquals("The minute is not correct.", original.getMinute(), deserialized.getMinute()); - assertEquals("The second is not correct.", original.getSecond(), deserialized.getSecond()); - assertEquals("The nano is not correct.", original.getNano(), deserialized.getNano()); - assertEquals("The time zone is not correct.", ZoneId.of("UTC").getRules(), deserialized.getZone().getRules()); + assertEquals(original.getDayOfMonth(), deserialized.getDayOfMonth(), "The day is not correct."); + assertEquals(original.getMonthValue(), deserialized.getMonthValue(), "The month is not correct."); + assertEquals(original.getYear(), deserialized.getYear(), "The year is not correct."); + assertEquals(original.getHour(), deserialized.getHour(), "The hour is not correct."); + assertEquals(original.getMinute(), deserialized.getMinute(), "The minute is not correct."); + assertEquals(original.getSecond(), deserialized.getSecond(), "The second is not correct."); + assertEquals(original.getNano(), deserialized.getNano(), "The nano is not correct."); + assertEquals(ZoneId.of("UTC").getRules(), deserialized.getZone().getRules(), "The time zone is not correct."); } @Test @@ -137,7 +136,7 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "0", value); + assertEquals("0", value); } @Test @@ -148,7 +147,7 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertEquals("123456789.183917322", value); } @Test @@ -159,7 +158,7 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", "123456789183", value); + assertEquals("123456789183", value); } @Test @@ -170,7 +169,7 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .with(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); + assertEquals(DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), value); } @Test @@ -181,7 +180,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .without(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .writeValueAsString(date); - assertEquals("The value is not correct.", Long.toString(date.toInstant().toEpochMilli()), value); + assertEquals(Long.toString(date.toInstant().toEpochMilli()), value); } @Test @@ -191,7 +190,7 @@ public void testSerializationAsString01() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + assertEquals('"' + FORMATTER.withZone(Z1).format(date) + '"', value); } @@ -202,7 +201,7 @@ public void testSerializationAsString02() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + assertEquals('"' + FORMATTER.withZone(Z2).format(date) + '"', value); } @@ -213,7 +212,7 @@ public void testSerializationAsString03() throws Exception String value = MAPPER.writer() .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + assertEquals('"' + FORMATTER.withZone(Z3).format(date) + '"', value); } @@ -225,7 +224,7 @@ public void testSerializationAsStringWithMapperTimeZone01() throws Exception .with(TimeZone.getTimeZone(Z1)) .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -236,7 +235,7 @@ public void testSerializationAsStringWithMapperTimeZone02() throws Exception .with(TimeZone.getTimeZone(Z2)) .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -247,7 +246,7 @@ public void testSerializationAsStringWithMapperTimeZone03() throws Exception .with(TimeZone.getTimeZone(Z3)) .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .writeValueAsString(date); - assertEquals("The value is not correct.", '"' + FORMATTER.format(date) + '"', value); + assertEquals('"' + FORMATTER.format(date) + '"', value); } @Test @@ -258,7 +257,7 @@ public void testSerializationAsStringWithZoneIdOff() throws Exception { SerializationFeature.WRITE_DATES_WITH_ZONE_ID) .writeValueAsString(date); - assertEquals("The value is incorrect.", "\"" + assertEquals("\"" + FORMATTER.withZone(Z3).format(date) + "\"", value); } @@ -271,7 +270,7 @@ public void testSerializationAsStringWithZoneIdOffAndMapperTimeZone() throws Exc SerializationFeature.WRITE_DATES_WITH_ZONE_ID) .writeValueAsString(date); - assertEquals("The value is incorrect.", "\"" + FORMATTER.format(date) + "\"", value); + assertEquals("\"" + FORMATTER.format(date) + "\"", value); } @Test @@ -282,7 +281,7 @@ public void testSerializationAsStringWithZoneIdOn() throws Exception { .with(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) .writeValueAsString(date); - assertEquals("The value is incorrect.", "\"" + DateTimeFormatter.ISO_ZONED_DATE_TIME.format(date) + "\"", value); + assertEquals("\"" + DateTimeFormatter.ISO_ZONED_DATE_TIME.format(date) + "\"", value); } @Test @@ -297,7 +296,7 @@ public void testSerializationAsStringWithDefaultTimeZoneAndContextTimeZoneOnAndA .writeValueAsString(date); // We expect to have the date written with the datetime of ZoneId Z2 - assertEquals("The value is incorrect", "\"" + date.withZoneSameInstant(Z2).format(FORMATTER_WITHOUT_ZONEID) + "\"", value); + assertEquals("\"" + date.withZoneSameInstant(Z2).format(FORMATTER_WITHOUT_ZONEID) + "\"", value); } @Test @@ -312,7 +311,7 @@ public void testSerializationAsStringWithDefaultTimeZoneAndContextTimeZoneOffAnd .writeValueAsString(date); // We expect to have the date written with the datetime of ZoneId Z3 - assertEquals("The value is incorrect", "\"" + date.format(FORMATTER_WITHOUT_ZONEID) + "\"", value); + assertEquals("\"" + date.format(FORMATTER_WITHOUT_ZONEID) + "\"", value); } @Test @@ -326,7 +325,7 @@ public void testSerializationAsStringWithDefaultTimeZoneAndContextTimeZoneOn() t .writeValueAsString(date); // We expect to have the date written with the ZoneId Z2 - assertEquals("The value is incorrect", "\"" + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(date.withZoneSameInstant(Z2)) + "\"", value); + assertEquals("\"" + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(date.withZoneSameInstant(Z2)) + "\"", value); } @Test @@ -340,7 +339,7 @@ public void testSerializationAsStringWithDefaultTimeZoneAndContextTimeZoneOff() .writeValueAsString(date); // We expect to have the date written with the ZoneId Z3 - assertEquals("The value is incorrect", "\"" + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(date) + "\"", value); + assertEquals("\"" + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(date) + "\"", value); } @Test @@ -353,8 +352,7 @@ public void testSerializationWithTypeInfo01() throws Exception .enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .build() .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", value); + assertEquals("[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", value); } @Test @@ -367,8 +365,7 @@ public void testSerializationWithTypeInfo02() throws Exception .disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS) .build() .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + ZonedDateTime.class.getName() + "\",123456789183]", value); + assertEquals("[\"" + ZonedDateTime.class.getName() + "\",123456789183]", value); } @Test @@ -380,8 +377,7 @@ public void testSerializationWithTypeInfo03() throws Exception .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .build() .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + ZonedDateTime.class.getName() + "\",\"" + assertEquals("[\"" + ZonedDateTime.class.getName() + "\",\"" + FORMATTER.withZone(Z3).format(date) + "\"]", value); } @@ -396,8 +392,7 @@ public void testSerializationWithTypeInfoAndMapperTimeZone() throws Exception .writer() .with(TimeZone.getTimeZone(Z3)) .writeValueAsString(date); - assertEquals("The value is not correct.", - "[\"" + ZonedDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); + assertEquals("[\"" + ZonedDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]", value); } @Test @@ -406,9 +401,9 @@ public void testDeserializationAsFloat01WithoutTimeZone() throws Exception ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); ZonedDateTime value = MAPPER.readValue("0.000000000", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -420,9 +415,9 @@ public void testDeserializationAsFloat01WithTimeZone() throws Exception .with(TimeZone.getDefault()) .readValue("0.000000000"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -432,9 +427,9 @@ public void testDeserializationAsFloat02WithoutTimeZone() throws Exception ZonedDateTime value = this.MAPPER.readValue("123456789.183917322", ZonedDateTime.class); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -446,9 +441,9 @@ public void testDeserializationAsFloat02WithTimeZone() throws Exception .with(TimeZone.getDefault()) .readValue("123456789.183917322"); - assertNotNull("The value should not be null.", value); + assertNotNull(value); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -459,7 +454,7 @@ public void testDeserializationAsFloat03WithoutTimeZone() throws Exception DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano()), ZonedDateTime.class ); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -471,7 +466,7 @@ public void testDeserializationAsFloat03WithTimeZone() throws Exception .readValue(DecimalUtils.toDecimal(date.toEpochSecond(), date.getNano())); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -483,7 +478,7 @@ public void testDeserializationAsInt01NanosecondsWithoutTimeZone() throws Except .readValue("0"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -496,7 +491,7 @@ public void testDeserializationAsInt01NanosecondsWithTimeZone() throws Exception .readValue("0"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -508,7 +503,7 @@ public void testDeserializationAsInt01MillisecondsWithoutTimeZone() throws Excep .readValue("0"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -521,7 +516,7 @@ public void testDeserializationAsInt01MillisecondsWithTimeZone() throws Exceptio .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -532,7 +527,7 @@ public void testDeserializationAsInt02NanosecondsWithoutTimeZone() throws Except .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -544,7 +539,7 @@ public void testDeserializationAsInt02NanosecondsWithTimeZone() throws Exception .with(TimeZone.getDefault()) .readValue("123456789"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -555,7 +550,7 @@ public void testDeserializationAsInt02MillisecondsWithoutTimeZone() throws Excep .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789422"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -567,7 +562,7 @@ public void testDeserializationAsInt02MillisecondsWithTimeZone() throws Exceptio .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789422"); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -580,7 +575,7 @@ public void testDeserializationAsInt03NanosecondsWithoutTimeZone() throws Except .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(date.toEpochSecond()), ZonedDateTime.class); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -594,7 +589,7 @@ public void testDeserializationAsInt03NanosecondsWithTimeZone() throws Exception .with(TimeZone.getDefault()) .readValue(Long.toString(date.toEpochSecond()), ZonedDateTime.class); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -607,7 +602,7 @@ public void testDeserializationAsInt03MillisecondsWithoutTimeZone() throws Excep .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(date.toInstant().toEpochMilli())); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -621,7 +616,7 @@ public void testDeserializationAsInt03MillisecondsWithTimeZone() throws Exceptio .with(TimeZone.getDefault()) .readValue(Long.toString(date.toInstant().toEpochMilli())); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -632,7 +627,7 @@ public void testDeserializationAsString01WithoutTimeZone() throws Exception .with(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -644,7 +639,7 @@ public void testDeserializationAsString01WithTimeZone() throws Exception .with(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -656,7 +651,7 @@ public void testDeserializationAsString01WithTimeZoneTurnedOff() throws Exceptio .with(TimeZone.getDefault()) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", FIX_OFFSET, value.getZone()); + assertEquals(FIX_OFFSET, value.getZone(), "The time zone is not correct."); } @Test @@ -674,7 +669,7 @@ public void testDeserializationAsString02WithoutTimeZone() throws Exception .with(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -686,7 +681,7 @@ public void testDeserializationAsString02WithTimeZone() throws Exception .with(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -698,7 +693,7 @@ public void testDeserializationAsString02WithTimeZoneTurnedOff() throws Exceptio .without(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", FIX_OFFSET, value.getZone()); + assertEquals(FIX_OFFSET, value.getZone(), "The time zone is not correct."); } @Test @@ -716,7 +711,7 @@ public void testDeserializationAsString03WithoutTimeZone() throws Exception .with(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, value.getZone()); + assertEquals(DEFAULT_TZ, value.getZone(), "The time zone is not correct."); } @Test @@ -728,7 +723,7 @@ public void testDeserializationAsString03WithTimeZone() throws Exception .with(TimeZone.getDefault()) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), value.getZone()); + assertEquals(ZoneId.systemDefault().normalized(), value.getZone(), "The time zone is not correct."); } @Test @@ -740,7 +735,7 @@ public void testDeserializationAsString03WithTimeZoneTurnedOff() throws Exceptio .without(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue('"' + FORMATTER.format(date) + '"'); assertIsEqual(date, value); - assertEquals("The time zone is not correct.", FIX_OFFSET, value.getZone()); + assertEquals(FIX_OFFSET, value.getZone(), "The time zone is not correct."); } @Test @@ -760,10 +755,10 @@ public void testDeserializationWithTypeInfo01WithoutTimeZone() throws Exception .readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", Temporal.class ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -780,10 +775,10 @@ public void testDeserializationWithTypeInfo01WithTimeZone() throws Exception ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -797,9 +792,9 @@ public void testDeserializationWithTypeInfo02WithoutTimeZone() throws Exception .readerFor(Temporal.class) .readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789]"); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -816,10 +811,10 @@ public void testDeserializationWithTypeInfo02WithTimeZone() throws Exception "[\"" + ZonedDateTime.class.getName() + "\",123456789]" ); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -834,10 +829,10 @@ public void testDeserializationWithTypeInfo03WithoutTimeZone() throws Exception .readValue( "[\"" + ZonedDateTime.class.getName() + "\",123456789422]"); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -852,10 +847,10 @@ public void testDeserializationWithTypeInfo03WithTimeZone() throws Exception .with(TimeZone.getDefault()) .readValue("[\"" + ZonedDateTime.class.getName() + "\",123456789422]"); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -870,10 +865,10 @@ public void testDeserializationWithTypeInfo04WithoutTimeZone() throws Exception .readValue( "[\"" + ZonedDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]"); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", DEFAULT_TZ, ((ZonedDateTime) value).getZone()); + assertEquals(DEFAULT_TZ, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -890,10 +885,10 @@ public void testDeserializationWithTypeInfo04WithTimeZone() throws Exception .readValue( "[\"" + ZonedDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]"); - assertNotNull("The value should not be null.", value); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertNotNull(value); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone()); + assertEquals(ZoneId.systemDefault().normalized(), ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -909,9 +904,9 @@ public void testDeserializationWithTypeInfo04WithTimeZoneTurnedOff() throws Exce .without(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .readValue( "[\"" + ZonedDateTime.class.getName() + "\",\"" + FORMATTER.format(date) + "\"]"); - assertTrue("The value should be an ZonedDateTime.", value instanceof ZonedDateTime); + assertInstanceOf(ZonedDateTime.class, value, "The value should be an ZonedDateTime."); assertIsEqual(date, (ZonedDateTime) value); - assertEquals("The time zone is not correct.", FIX_OFFSET, ((ZonedDateTime) value).getZone()); + assertEquals(FIX_OFFSET, ((ZonedDateTime) value).getZone(), "The time zone is not correct."); } @Test @@ -982,7 +977,7 @@ public void testShapeInt() throws JsonProcessingException { private static void assertIsEqual(ZonedDateTime expected, ZonedDateTime actual) { - assertTrue("The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">.", - expected.isEqual(actual)); + assertTrue(expected.isEqual(actual), + "The value is not correct. Expected timezone-adjusted <" + expected + ">, actual <" + actual + ">."); } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerWithJsonFormat333Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerWithJsonFormat333Test.java index a15055f7..5e1e8111 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerWithJsonFormat333Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerWithJsonFormat333Test.java @@ -2,14 +2,14 @@ import java.time.ZonedDateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; // [module-java8#333]: ZonedDateTime serialization with @JsonFormat pattern never uses // while WRITE_DATES_WITH_ZONE_ID enabled #333 diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/util/DurationUnitConverterTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/util/DurationUnitConverterTest.java index bf75bba7..7873baf8 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/util/DurationUnitConverterTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/util/DurationUnitConverterTest.java @@ -1,14 +1,13 @@ package com.fasterxml.jackson.datatype.jsr310.util; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - import java.time.temporal.ChronoUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class DurationUnitConverterTest extends ModuleTestBase { @@ -47,8 +46,8 @@ public void shouldNotMapToTemporalUnit() { // Not matching at all "DOESNOTMATCH", "", " " }) { - assertNull("Should not map pattern '"+invalid+"'", - DurationUnitConverter.from(invalid)); + assertNull(DurationUnitConverter.from(invalid), + "Should not map pattern '"+invalid+"'"); } } } From c329996ad30282aa655395f06327aae93628b3f3 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 27 Jan 2025 17:15:49 -0800 Subject: [PATCH 014/140] Fix Java 8-only/9+-only tests: need to use Assumptions, NOT Assertions --- .../deser/key/ZonedDateTimeKeyDeserializerTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java index 096e2255..802d10b2 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/key/ZonedDateTimeKeyDeserializerTest.java @@ -11,6 +11,8 @@ import java.util.Map; import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; // for [modules-java8#306] public class ZonedDateTimeKeyDeserializerTest @@ -37,10 +39,11 @@ public void ZonedDateTime_with_zone_name_can_be_deserialized() throws Exception } // 29-Oct-2024, tatu: Following two tests are for Java 8+ only vs Java 9 or later - + + // Java 9+ test @Test public void ZonedDateTime_with_place_name_can_be_deserialized() throws Exception { - assertFalse(System.getProperty("java.version").startsWith("1.8")); + assumeFalse(System.getProperty("java.version").startsWith("1.8")); Map map = MAPPER.readValue(getMap("2015-07-24T12:23:34.184Z[Europe/London]"), MAP_TYPE_REF); @@ -48,10 +51,11 @@ public void ZonedDateTime_with_place_name_can_be_deserialized() throws Exception assertEquals("2015-07-24T13:23:34.184+01:00[Europe/London]", entry.getKey().toString()); } + // Java 8 test @Test public void ZonedDateTime_with_place_name_can_be_deserialized_Java_8() throws Exception { // Java 8 parses this format incorrectly due to https://bugs.openjdk.org/browse/JDK-8066982 - assertTrue(System.getProperty("java.version").startsWith("1.8")); + assumeTrue(System.getProperty("java.version").startsWith("1.8")); Map map = MAPPER.readValue(getMap("2015-07-24T12:23:34.184Z[Europe/London]"), MAP_TYPE_REF); From c635caa7e17fe06b0f71d5fc5c0d4eabae18a65b Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 27 Jan 2025 17:25:22 -0800 Subject: [PATCH 015/140] Another Assumption -> Assertion case to fix --- .../jackson/datatype/jsr310/deser/InstantDeserTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java index 3768276a..b446cdc8 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserTest.java @@ -26,6 +26,7 @@ import static com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.ISO8601_COLONLESS_OFFSET_REGEX; import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class InstantDeserTest extends ModuleTestBase { @@ -520,7 +521,7 @@ private String formatWithZeroZoneOffset(Instant date, String offset){ private static void assumeInstantCanParseOffsets() { // DateTimeFormatter.ISO_INSTANT didn't handle offsets until JDK 12+. // This was added by https://bugs.openjdk.org/browse/JDK-8166138 - assertTrue(System.getProperty("java.specification.version").compareTo("12") > 0); + assumeTrue(System.getProperty("java.specification.version").compareTo("12") > 0); } /* From 8297686076bfaa4aa202648ec66659a4d76caa75 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 27 Jan 2025 18:02:30 -0800 Subject: [PATCH 016/140] Fix problem wrt #207 on 2.19 (#352) --- .../datatype/jsr310/JavaTimeModule.java | 30 ++++++++++++++++++- .../jsr310/ser/OneBasedMonthSerTest.java | 2 -- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java index 2325c5f0..1a27406e 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java @@ -17,6 +17,7 @@ package com.fasterxml.jackson.datatype.jsr310; import java.time.*; +import java.time.temporal.TemporalAdjuster; import com.fasterxml.jackson.core.util.JacksonFeatureSet; @@ -31,6 +32,7 @@ import com.fasterxml.jackson.databind.module.SimpleKeyDeserializers; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleSerializers; +import com.fasterxml.jackson.databind.ser.std.ToEmptyObjectSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.datatype.jsr310.deser.*; import com.fasterxml.jackson.datatype.jsr310.deser.key.*; @@ -152,7 +154,7 @@ public void setupModule(SetupContext context) { context.addDeserializers(_deserializers); } - SimpleSerializers sers = new SimpleSerializers(); + JavaTimeSerializers sers = new JavaTimeSerializers(); sers.addSerializer(Duration.class, DurationSerializer.INSTANCE); sers.addSerializer(Instant.class, InstantSerializer.INSTANCE); @@ -278,4 +280,30 @@ protected AnnotatedMethod _findFactory(AnnotatedClass cls, String name, Class } return null; } + + /** + * Container for serializers, with one tweak; specific lookup we need to deal + * with specific {@code TemporalAdjuster} closure subtypes. + * + * @since 2.19 + */ + @SuppressWarnings("serial") + class JavaTimeSerializers extends SimpleSerializers { + @Override + public JsonSerializer findSerializer(SerializationConfig config, + JavaType type, BeanDescription beanDesc) + { + JsonSerializer ser = super.findSerializer(config, type, beanDesc); + if (ser == null) { + // 27-Jan-2025, tatu: [modules-java8#207] Need actual "ToEmptySerializer" + // with Jackson 2.x, to avoid "No Bean Properties found" error + // But! Must be careful to only apply to lambdas + if (type.isTypeOrSubTypeOf(TemporalAdjuster.class) + && type.getRawClass().isSynthetic()) { + return new ToEmptyObjectSerializer(type); + } + } + return ser; + } + } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java index 0a6d12cd..fffe87f7 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OneBasedMonthSerTest.java @@ -47,7 +47,6 @@ public void testSerializationFromEnumWithPattern_zeroBased() throws Exception assertEquals( "{\"month\":0}" , mapper.writeValueAsString(new Wrapper(Month.JANUARY))); } - private JsonMapper mapperForZeroBased() { return JsonMapper.builder() .addModule(new JavaTimeModule().disable(JavaTimeFeature.ONE_BASED_MONTHS)) @@ -59,5 +58,4 @@ private JsonMapper mapperForOneBased() { .addModule(new JavaTimeModule().enable(JavaTimeFeature.ONE_BASED_MONTHS)) .build(); } - } From cfa78ec948f9fdd2df9381b986eaa6cf513cc73c Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Tue, 28 Jan 2025 11:04:49 +0900 Subject: [PATCH 017/140] Add failure testutil (#349) --- .../failure/JacksonTestFailureExpected.java | 37 ++++++++++++++++ ...JacksonTestFailureExpectedInterceptor.java | 43 +++++++++++++++++++ .../JacksonTestShouldFailException.java | 18 ++++++++ 3 files changed, 98 insertions(+) create mode 100644 datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpected.java create mode 100644 datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpectedInterceptor.java create mode 100644 datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestShouldFailException.java diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpected.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpected.java new file mode 100644 index 00000000..352ca9dd --- /dev/null +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpected.java @@ -0,0 +1,37 @@ +package com.fasterxml.jackson.datatype.jsr310.testutil.failure; + +import java.lang.annotation.*; + +import org.junit.jupiter.api.extension.ExtendWith; + +/** + *

+ * Annotation used to indicate that a JUnit-5 based tests method is expected to fail. + * + *

+ * When a test method is annotated with {@code @JacksonTestFailureExpected}, the + * {@link JacksonTestFailureExpectedInterceptor} will intercept the test execution. + * If the test passes, which is an unexpected behavior, the interceptor will throw an exception to fail the test, + * indicating that the test was expected to fail but didn't. + *

+ * + *

Usage Example:

+ * + *

+ *
+ *     @Test
+ *     @JacksonTestFailureExpected
+ *     public void testFeatureNotYetImplemented() {
+ *         // Test code that is expected to fail
+ *     }
+ * }
+ * 
+ * + *

+ * + * @since 2.19 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(JacksonTestFailureExpectedInterceptor.class) +public @interface JacksonTestFailureExpected { } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpectedInterceptor.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpectedInterceptor.java new file mode 100644 index 00000000..1de29814 --- /dev/null +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestFailureExpectedInterceptor.java @@ -0,0 +1,43 @@ +package com.fasterxml.jackson.datatype.jsr310.testutil.failure; + +import java.lang.reflect.Method; + +import org.junit.jupiter.api.extension.*; + +/** + * Custom {@link InvocationInterceptor} that intercepts test method invocation. + * To pass the test ***only if*** test fails with an exception, and fail the test otherwise. + * + * @since 2.19 + */ +public class JacksonTestFailureExpectedInterceptor + implements InvocationInterceptor +{ + @Override + public void interceptTestMethod(Invocation invocation, + ReflectiveInvocationContext invocationContext, ExtensionContext extensionContext) + throws Throwable + { + try { + invocation.proceed(); + } catch (Throwable t) { + // do-nothing, we do expect an exception + return; + } + handleUnexpectePassingTest(invocationContext); + } + + private void handleUnexpectePassingTest(ReflectiveInvocationContext invocationContext) { + // Collect information we need + Object targetClass = invocationContext.getTargetClass(); + Object testMethod = invocationContext.getExecutable().getName(); + //List arguments = invocationContext.getArguments(); + + // Create message + String message = String.format("Test method %s.%s() passed, but should have failed", targetClass, testMethod); + + // throw exception + throw new JacksonTestShouldFailException(message); + } + +} diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestShouldFailException.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestShouldFailException.java new file mode 100644 index 00000000..68790320 --- /dev/null +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/testutil/failure/JacksonTestShouldFailException.java @@ -0,0 +1,18 @@ +package com.fasterxml.jackson.datatype.jsr310.testutil.failure; + +/** + * Exception used to alert that a test is passing, but should be failing. + * + * WARNING : This only for test code, and should never be thrown from production code. + * + * @since 2.19 + */ +public class JacksonTestShouldFailException + extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public JacksonTestShouldFailException(String msg) { + super(msg); + } +} From 6d276745a49c3b1da2fe576200bf23a1f64a9cd6 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Wed, 29 Jan 2025 10:06:26 +0900 Subject: [PATCH 018/140] [JSTEP-10] Remove `/failing` tests exclusion (#353) --- datatypes/pom.xml | 5 ----- .../jsr310/{failing => tofix}/DurationDeser337Test.java | 5 ++++- .../{failing => tofix}/InstanceViaBigDecimal307Test.java | 4 +++- .../jsr310/{failing => tofix}/JDKSerializabilityTest.java | 4 +++- .../{failing => tofix}/OffsetDateTimeDeser279Test.java | 4 +++- .../jsr310/{failing => tofix}/ZonedDateTimeIssue244Test.java | 5 ++++- parameter-names/pom.xml | 5 ----- pom.xml | 5 ----- 8 files changed, 17 insertions(+), 20 deletions(-) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{failing => tofix}/DurationDeser337Test.java (90%) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{failing => tofix}/InstanceViaBigDecimal307Test.java (88%) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{failing => tofix}/JDKSerializabilityTest.java (90%) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{failing => tofix}/OffsetDateTimeDeser279Test.java (88%) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{failing => tofix}/ZonedDateTimeIssue244Test.java (89%) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 41bdbdb7..5640b006 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -35,11 +35,6 @@ JDK 8 data types. org.apache.maven.plugins ${version.plugin.surefire} maven-surefire-plugin - - - com/fasterxml/jackson/failing/*.java - - diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/DurationDeser337Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/DurationDeser337Test.java similarity index 90% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/DurationDeser337Test.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/DurationDeser337Test.java index 72d393fb..7c549085 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/DurationDeser337Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/DurationDeser337Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.failing; +package com.fasterxml.jackson.datatype.jsr310.tofix; import java.time.Duration; @@ -7,11 +7,13 @@ import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.assertEquals; public class DurationDeser337Test extends ModuleTestBase { + @JacksonTestFailureExpected @Test public void test_default() throws Exception { ObjectMapper mapper = newMapper(); @@ -29,6 +31,7 @@ public void test_default() throws Exception { } // Handling with WRITE_DURATIONS_AS_TIMESTAMPS enabled can't round-trip a value + @JacksonTestFailureExpected @Test public void test_with() throws Exception { ObjectMapper mapper = mapperBuilder() diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/InstanceViaBigDecimal307Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java similarity index 88% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/InstanceViaBigDecimal307Test.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java index ee71a563..58ddf542 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/InstanceViaBigDecimal307Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.failing; +package com.fasterxml.jackson.datatype.jsr310.tofix; import java.time.Instant; @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -32,6 +33,7 @@ public void instantViaReadValue() throws Exception { assertEquals(ISSUED_AT, deserialized.value); } + @JacksonTestFailureExpected @Test public void instantViaReadTree() throws Exception { String serialized = MAPPER.writeValueAsString(new Wrapper307(ISSUED_AT)); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/JDKSerializabilityTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/JDKSerializabilityTest.java similarity index 90% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/JDKSerializabilityTest.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/JDKSerializabilityTest.java index 60e98f96..90d38e88 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/JDKSerializabilityTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/JDKSerializabilityTest.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.failing; +package com.fasterxml.jackson.datatype.jsr310.tofix; import java.io.*; import java.time.Year; @@ -8,11 +8,13 @@ import com.fasterxml.jackson.datatype.jsr310.*; import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; public class JDKSerializabilityTest extends ModuleTestBase { + @JacksonTestFailureExpected @Test public void testJDKSerializability() throws Exception { final Year input = Year.of(1986); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/OffsetDateTimeDeser279Test.java similarity index 88% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/OffsetDateTimeDeser279Test.java index e0eada25..02b7869c 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/OffsetDateTimeDeser279Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.failing; +package com.fasterxml.jackson.datatype.jsr310.tofix; import java.time.OffsetDateTime; import java.time.ZoneId; @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -33,6 +34,7 @@ public void setDate(OffsetDateTime date) { private ObjectMapper MAPPER = newMapper(); // For [modules-java8#279] + @JacksonTestFailureExpected @Test public void testWrapperWithPattern279() throws Exception { diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/ZonedDateTimeIssue244Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java similarity index 89% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/ZonedDateTimeIssue244Test.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java index 93ae95a6..a25bbb72 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/ZonedDateTimeIssue244Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.failing; +package com.fasterxml.jackson.datatype.jsr310.tofix; import java.time.ZoneId; import java.time.ZoneOffset; @@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -21,6 +22,7 @@ public class ZonedDateTimeIssue244Test extends ModuleTestBase .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .build(); + @JacksonTestFailureExpected @Test public void zoneIdUTC() throws Exception { @@ -33,6 +35,7 @@ public void zoneOffsetUTC() throws Exception assertSerializeAndDeserialize(ZonedDateTime.now(ZoneOffset.UTC)); // fails! } + @JacksonTestFailureExpected @Test public void zoneOffsetNonUTC() throws Exception { diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 43bf73bc..ea279856 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -96,11 +96,6 @@ introspection of method/constructor parameter names, without having to add expli org.apache.maven.plugins maven-surefire-plugin ${version.plugin.surefire} - - - ${packageVersion.dir}/failing/*.java - - + + + org.gradlex + gradle-module-metadata-maven-plugin + diff --git a/datetime/pom.xml b/datetime/pom.xml index 03896517..1e435ccd 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -124,6 +124,12 @@ org.moditect moditect-maven-plugin + + + + org.gradlex + gradle-module-metadata-maven-plugin + diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 5b825cee..c3079739 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -103,6 +103,12 @@ introspection of method/constructor parameter names, without having to add expli org.moditect moditect-maven-plugin + + + + org.gradlex + gradle-module-metadata-maven-plugin + diff --git a/pom.xml b/pom.xml index 15636b4e..bbde1ef3 100644 --- a/pom.xml +++ b/pom.xml @@ -86,14 +86,5 @@ - - - - - de.jjohannes - gradle-module-metadata-maven-plugin - - - From 543a5ba6097295b0da241960a89e3042f47f4cd0 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 4 Mar 2025 21:16:23 -0800 Subject: [PATCH 026/140] Fix Junit 4 tests to use JUnit 5 --- .../jsr310/deser/InstantDeser291Test.java | 5 ++--- .../jsr310/deser/OffsetTimeDeserTest.java | 19 +++---------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeser291Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeser291Test.java index 78804c0f..7081a921 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeser291Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeser291Test.java @@ -3,7 +3,7 @@ import java.time.Instant; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.json.JsonReadFeature; import com.fasterxml.jackson.databind.ObjectReader; @@ -13,8 +13,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.*; // [modules-java8#291] InstantDeserializer fails to parse negative numeric timestamp strings for // pre-1970 values. diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java index 4ddbb78f..febeda1f 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserTest.java @@ -194,7 +194,8 @@ public void testDeserializationFromString01() throws Exception value = READER.readValue('"' + time.toString() + '"'); assertEquals(time, value, "The value is not correct."); - expectSuccess(OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC), "'12:00Z'"); + assertEquals(OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC), + read("'12:00Z'")); } @Test @@ -286,7 +287,7 @@ public void testDeserializationAsArrayEnabled() throws Throwable { OffsetTime value = READER.with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) .readValue(a2q("['12:00Z']")); - expect(OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC), value); + assertEquals(OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC), value); } @Test @@ -354,21 +355,7 @@ private void expectFailure(String json) throws Throwable { } } - private void expectSuccess(Object exp, String json) throws IOException { - final OffsetTime value = read(json); - assertNotNull(value, "The value should not be null."); - assertEquals(exp, value, "The value is not correct."); - } - private OffsetTime read(final String json) throws IOException { return READER.readValue(a2q(json)); } - - private static void notNull(Object value) { - assertNotNull(value, "The value should not be null."); - } - - private static void expect(Object exp, Object value) { - assertEquals(exp, value, "The value is not correct."); - } } From 6283ad19edc265a2ca8c1105895cf2e5d50428e4 Mon Sep 17 00:00:00 2001 From: Boleslav Bobcik Date: Sun, 30 Mar 2025 05:56:12 +0200 Subject: [PATCH 027/140] Fix #364: make one-based Month deserializer accept "12" (#365) --- .../deser/OneBasedMonthDeserializer.java | 53 ++++++++++++++----- .../jsr310/deser/OneBasedMonthDeserTest.java | 53 ++++++++++++------- 2 files changed, 74 insertions(+), 32 deletions(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java index ed626849..f1153459 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java @@ -2,7 +2,6 @@ import java.io.IOException; import java.time.Month; -import java.util.regex.Pattern; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; @@ -17,8 +16,6 @@ public class OneBasedMonthDeserializer extends DelegatingDeserializer { private static final long serialVersionUID = 1L; - private static final Pattern HAS_ONE_OR_TWO_DIGITS = Pattern.compile("^\\d{1,2}$"); - public OneBasedMonthDeserializer(JsonDeserializer defaultDeserializer) { super(defaultDeserializer); } @@ -26,22 +23,50 @@ public OneBasedMonthDeserializer(JsonDeserializer defaultDeserializer) { @Override public Object deserialize(JsonParser parser, DeserializationContext context) throws IOException { JsonToken token = parser.currentToken(); - Month zeroBaseMonth = (Month) getDelegatee().deserialize(parser, context); - if (!_isNumericValue(parser.getText(), token)) { - return zeroBaseMonth; - } - if (zeroBaseMonth == Month.JANUARY) { - throw new InvalidFormatException(parser, "Month.JANUARY value not allowed for 1-based Month.", zeroBaseMonth, Month.class); + switch (token) { + case VALUE_NUMBER_INT: + return _decodeMonth(parser.getIntValue(), parser); + case VALUE_STRING: + String monthSpec = parser.getText(); + int oneBasedMonthNumber = _decodeNumber(monthSpec); + if (oneBasedMonthNumber >= 0) { + return _decodeMonth(oneBasedMonthNumber, parser); + } + // Otherwise fall through to default handling + break; } - return zeroBaseMonth.minus(1); + return getDelegatee().deserialize(parser, context); } - private boolean _isNumericValue(String text, JsonToken token) { - return token == JsonToken.VALUE_NUMBER_INT || _isNumberAsString(text, token); + /** + * @return Numeric value of input text that represents a 1-digit or 2-digit number. + * Negative value in other cases (empty string, not a number, 3 or more digits). + */ + private int _decodeNumber(String text) { + int numValue; + switch (text.length()) { + case 1: + char c = text.charAt(0); + boolean cValid = ('0' <= c && c <= '9'); + numValue = cValid ? (c - '0') : -1; + break; + case 2: + char c1 = text.charAt(0); + char c2 = text.charAt(1); + boolean c12valid = ('0' <= c1 && c1 <= '9' && '0' <= c2 && c2 <= '9'); + numValue = c12valid ? (10 * (c1 - '0') + (c2 - '0')) : -1; + break; + default: + numValue = -1; + } + return numValue; } - private boolean _isNumberAsString(String text, JsonToken token) { - return token == JsonToken.VALUE_STRING && HAS_ONE_OR_TWO_DIGITS.matcher(text).matches(); + private Month _decodeMonth(int oneBasedMonthNumber, JsonParser parser) throws InvalidFormatException { + if (Month.JANUARY.getValue() <= oneBasedMonthNumber && oneBasedMonthNumber <= Month.DECEMBER.getValue()) { + return Month.of(oneBasedMonthNumber); + } + throw new InvalidFormatException(parser, "Month number " + oneBasedMonthNumber + " not allowed for 1-based Month.", oneBasedMonthNumber, Integer.class); } @Override diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java index 0e4d3eea..9377f5f4 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserTest.java @@ -17,6 +17,9 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.EnumSource; import static org.junit.jupiter.api.Assertions.*; @@ -29,37 +32,51 @@ static class Wrapper { public Wrapper() { } } - @Test - public void testDeserializationAsString01_oneBased() throws Exception + @ParameterizedTest + @EnumSource(Month.class) + public void testDeserializationAsString01_oneBased(Month expectedMonth) throws Exception { - assertEquals(Month.JANUARY, readerForOneBased().readValue("\"1\"")); + int monthNum = expectedMonth.getValue(); + assertEquals(expectedMonth, readerForOneBased().readValue("\"" + monthNum + '"')); } - @Test - public void testDeserializationAsString01_zeroBased() throws Exception + @ParameterizedTest + @EnumSource(Month.class) + public void testDeserializationAsString01_zeroBased(Month expectedMonth) throws Exception { - assertEquals(Month.FEBRUARY, readerForZeroBased().readValue("\"1\"")); + int monthNum = expectedMonth.ordinal(); + assertEquals(expectedMonth, readerForZeroBased().readValue("\"" + monthNum + '"')); } - @Test - public void testDeserializationAsString02_oneBased() throws Exception + @ParameterizedTest + @EnumSource(Month.class) + public void testDeserializationAsString02_oneBased(Month month) throws Exception { - assertEquals(Month.JANUARY, readerForOneBased().readValue("\"JANUARY\"")); + assertEquals(month, readerForOneBased().readValue("\"" + month.name() + '"')); } - @Test - public void testDeserializationAsString02_zeroBased() throws Exception + @ParameterizedTest + @EnumSource(Month.class) + public void testDeserializationAsString02_zeroBased(Month month) throws Exception { - assertEquals(Month.JANUARY, readerForZeroBased().readValue("\"JANUARY\"")); - } - - @Test - public void testBadDeserializationAsString01_oneBased() { + assertEquals(month, readerForOneBased().readValue("\"" + month.name() + '"')); + } + + @ParameterizedTest + @CsvSource({ + "notamonth , 'Cannot deserialize value of type `java.time.Month` from String \"notamonth\": not one of the values accepted for Enum class: [OCTOBER, SEPTEMBER, JUNE, MARCH, MAY, APRIL, JULY, JANUARY, FEBRUARY, DECEMBER, AUGUST, NOVEMBER]'", + "JANUAR , 'Cannot deserialize value of type `java.time.Month` from String \"JANUAR\": not one of the values accepted for Enum class: [OCTOBER, SEPTEMBER, JUNE, MARCH, MAY, APRIL, JULY, JANUARY, FEBRUARY, DECEMBER, AUGUST, NOVEMBER]'", + "march , 'Cannot deserialize value of type `java.time.Month` from String \"march\": not one of the values accepted for Enum class: [OCTOBER, SEPTEMBER, JUNE, MARCH, MAY, APRIL, JULY, JANUARY, FEBRUARY, DECEMBER, AUGUST, NOVEMBER]'", + "0 , 'Month number 0 not allowed for 1-based Month.'", + "13 , 'Month number 13 not allowed for 1-based Month.'", + }) + public void testBadDeserializationAsString01_oneBased(String monthSpec, String expectedMessage) { + String value = "\"" + monthSpec + '"'; assertError( - () -> readerForOneBased().readValue("\"notamonth\""), + () -> readerForOneBased().readValue(value), InvalidFormatException.class, - "Cannot deserialize value of type `java.time.Month` from String \"notamonth\": not one of the values accepted for Enum class: [OCTOBER, SEPTEMBER, JUNE, MARCH, MAY, APRIL, JULY, JANUARY, FEBRUARY, DECEMBER, AUGUST, NOVEMBER]" + expectedMessage ); } From 211989687f189c122ac641ae75dd45990dbb07fe Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 29 Mar 2025 20:58:53 -0700 Subject: [PATCH 028/140] Update release notes wrt #364 --- release-notes/CREDITS-2.x | 5 +++++ release-notes/VERSION-2.x | 2 ++ 2 files changed, 7 insertions(+) diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index e15888d1..39c41bf9 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -222,3 +222,8 @@ Joey Muia (@jmuia) Henning Pöttker (@ hpoettker) * Contributed #342: Lenient deserialization of `LocalDate` is not time-zone aware (2.19.0) + +Boleslav Bobcik (@bbobcik) + * Reported, contributed fix for #364: Deserialization of Month in ONE_BASED_MONTHS + mode fails for value "12" + (2.19.0) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 6500bc45..6255bc16 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -19,6 +19,8 @@ Modules: #342: Lenient deserialization of `LocalDate`, `LocalDateTime` is not time-zone aware (contributed by Henning P) +#364: Deserialization of Month in ONE_BASED_MONTHS mode fails for value "12" + (reported, fix contributed by Boleslav B) 2.18.4 (not yet released) From 7ef692016a5993e2f07d330b7969f74ae28cfb22 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 7 Apr 2025 15:09:34 -0700 Subject: [PATCH 029/140] Start converting master->3.x --- .github/workflows/dep_build_v3.yml | 2 +- .github/workflows/main.yml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dep_build_v3.yml b/.github/workflows/dep_build_v3.yml index 6da2dd55..8f56e555 100644 --- a/.github/workflows/dep_build_v3.yml +++ b/.github/workflows/dep_build_v3.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: - ref: master + ref: 3.x - name: Set up JDK uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a1c56135..9f90aef1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,16 +2,14 @@ name: Build and Deploy Snapshot on: push: branches: - - master - - "3.0" + - 3.x - "2.19" paths-ignore: - "README.md" - "release-notes/*" pull_request: branches: - - master - - "3.0" + - 3.x - "2.19" paths-ignore: - "README.md" @@ -66,5 +64,5 @@ jobs: uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 with: token: ${{ secrets.CODECOV_TOKEN }} - file: ./target/site/jacoco/jacoco.xml + files: ./target/site/jacoco/jacoco.xml flags: unittests From caebd3a1deb5a65e03b2e1cead52defc6d5a648c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 7 Apr 2025 18:49:25 -0700 Subject: [PATCH 030/140] Prep for 2.19.0-rc2 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- release-notes/VERSION-2.x | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index bfe9f6c6..2555a2f7 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-SNAPSHOT + 2.19.0-rc2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1e435ccd..04d635d8 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-SNAPSHOT + 2.19.0-rc2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index c3079739..4b9c3c4e 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-SNAPSHOT + 2.19.0-rc2-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index bbde1ef3..0c13a72d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.19.0-SNAPSHOT + 2.19.0-rc2 com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.0-SNAPSHOT + 2.19.0-rc2-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 6255bc16..54c645e2 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,7 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ -2.19.0 (not yet released) +2.19.0-rc2 (07-Apr-2025) #336: Optimize `InstantDeserializer` `addInColonToOffsetIfMissing()` (contributed by David S) From 8a5ab7b64fef049365f6c940e59a8682e03694a1 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 7 Apr 2025 18:51:33 -0700 Subject: [PATCH 031/140] [maven-release-plugin] prepare release jackson-modules-java8-2.19.0-rc2 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 2555a2f7..88165ddc 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-rc2-SNAPSHOT + 2.19.0-rc2 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 04d635d8..498ba2e0 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-rc2-SNAPSHOT + 2.19.0-rc2 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 4b9c3c4e..9b0485db 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-rc2-SNAPSHOT + 2.19.0-rc2 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 0c13a72d..049f6a9f 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.0-rc2-SNAPSHOT + 2.19.0-rc2 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.19.0-rc2 https://github.com/FasterXML/jackson-modules-java8/issues From 3b4e211d571192205805113c5f6601f7c16db2a5 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 7 Apr 2025 18:51:35 -0700 Subject: [PATCH 032/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 88165ddc..bfe9f6c6 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-rc2 + 2.19.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 498ba2e0..1e435ccd 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-rc2 + 2.19.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 9b0485db..c3079739 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-rc2 + 2.19.0-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 049f6a9f..66b67898 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.0-rc2 + 2.19.0-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.19.0-rc2 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 408130cd8c97b62902f943a76d7ff63bcc6950f8 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 7 Apr 2025 18:53:41 -0700 Subject: [PATCH 033/140] Back to snapshot dep --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 66b67898..bbde1ef3 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.0-rc2 + 2.19.0-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From ddc98a310d6c6950567a5a0a7395649a0fdf8dce Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 20 Apr 2025 14:52:52 -0700 Subject: [PATCH 034/140] Update wrt 3.0 embedding jsr-310 module --- README.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index dee05669..e552afd2 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,8 @@ all of which are built from this repository, and accessed and used as separate J Jackson 3.0 changes things as it requires Java 8 to work and can thereby directly supported features. -Because of this `parameter-names` and `datatypes` modules are merged into `jackson-databind` -and need not be registered; `datetime` module (`JavaTimeModule`) remains separate module due to its size -and configurability options. - -So you will only need to separately add "Java 8 Date/time" module (see above for description) +Because of this, all 3 modules are merged into `jackson-databind` +and need not be registered (as of Jacksson `3.0.0-rc3`) ## License @@ -36,7 +33,7 @@ All modules are licensed under [Apache License 2.0](http://www.apache.org/licens ## Status -[![Build Status](https://travis-ci.org/FasterXML/jackson-modules-java8.svg)](https://travis-ci.org/FasterXML/jackson-modules-java8) +[![Build status (github)](https://github.com/FasterXML/jackson-databind/actions/workflows/main.yml/badge.svg)](https://github.com/FasterXML/jackson-databind/actions/workflows/main.yml) [![Tidelift](https://tidelift.com/badges/package/maven/com.fasterxml.jackson.datatype:jackson-datatype-jsr310)](https://tidelift.com/subscription/pkg/maven-com-fasterxml-jackson-datatype-jackson-datatype-jsr310?utm_source=maven-com-fasterxml-jackson-datatype-jackson-datatype-jsr310&utm_medium=referral&utm_campaign=readme) ## Usage @@ -46,19 +43,19 @@ All modules are licensed under [Apache License 2.0](http://www.apache.org/licens To include modules, you use some or all of: ```xml - + com.fasterxml.jackson.module jackson-module-parameter-names - + com.fasterxml.jackson.datatype jackson-datatype-jsr310 - + com.fasterxml.jackson.datatype jackson-datatype-jdk8 From 3a7af077dcf0732744f16706e71ee9bab79d5b41 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 24 Apr 2025 17:34:37 -0700 Subject: [PATCH 035/140] Prep for 2.19.0 --- pom.xml | 2 +- release-notes/VERSION-2.x | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index bbde1ef3..9328f7fb 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.0-SNAPSHOT + 2.19.0 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 54c645e2..d6bc430e 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,7 +8,11 @@ Modules: === Releases === ------------------------------------------------------------------------ -2.19.0-rc2 (07-Apr-2025) +2.20.0 (not yet released) + +- + +2.19.0 (24-Apr-2025) #336: Optimize `InstantDeserializer` `addInColonToOffsetIfMissing()` (contributed by David S) From acbf02e3aec09ff75671b3ffc01e26bba3bfa061 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 24 Apr 2025 17:42:14 -0700 Subject: [PATCH 036/140] [maven-release-plugin] prepare release jackson-modules-java8-2.19.0 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index bfe9f6c6..18ba33a2 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-SNAPSHOT + 2.19.0 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1e435ccd..03a14f21 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-SNAPSHOT + 2.19.0 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index c3079739..386103c8 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0-SNAPSHOT + 2.19.0 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 9328f7fb..076aae71 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.0-SNAPSHOT + 2.19.0 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.19.0 https://github.com/FasterXML/jackson-modules-java8/issues From 2557c1486531a03c4e2b4b23787535e2512e5c86 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 24 Apr 2025 17:42:17 -0700 Subject: [PATCH 037/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 18ba33a2..2f98b588 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0 + 2.19.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 03a14f21..564c7fa9 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0 + 2.19.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 386103c8..e13d0c7f 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.0 + 2.19.1-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 076aae71..a7a59a76 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.0 + 2.19.1-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.19.0 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From cf208e5287eaee35136dfcf8a220e8a7e8a0b80b Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 24 Apr 2025 17:45:19 -0700 Subject: [PATCH 038/140] Back to snapshot dep --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a7a59a76..7957d597 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.0 + 2.19.1-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From ca9c2a8d6adf94c0fb47f6beb6409ce47360d3ee Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 24 Apr 2025 17:49:03 -0700 Subject: [PATCH 039/140] Start 2.x branch for 2.20 --- .github/workflows/dep_build_v2.yml | 4 +++- .github/workflows/main.yml | 10 +++------- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dep_build_v2.yml b/.github/workflows/dep_build_v2.yml index 626cb550..f80d3222 100644 --- a/.github/workflows/dep_build_v2.yml +++ b/.github/workflows/dep_build_v2.yml @@ -10,7 +10,7 @@ permissions: jobs: build: - runs-on: 'ubuntu-22.04' + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -19,6 +19,8 @@ jobs: JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + ref: 2.x - name: Set up JDK uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f90aef1..7523e38c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,16 +1,12 @@ name: Build and Deploy Snapshot on: push: - branches: - - 3.x - - "2.19" + branches: [2.*] paths-ignore: - "README.md" - "release-notes/*" pull_request: - branches: - - 3.x - - "2.19" + branches: [2.*] paths-ignore: - "README.md" - "release-notes/*" @@ -20,7 +16,7 @@ permissions: jobs: build: - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-24.04' strategy: fail-fast: false matrix: diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 2f98b588..bb80b5be 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1-SNAPSHOT + 2.20.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 564c7fa9..be9b1e79 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1-SNAPSHOT + 2.20.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index e13d0c7f..96646efe 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1-SNAPSHOT + 2.20.0-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 7957d597..d95f4272 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.19.1-SNAPSHOT + 2.20.0-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.1-SNAPSHOT + 2.20.0-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types From 239a8db46cf3ebd44cf49675ed528f20d312b964 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 25 Apr 2025 20:59:05 -0700 Subject: [PATCH 040/140] Fix compilation issue --- .../com/fasterxml/jackson/datatype/jsr310/JSR310Module.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JSR310Module.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JSR310Module.java index a8b7e68a..d12cc119 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JSR310Module.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JSR310Module.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.deser.ValueInstantiators; import com.fasterxml.jackson.databind.deser.std.StdValueInstantiator; import com.fasterxml.jackson.databind.introspect.AnnotatedClass; +import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver; import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; @@ -184,7 +185,8 @@ public ValueInstantiator findValueInstantiator(DeserializationConfig config, } else { // we don't need Annotations, so constructing directly is fine here // even if it's not generally recommended - ac = AnnotatedClass.construct(config.constructType(ZoneId.class), config); + ac = AnnotatedClassResolver.resolve(config, + config.constructType(ZoneId.class), config); } if (!inst.canCreateFromString()) { AnnotatedMethod factory = _findFactory(ac, "of", String.class); From d2fa9d81582a049e2cf3911a1289f0f67facb27d Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 28 Apr 2025 12:02:20 -0700 Subject: [PATCH 041/140] Minor cleanup of CI defs --- .github/workflows/main.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f90aef1..7523e38c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,16 +1,12 @@ name: Build and Deploy Snapshot on: push: - branches: - - 3.x - - "2.19" + branches: [2.*] paths-ignore: - "README.md" - "release-notes/*" pull_request: - branches: - - 3.x - - "2.19" + branches: [2.*] paths-ignore: - "README.md" - "release-notes/*" @@ -20,7 +16,7 @@ permissions: jobs: build: - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-24.04' strategy: fail-fast: false matrix: From a5c0f69b9a5f08a4ed58882635d95f22fe831190 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 30 Apr 2025 20:26:26 -0700 Subject: [PATCH 042/140] JSTEP-14: add SBOM generation (#368) --- datatypes/pom.xml | 11 +++++------ datetime/pom.xml | 12 +++++------- parameter-names/pom.xml | 14 ++++---------- pom.xml | 19 +++++++++---------- 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index bb80b5be..63b4f4ae 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -40,12 +40,11 @@ JDK 8 data types. com.google.code.maven-replacer-plugin replacer - - - process-packageVersion - generate-sources - - + + + + org.cyclonedx + cyclonedx-maven-plugin com.google.code.maven-replacer-plugin replacer - - - process-packageVersion - generate-sources - - + + + + org.cyclonedx + cyclonedx-maven-plugin org.apache.maven.plugins maven-compiler-plugin - 3.0 true ${javac.src.version} diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 96646efe..4cd3fc7d 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -84,17 +84,11 @@ introspection of method/constructor parameter names, without having to add expli com.google.code.maven-replacer-plugin replacer - - - process-packageVersion - generate-sources - - - - org.apache.maven.plugins - maven-surefire-plugin - ${version.plugin.surefire} + + + org.cyclonedx + cyclonedx-maven-plugin - com.google.code.maven-replacer-plugin - replacer - + + + com.google.code.maven-replacer-plugin + replacer + process-packageVersion generate-sources - - - - + + + org.apache.maven.plugins maven-surefire-plugin - + From 60eea52a4266f3d2823bd2eddbd3f2f71461e37b Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Tue, 6 May 2025 10:41:25 +0900 Subject: [PATCH 043/140] Test dataformat-joda#92 (#369) --- .../jsr310/ser/ZonedDateTimeSerTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java index aaca9ff6..614d9089 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerTest.java @@ -975,6 +975,30 @@ public void testShapeInt() throws JsonProcessingException { assertEquals("{\"t1\":1651053600000,\"t2\":1651053600.000000000}", json1); } + // [dataformat-joda#92] DateTime serialization result is not same as Java 8 ZonedDateTime + @Test + public void testSerializationWithZoneWithDefaultTimeZone() throws Exception + { + ZonedDateTime java8ZonedDateTime = ZonedDateTime.of(2023, 10, 1, 12, 0, 0, 0, + ZoneId.of("Asia/Shanghai")); + + // Without WRITE_DATES_WITH_CONTEXT_TIME_ZONE + assertEquals("\"2023-10-01T12:00:00+08:00\"", + MAPPER.writer() + .with(TimeZone.getTimeZone("UTC")) + .without(SerializationFeature.WRITE_DATES_WITH_CONTEXT_TIME_ZONE) + .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .writeValueAsString(java8ZonedDateTime)); + + // With WRITE_DATES_WITH_CONTEXT_TIME_ZONE + assertEquals("\"2023-10-01T04:00:00Z\"", + MAPPER.writer() + .with(TimeZone.getTimeZone("UTC")) + .with(SerializationFeature.WRITE_DATES_WITH_CONTEXT_TIME_ZONE) + .without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .writeValueAsString(java8ZonedDateTime)); + } + private static void assertIsEqual(ZonedDateTime expected, ZonedDateTime actual) { assertTrue(expected.isEqual(actual), From 3b021b8bc814e5fdc3182fee0b7eacc30a57c810 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 5 May 2025 18:47:53 -0700 Subject: [PATCH 044/140] Warnings removal for tests --- .../paramnames/CreatorWithNamingStrategy74Test.java | 6 +++--- .../module/paramnames/DelegatingCreatorTest.java | 12 ++++++------ .../jackson/module/paramnames/JsonCreatorTest.java | 2 +- .../module/paramnames/NamingStrategy67Test.java | 4 ++-- .../jackson/module/paramnames/PersonTest.java | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java index 3c264048..cb9aa78c 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/CreatorWithNamingStrategy74Test.java @@ -2,12 +2,12 @@ import org.junit.jupiter.api.Test; -import static org.assertj.core.api.BDDAssertions.then; - import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; +import static org.assertj.core.api.BDDAssertions.then; + // for [java8-modules#74] public class CreatorWithNamingStrategy74Test extends ModuleTestBase @@ -43,6 +43,6 @@ private void verifyObjectDeserializationWithNamingStrategy( // when Object actual = objectMapper.readValue(json, expected.getClass()); - then(actual).isEqualToComparingFieldByField(expected); + then(actual).usingRecursiveComparison().isEqualTo(expected); } } diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java index 9b68acc1..ce40dce2 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/DelegatingCreatorTest.java @@ -1,14 +1,14 @@ package com.fasterxml.jackson.module.paramnames; +import java.io.*; +import java.util.*; + import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.type.*; import com.fasterxml.jackson.databind.*; -import java.io.*; -import java.util.*; - import static org.assertj.core.api.BDDAssertions.*; public class DelegatingCreatorTest extends ModuleTestBase @@ -68,7 +68,7 @@ public void shouldNotOverrideJsonCreatorAnnotationWithSpecifiedMode() throws IOE Map props = new HashMap<>(); props.put("value", "aValue"); ClassWithDelegatingCreator expected = new ClassWithDelegatingCreator(props); - then(actual).isEqualToComparingFieldByField(expected); + then(actual).usingRecursiveComparison().isEqualTo(expected); } @Test @@ -77,7 +77,7 @@ public void shouldDeserializeIntWrapper() throws Exception { IntWrapper actual = mapper.readValue ("{\"value\":13}", IntWrapper.class); - then(actual).isEqualToComparingFieldByField(new IntWrapper(13)); + then(actual).usingRecursiveComparison().isEqualTo(new IntWrapper(13)); } @Test @@ -86,6 +86,6 @@ public void shouldDeserializeGenericWrapper() throws Exception { GenericWrapper actual = mapper.readValue ("{\"value\":\"aValue\"}", new TypeReference>() { }); - then(actual).isEqualToComparingFieldByField(new GenericWrapper<>("aValue")); + then(actual).usingRecursiveComparison().isEqualTo(new GenericWrapper<>("aValue")); } } diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java index 23b94e7e..43413b9d 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/JsonCreatorTest.java @@ -61,7 +61,7 @@ public void testJsonCreatorOnStaticMethod() throws Exception String json = a2q("{'first':'1st','second':'2nd'}"); ClassWithJsonCreatorOnStaticMethod actual = MAPPER.readValue(json, ClassWithJsonCreatorOnStaticMethod.class); - then(actual).isEqualToComparingFieldByField(new ClassWithJsonCreatorOnStaticMethod("1st", "2nd")); + then(actual).usingRecursiveComparison().isEqualTo(new ClassWithJsonCreatorOnStaticMethod("1st", "2nd")); } // [modules-base#178] diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java index c9bcc778..330707dc 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/NamingStrategy67Test.java @@ -43,7 +43,7 @@ public void testSnakeCaseNaming() throws Exception "{\"first_property\":\""+MSG+"\"}", // "{\"firstProperty\":\""+MSG+"\"}", ClassWithOneProperty.class); - then(actual).isEqualToComparingFieldByField(new ClassWithOneProperty(MSG)); + then(actual).usingRecursiveComparison().isEqualTo(new ClassWithOneProperty(MSG)); } @Test @@ -54,6 +54,6 @@ public void testPrivateConstructorWithPropertyAnnotations() throws Exception ClassWithTwoProperties actual = mapper.readValue("{\"a\":1, \"b\": 2}", ClassWithTwoProperties.class); - then(actual).isEqualToComparingFieldByField(new ClassWithTwoProperties(1, 2)); + then(actual).usingRecursiveComparison().isEqualTo(new ClassWithTwoProperties(1, 2)); } } diff --git a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java index 1e0198fd..58f45e20 100644 --- a/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java +++ b/parameter-names/src/test/java/com/fasterxml/jackson/module/paramnames/PersonTest.java @@ -22,7 +22,7 @@ public void shouldBeAbleToDeserializePerson() throws IOException // then Person expected = new Person("joe", "smith"); expected.setNickname("joey"); - then(actual).isEqualToComparingFieldByField(expected); + then(actual).usingRecursiveComparison().isEqualTo(expected); } } From 63c7b8e55c02ce3101d255de48b80dcf895246e6 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 17 May 2025 20:41:47 -0700 Subject: [PATCH 045/140] Sync with databind#4656 changes (#370) --- .../jsr310/deser/DurationDeserializer.java | 13 ++-- .../jsr310/deser/InstantDeserializer.java | 12 ++-- .../JSR310StringParsableDeserializer.java | 14 ++-- .../jsr310/deser/LocalDateDeserializer.java | 58 ++++++++------- .../deser/LocalDateTimeDeserializer.java | 64 +++++++++-------- .../jsr310/deser/LocalTimeDeserializer.java | 60 ++++++++-------- .../jsr310/deser/MonthDayDeserializer.java | 52 +++++++------- .../jsr310/deser/OffsetTimeDeserializer.java | 72 ++++++++++--------- .../deser/OneBasedMonthDeserializer.java | 30 ++++---- .../jsr310/deser/YearDeserializer.java | 31 ++++---- .../jsr310/deser/YearMonthDeserializer.java | 52 +++++++------- 11 files changed, 244 insertions(+), 214 deletions(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserializer.java index 2a7945e8..79a1fc25 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserializer.java @@ -162,17 +162,20 @@ public Duration deserialize(JsonParser parser, DeserializationContext context) t return _fromTimestamp(context, parser.getLongValue()); case JsonTokenId.ID_STRING: return _fromString(parser, context, parser.getText()); - // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - case JsonTokenId.ID_START_OBJECT: - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); case JsonTokenId.ID_EMBEDDED_OBJECT: // 20-Apr-2016, tatu: Related to [databind#1208], can try supporting embedded // values quite easily return (Duration) parser.getEmbeddedObject(); - case JsonTokenId.ID_START_ARRAY: return _deserializeFromArray(parser, context); + // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) + case JsonTokenId.ID_START_OBJECT: + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = context.extractScalarFromObject(parser, this, handledType()); + if (str != null) { + return _fromString(parser, context, str); + } + // fall through } return _handleUnexpectedToken(context, parser, JsonToken.VALUE_STRING, JsonToken.VALUE_NUMBER_INT, JsonToken.VALUE_NUMBER_FLOAT); diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java index 4f406931..0e1bf808 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java @@ -355,10 +355,6 @@ public T deserialize(JsonParser parser, DeserializationContext context) throws I return _fromLong(context, parser.getLongValue()); case JsonTokenId.ID_STRING: return _fromString(parser, context, parser.getText()); - // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - case JsonTokenId.ID_START_OBJECT: - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); case JsonTokenId.ID_EMBEDDED_OBJECT: // 20-Apr-2016, tatu: Related to [databind#1208], can try supporting embedded // values quite easily @@ -366,6 +362,14 @@ public T deserialize(JsonParser parser, DeserializationContext context) throws I case JsonTokenId.ID_START_ARRAY: return _deserializeFromArray(parser, context); + // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) + case JsonTokenId.ID_START_OBJECT: + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = context.extractScalarFromObject(parser, this, handledType()); + if (str != null) { + return _fromString(parser, context, str); + } + // fall through } return _handleUnexpectedToken(context, parser, JsonToken.VALUE_STRING, JsonToken.VALUE_NUMBER_INT, JsonToken.VALUE_NUMBER_FLOAT); diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310StringParsableDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310StringParsableDeserializer.java index 5cb8e465..96596a34 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310StringParsableDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310StringParsableDeserializer.java @@ -122,15 +122,17 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) if (p.isExpectedStartObjectToken()) { - return _fromString(p, ctxt, - ctxt.extractScalarFromObject(p, this, handledType())); - } - if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + // fall through + } else if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { // 20-Apr-2016, tatu: Related to [databind#1208], can try supporting embedded // values quite easily return p.getEmbeddedObject(); - } - if (p.isExpectedStartArrayToken()) { + } else if (p.isExpectedStartArrayToken()) { return _deserializeFromArray(p, ctxt); } diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserializer.java index 4a19d89b..5775a1d4 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserializer.java @@ -125,61 +125,65 @@ public LocalDateDeserializer withFeatures(JacksonFeatureSet fea } @Override - public LocalDate deserialize(JsonParser parser, DeserializationContext context) throws IOException + public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - if (parser.hasToken(JsonToken.VALUE_STRING)) { - return _fromString(parser, context, parser.getText()); + if (p.hasToken(JsonToken.VALUE_STRING)) { + return _fromString(p, ctxt, p.getText()); } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - if (parser.isExpectedStartObjectToken()) { - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); + if (p.isExpectedStartObjectToken()) { + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + return _handleUnexpectedToken(ctxt, p, "Expected array or string"); } - if (parser.isExpectedStartArrayToken()) { - JsonToken t = parser.nextToken(); + if (p.isExpectedStartArrayToken()) { + JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY) { return null; } - if (context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) + if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) && (t == JsonToken.VALUE_STRING || t==JsonToken.VALUE_EMBEDDED_OBJECT)) { - final LocalDate parsed = deserialize(parser, context); - if (parser.nextToken() != JsonToken.END_ARRAY) { - handleMissingEndArrayForSingle(parser, context); + final LocalDate parsed = deserialize(p, ctxt); + if (p.nextToken() != JsonToken.END_ARRAY) { + handleMissingEndArrayForSingle(p, ctxt); } return parsed; } if (t == JsonToken.VALUE_NUMBER_INT) { - int year = parser.getIntValue(); - int month = parser.nextIntValue(-1); - int day = parser.nextIntValue(-1); + int year = p.getIntValue(); + int month = p.nextIntValue(-1); + int day = p.nextIntValue(-1); - if (parser.nextToken() != JsonToken.END_ARRAY) { - throw context.wrongTokenException(parser, handledType(), JsonToken.END_ARRAY, + if (p.nextToken() != JsonToken.END_ARRAY) { + throw ctxt.wrongTokenException(p, handledType(), JsonToken.END_ARRAY, "Expected array to end"); } return LocalDate.of(year, month, day); } - context.reportInputMismatch(handledType(), + ctxt.reportInputMismatch(handledType(), "Unexpected token (%s) within Array, expected VALUE_NUMBER_INT", t); } - if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { - return (LocalDate) parser.getEmbeddedObject(); + if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + return (LocalDate) p.getEmbeddedObject(); } // 06-Jan-2018, tatu: Is this actually safe? Do users expect such coercion? - if (parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { - CoercionAction act = context.findCoercionAction(logicalType(), _valueClass, + if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { + CoercionAction act = ctxt.findCoercionAction(logicalType(), _valueClass, CoercionInputShape.Integer); - _checkCoercionFail(context, act, handledType(), parser.getLongValue(), - "Integer value (" + parser.getLongValue() + ")"); + _checkCoercionFail(ctxt, act, handledType(), p.getLongValue(), + "Integer value (" + p.getLongValue() + ")"); // issue 58 - also check for NUMBER_INT, which needs to be specified when serializing. if (_shape == JsonFormat.Shape.NUMBER_INT || isLenient()) { - return LocalDate.ofEpochDay(parser.getLongValue()); + return LocalDate.ofEpochDay(p.getLongValue()); } - return _failForNotLenient(parser, context, JsonToken.VALUE_STRING); + return _failForNotLenient(p, ctxt, JsonToken.VALUE_STRING); } - return _handleUnexpectedToken(context, parser, "Expected array or string."); + return _handleUnexpectedToken(ctxt, p, "Expected array or string"); } protected LocalDate _fromString(JsonParser p, DeserializationContext ctxt, diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java index 7c88f8cb..c76fdb0d 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java @@ -148,52 +148,56 @@ public LocalDateTimeDeserializer withFeatures(JacksonFeatureSet } @Override - public LocalDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException + public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - if (parser.hasTokenId(JsonTokenId.ID_STRING)) { - return _fromString(parser, context, parser.getText()); + if (p.hasTokenId(JsonTokenId.ID_STRING)) { + return _fromString(p, ctxt, p.getText()); } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - if (parser.isExpectedStartObjectToken()) { - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); + if (p.isExpectedStartObjectToken()) { + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + return _handleUnexpectedToken(ctxt, p, "Expected array or string"); } - if (parser.isExpectedStartArrayToken()) { - JsonToken t = parser.nextToken(); + if (p.isExpectedStartArrayToken()) { + JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY) { return null; } if ((t == JsonToken.VALUE_STRING || t == JsonToken.VALUE_EMBEDDED_OBJECT) - && context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { - final LocalDateTime parsed = deserialize(parser, context); - if (parser.nextToken() != JsonToken.END_ARRAY) { - handleMissingEndArrayForSingle(parser, context); + && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { + final LocalDateTime parsed = deserialize(p, ctxt); + if (p.nextToken() != JsonToken.END_ARRAY) { + handleMissingEndArrayForSingle(p, ctxt); } return parsed; } if (t == JsonToken.VALUE_NUMBER_INT) { LocalDateTime result; - int year = parser.getIntValue(); - int month = parser.nextIntValue(-1); - int day = parser.nextIntValue(-1); - int hour = parser.nextIntValue(-1); - int minute = parser.nextIntValue(-1); + int year = p.getIntValue(); + int month = p.nextIntValue(-1); + int day = p.nextIntValue(-1); + int hour = p.nextIntValue(-1); + int minute = p.nextIntValue(-1); - t = parser.nextToken(); + t = p.nextToken(); if (t == JsonToken.END_ARRAY) { result = LocalDateTime.of(year, month, day, hour, minute); } else { - int second = parser.getIntValue(); - t = parser.nextToken(); + int second = p.getIntValue(); + t = p.nextToken(); if (t == JsonToken.END_ARRAY) { result = LocalDateTime.of(year, month, day, hour, minute, second); } else { - int partialSecond = parser.getIntValue(); - if (partialSecond < 1_000 && !shouldReadTimestampsAsNanoseconds(context)) + int partialSecond = p.getIntValue(); + if (partialSecond < 1_000 && !shouldReadTimestampsAsNanoseconds(ctxt)) partialSecond *= 1_000_000; // value is milliseconds, convert it to nanoseconds - if (parser.nextToken() != JsonToken.END_ARRAY) { - throw context.wrongTokenException(parser, handledType(), JsonToken.END_ARRAY, + if (p.nextToken() != JsonToken.END_ARRAY) { + throw ctxt.wrongTokenException(p, handledType(), JsonToken.END_ARRAY, "Expected array to end"); } result = LocalDateTime.of(year, month, day, hour, minute, second, partialSecond); @@ -201,17 +205,17 @@ public LocalDateTime deserialize(JsonParser parser, DeserializationContext conte } return result; } - context.reportInputMismatch(handledType(), + ctxt.reportInputMismatch(handledType(), "Unexpected token (%s) within Array, expected VALUE_NUMBER_INT", t); } - if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { - return (LocalDateTime) parser.getEmbeddedObject(); + if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + return (LocalDateTime) p.getEmbeddedObject(); } - if (parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { - _throwNoNumericTimestampNeedTimeZone(parser, context); + if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { + _throwNoNumericTimestampNeedTimeZone(p, ctxt); } - return _handleUnexpectedToken(context, parser, "Expected array or string."); + return _handleUnexpectedToken(ctxt, p, "Expected array or string"); } protected boolean shouldReadTimestampsAsNanoseconds(DeserializationContext context) { diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserializer.java index da860cf3..f023be9a 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalTimeDeserializer.java @@ -103,51 +103,55 @@ protected JSR310DateTimeDeserializerBase _withFormatOverrides(Deserialization } @Override - public LocalTime deserialize(JsonParser parser, DeserializationContext context) throws IOException + public LocalTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - if (parser.hasToken(JsonToken.VALUE_STRING)) { - return _fromString(parser, context, parser.getText()); + if (p.hasToken(JsonToken.VALUE_STRING)) { + return _fromString(p, ctxt, p.getText()); } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - if (parser.isExpectedStartObjectToken()) { - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); + if (p.isExpectedStartObjectToken()) { + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + return _handleUnexpectedToken(ctxt, p, "Expected array or string"); } - if (parser.isExpectedStartArrayToken()) { - JsonToken t = parser.nextToken(); + if (p.isExpectedStartArrayToken()) { + JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY) { return null; } - if (context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) + if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) && (t == JsonToken.VALUE_STRING || t==JsonToken.VALUE_EMBEDDED_OBJECT)) { - final LocalTime parsed = deserialize(parser, context); - if (parser.nextToken() != JsonToken.END_ARRAY) { - handleMissingEndArrayForSingle(parser, context); + final LocalTime parsed = deserialize(p, ctxt); + if (p.nextToken() != JsonToken.END_ARRAY) { + handleMissingEndArrayForSingle(p, ctxt); } return parsed; } if (t == JsonToken.VALUE_NUMBER_INT) { - int hour = parser.getIntValue(); + int hour = p.getIntValue(); - parser.nextToken(); - int minute = parser.getIntValue(); + p.nextToken(); + int minute = p.getIntValue(); LocalTime result; - t = parser.nextToken(); + t = p.nextToken(); if (t == JsonToken.END_ARRAY) { result = LocalTime.of(hour, minute); } else { - int second = parser.getIntValue(); - t = parser.nextToken(); + int second = p.getIntValue(); + t = p.nextToken(); if (t == JsonToken.END_ARRAY) { result = LocalTime.of(hour, minute, second); } else { - int partialSecond = parser.getIntValue(); - if(partialSecond < 1_000 && !shouldReadTimestampsAsNanoseconds(context)) + int partialSecond = p.getIntValue(); + if(partialSecond < 1_000 && !shouldReadTimestampsAsNanoseconds(ctxt)) partialSecond *= 1_000_000; // value is milliseconds, convert it to nanoseconds - t = parser.nextToken(); + t = p.nextToken(); if (t != JsonToken.END_ARRAY) { - throw context.wrongTokenException(parser, handledType(), JsonToken.END_ARRAY, + throw ctxt.wrongTokenException(p, handledType(), JsonToken.END_ARRAY, "Expected array to end"); } result = LocalTime.of(hour, minute, second, partialSecond); @@ -155,17 +159,17 @@ public LocalTime deserialize(JsonParser parser, DeserializationContext context) } return result; } - context.reportInputMismatch(handledType(), + ctxt.reportInputMismatch(handledType(), "Unexpected token (%s) within Array, expected VALUE_NUMBER_INT", t); } - if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { - return (LocalTime) parser.getEmbeddedObject(); + if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + return (LocalTime) p.getEmbeddedObject(); } - if (parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { - _throwNoNumericTimestampNeedTimeZone(parser, context); + if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { + _throwNoNumericTimestampNeedTimeZone(p, ctxt); } - return _handleUnexpectedToken(context, parser, "Expected array or string."); + return _handleUnexpectedToken(ctxt, p, "Expected array or string"); } protected boolean shouldReadTimestampsAsNanoseconds(DeserializationContext context) { diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserializer.java index 449cf718..88d71697 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/MonthDayDeserializer.java @@ -62,50 +62,52 @@ protected MonthDayDeserializer withDateFormat(DateTimeFormatter dtf) { } @Override - public MonthDay deserialize(JsonParser parser, DeserializationContext context) throws IOException + public MonthDay deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - if (parser.hasToken(JsonToken.VALUE_STRING)) { - return _fromString(parser, context, parser.getText()); + if (p.hasToken(JsonToken.VALUE_STRING)) { + return _fromString(p, ctxt, p.getText()); } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - if (parser.isExpectedStartObjectToken()) { - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); - } - if (parser.isExpectedStartArrayToken()) { - JsonToken t = parser.nextToken(); + if (p.isExpectedStartObjectToken()) { + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + // fall through + } else if (p.isExpectedStartArrayToken()) { + JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY) { return null; } if ((t == JsonToken.VALUE_STRING || t == JsonToken.VALUE_EMBEDDED_OBJECT) - && context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { - final MonthDay parsed = deserialize(parser, context); - if (parser.nextToken() != JsonToken.END_ARRAY) { - handleMissingEndArrayForSingle(parser, context); + && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { + final MonthDay parsed = deserialize(p, ctxt); + if (p.nextToken() != JsonToken.END_ARRAY) { + handleMissingEndArrayForSingle(p, ctxt); } return parsed; } if (t != JsonToken.VALUE_NUMBER_INT) { - _reportWrongToken(context, JsonToken.VALUE_NUMBER_INT, "month"); + _reportWrongToken(ctxt, JsonToken.VALUE_NUMBER_INT, "month"); } - int month = parser.getIntValue(); - int day = parser.nextIntValue(-1); + int month = p.getIntValue(); + int day = p.nextIntValue(-1); if (day == -1) { - if (!parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { - _reportWrongToken(context, JsonToken.VALUE_NUMBER_INT, "day"); + if (!p.hasToken(JsonToken.VALUE_NUMBER_INT)) { + _reportWrongToken(ctxt, JsonToken.VALUE_NUMBER_INT, "day"); } - day = parser.getIntValue(); + day = p.getIntValue(); } - if (parser.nextToken() != JsonToken.END_ARRAY) { - throw context.wrongTokenException(parser, handledType(), JsonToken.END_ARRAY, + if (p.nextToken() != JsonToken.END_ARRAY) { + throw ctxt.wrongTokenException(p, handledType(), JsonToken.END_ARRAY, "Expected array to end"); } return MonthDay.of(month, day); + } else if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + return (MonthDay) p.getEmbeddedObject(); } - if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { - return (MonthDay) parser.getEmbeddedObject(); - } - return _handleUnexpectedToken(context, parser, + return _handleUnexpectedToken(ctxt, p, JsonToken.VALUE_STRING, JsonToken.START_ARRAY); } diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserializer.java index 8331af7f..0a23ac39 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetTimeDeserializer.java @@ -99,75 +99,79 @@ protected JSR310DateTimeDeserializerBase _withFormatOverrides(Deserialization } @Override - public OffsetTime deserialize(JsonParser parser, DeserializationContext context) throws IOException + public OffsetTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - if (parser.hasToken(JsonToken.VALUE_STRING)) { - return _fromString(parser, context, parser.getText()); + if (p.hasToken(JsonToken.VALUE_STRING)) { + return _fromString(p, ctxt, p.getText()); } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - if (parser.isExpectedStartObjectToken()) { - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); + if (p.isExpectedStartObjectToken()) { + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + // fall through } - if (!parser.isExpectedStartArrayToken()) { - if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { - return (OffsetTime) parser.getEmbeddedObject(); + if (!p.isExpectedStartArrayToken()) { + if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + return (OffsetTime) p.getEmbeddedObject(); } - if (parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { - _throwNoNumericTimestampNeedTimeZone(parser, context); + if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { + _throwNoNumericTimestampNeedTimeZone(p, ctxt); } - throw context.wrongTokenException(parser, handledType(), JsonToken.START_ARRAY, + throw ctxt.wrongTokenException(p, handledType(), JsonToken.START_ARRAY, "Expected array or string."); } - JsonToken t = parser.nextToken(); + JsonToken t = p.nextToken(); if (t != JsonToken.VALUE_NUMBER_INT) { if (t == JsonToken.END_ARRAY) { return null; } if ((t == JsonToken.VALUE_STRING || t == JsonToken.VALUE_EMBEDDED_OBJECT) - && context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { - final OffsetTime parsed = deserialize(parser, context); - if (parser.nextToken() != JsonToken.END_ARRAY) { - handleMissingEndArrayForSingle(parser, context); + && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { + final OffsetTime parsed = deserialize(p, ctxt); + if (p.nextToken() != JsonToken.END_ARRAY) { + handleMissingEndArrayForSingle(p, ctxt); } return parsed; } - context.reportInputMismatch(handledType(), + ctxt.reportInputMismatch(handledType(), "Unexpected token (%s) within Array, expected VALUE_NUMBER_INT", t); } - int hour = parser.getIntValue(); - int minute = parser.nextIntValue(-1); + int hour = p.getIntValue(); + int minute = p.nextIntValue(-1); if (minute == -1) { - t = parser.getCurrentToken(); + t = p.getCurrentToken(); if (t == JsonToken.END_ARRAY) { return null; } if (t != JsonToken.VALUE_NUMBER_INT) { - _reportWrongToken(context, JsonToken.VALUE_NUMBER_INT, "minutes"); + _reportWrongToken(ctxt, JsonToken.VALUE_NUMBER_INT, "minutes"); } - minute = parser.getIntValue(); + minute = p.getIntValue(); } int partialSecond = 0; int second = 0; - if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) { - second = parser.getIntValue(); - if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) { - partialSecond = parser.getIntValue(); - if (partialSecond < 1_000 && !shouldReadTimestampsAsNanoseconds(context)) { + if (p.nextToken() == JsonToken.VALUE_NUMBER_INT) { + second = p.getIntValue(); + if (p.nextToken() == JsonToken.VALUE_NUMBER_INT) { + partialSecond = p.getIntValue(); + if (partialSecond < 1_000 && !shouldReadTimestampsAsNanoseconds(ctxt)) { partialSecond *= 1_000_000; // value is milliseconds, convert it to nanoseconds } - parser.nextToken(); + p.nextToken(); } } - if (parser.getCurrentToken() == JsonToken.VALUE_STRING) { - OffsetTime result = OffsetTime.of(hour, minute, second, partialSecond, ZoneOffset.of(parser.getText())); - if (parser.nextToken() != JsonToken.END_ARRAY) { - _reportWrongToken(context, JsonToken.END_ARRAY, "timezone"); + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + OffsetTime result = OffsetTime.of(hour, minute, second, partialSecond, ZoneOffset.of(p.getText())); + if (p.nextToken() != JsonToken.END_ARRAY) { + _reportWrongToken(ctxt, JsonToken.END_ARRAY, "timezone"); } return result; } - throw context.wrongTokenException(parser, handledType(), JsonToken.VALUE_STRING, + throw ctxt.wrongTokenException(p, handledType(), JsonToken.VALUE_STRING, "Expected string for TimeZone after numeric values"); } diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java index f1153459..d6b71680 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/OneBasedMonthDeserializer.java @@ -4,7 +4,7 @@ import java.time.Month; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; + import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.deser.std.DelegatingDeserializer; @@ -21,21 +21,21 @@ public OneBasedMonthDeserializer(JsonDeserializer defaultDeserializer) { } @Override - public Object deserialize(JsonParser parser, DeserializationContext context) throws IOException { - JsonToken token = parser.currentToken(); - switch (token) { - case VALUE_NUMBER_INT: - return _decodeMonth(parser.getIntValue(), parser); - case VALUE_STRING: - String monthSpec = parser.getText(); - int oneBasedMonthNumber = _decodeNumber(monthSpec); - if (oneBasedMonthNumber >= 0) { - return _decodeMonth(oneBasedMonthNumber, parser); - } - // Otherwise fall through to default handling - break; + public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + switch (p.currentToken()) { + case VALUE_NUMBER_INT: + return _decodeMonth(p.getIntValue(), p); + case VALUE_STRING: + String monthSpec = p.getText(); + int oneBasedMonthNumber = _decodeNumber(monthSpec); + if (oneBasedMonthNumber >= 0) { + return _decodeMonth(oneBasedMonthNumber, p); + } + // Otherwise fall through to default handling + break; + default: } - return getDelegatee().deserialize(parser, context); + return getDelegatee().deserialize(p, ctxt); } /** diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserializer.java index d34db205..7e6c3603 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearDeserializer.java @@ -79,27 +79,28 @@ protected YearDeserializer withLeniency(Boolean leniency) { } @Override - public Year deserialize(JsonParser parser, DeserializationContext context) throws IOException + public Year deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - JsonToken t = parser.currentToken(); + JsonToken t = p.currentToken(); if (t == JsonToken.VALUE_STRING) { - return _fromString(parser, context, parser.getText()); + return _fromString(p, ctxt, p.getText()); } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) if (t == JsonToken.START_OBJECT) { - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); - } - if (t == JsonToken.VALUE_NUMBER_INT) { - return _fromNumber(context, parser.getIntValue()); - } - if (t == JsonToken.VALUE_EMBEDDED_OBJECT) { - return (Year) parser.getEmbeddedObject(); - } - if (parser.hasToken(JsonToken.START_ARRAY)){ - return _deserializeFromArray(parser, context); + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + // fall through + } else if (t == JsonToken.VALUE_NUMBER_INT) { + return _fromNumber(ctxt, p.getIntValue()); + } else if (t == JsonToken.VALUE_EMBEDDED_OBJECT) { + return (Year) p.getEmbeddedObject(); + } else if (p.isExpectedStartArrayToken()){ + return _deserializeFromArray(p, ctxt); } - return _handleUnexpectedToken(context, parser, JsonToken.VALUE_STRING, JsonToken.VALUE_NUMBER_INT); + return _handleUnexpectedToken(ctxt, p, JsonToken.VALUE_STRING, JsonToken.VALUE_NUMBER_INT); } protected Year _fromString(JsonParser p, DeserializationContext ctxt, diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserializer.java index 58709ffa..4114343e 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/YearMonthDeserializer.java @@ -81,50 +81,52 @@ protected YearMonthDeserializer withLeniency(Boolean leniency) { } @Override - public YearMonth deserialize(JsonParser parser, DeserializationContext context) throws IOException + public YearMonth deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - if (parser.hasToken(JsonToken.VALUE_STRING)) { - return _fromString(parser, context, parser.getText()); + if (p.hasToken(JsonToken.VALUE_STRING)) { + return _fromString(p, ctxt, p.getText()); } // 30-Sep-2020, tatu: New! "Scalar from Object" (mostly for XML) - if (parser.isExpectedStartObjectToken()) { - return _fromString(parser, context, - context.extractScalarFromObject(parser, this, handledType())); - } - if (parser.isExpectedStartArrayToken()) { - JsonToken t = parser.nextToken(); + if (p.isExpectedStartObjectToken()) { + // 17-May-2025, tatu: [databind#4656] need to check for `null` + String str = ctxt.extractScalarFromObject(p, this, handledType()); + if (str != null) { + return _fromString(p, ctxt, str); + } + // fall through + } else if (p.isExpectedStartArrayToken()) { + JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY) { return null; } if ((t == JsonToken.VALUE_STRING || t == JsonToken.VALUE_EMBEDDED_OBJECT) - && context.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { - final YearMonth parsed = deserialize(parser, context); - if (parser.nextToken() != JsonToken.END_ARRAY) { - handleMissingEndArrayForSingle(parser, context); + && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { + final YearMonth parsed = deserialize(p, ctxt); + if (p.nextToken() != JsonToken.END_ARRAY) { + handleMissingEndArrayForSingle(p, ctxt); } return parsed; } if (t != JsonToken.VALUE_NUMBER_INT) { - _reportWrongToken(context, JsonToken.VALUE_NUMBER_INT, "years"); + _reportWrongToken(ctxt, JsonToken.VALUE_NUMBER_INT, "years"); } - int year = parser.getIntValue(); - int month = parser.nextIntValue(-1); + int year = p.getIntValue(); + int month = p.nextIntValue(-1); if (month == -1) { - if (!parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { - _reportWrongToken(context, JsonToken.VALUE_NUMBER_INT, "months"); + if (!p.hasToken(JsonToken.VALUE_NUMBER_INT)) { + _reportWrongToken(ctxt, JsonToken.VALUE_NUMBER_INT, "months"); } - month = parser.getIntValue(); + month = p.getIntValue(); } - if (parser.nextToken() != JsonToken.END_ARRAY) { - throw context.wrongTokenException(parser, handledType(), JsonToken.END_ARRAY, + if (p.nextToken() != JsonToken.END_ARRAY) { + throw ctxt.wrongTokenException(p, handledType(), JsonToken.END_ARRAY, "Expected array to end"); } return YearMonth.of(year, month); + } else if (p.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { + return (YearMonth) p.getEmbeddedObject(); } - if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { - return (YearMonth) parser.getEmbeddedObject(); - } - return _handleUnexpectedToken(context, parser, + return _handleUnexpectedToken(ctxt, p, JsonToken.VALUE_STRING, JsonToken.START_ARRAY); } From 0feeaf323170cb16a5e339de3ab0aa8fdafe362f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 27 May 2025 09:43:08 -0700 Subject: [PATCH 046/140] Manual pom.xml merge --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 7957d597..6b8a8c43 100644 --- a/pom.xml +++ b/pom.xml @@ -53,13 +53,13 @@ - + + - sonatype-nexus-snapshots - Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots + central-snapshots + Sonatype Central Portal (snapshots) + https://central.sonatype.com/repository/maven-snapshots false true From a60e62125fcaf80b3a3f030afcf352a669142032 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 27 May 2025 09:43:28 -0700 Subject: [PATCH 047/140] Manual pom.xml merge --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 7cf2eb44..1a95e1a0 100644 --- a/pom.xml +++ b/pom.xml @@ -53,13 +53,13 @@ - + + - sonatype-nexus-snapshots - Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots + central-snapshots + Sonatype Central Portal (snapshots) + https://central.sonatype.com/repository/maven-snapshots false true From 0ab8b7f8ab00c1b2584da8df6c1b7ab105dbe073 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 13 Jun 2025 18:33:47 -0700 Subject: [PATCH 048/140] Prep for 2.19.1 --- pom.xml | 2 +- release-notes/VERSION-2.x | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b8a8c43..e7436022 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.1-SNAPSHOT + 2.19.1 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 530e14ba..e8a80ba8 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -12,6 +12,10 @@ Modules: - +2.19.1 (13-Jun-2025) + +No changes since 2.19.0 + 2.19.0 (24-Apr-2025) #336: Optimize `InstantDeserializer` `addInColonToOffsetIfMissing()` From 35f72f172001df24174b03cf9857d96719ddd549 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 13 Jun 2025 18:34:20 -0700 Subject: [PATCH 049/140] [maven-release-plugin] prepare release jackson-modules-java8-2.19.1 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 2f98b588..a5b29793 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1-SNAPSHOT + 2.19.1 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 564c7fa9..a78613e2 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1-SNAPSHOT + 2.19.1 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index e13d0c7f..b2acb95f 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1-SNAPSHOT + 2.19.1 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index e7436022..d35e5545 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.1-SNAPSHOT + 2.19.1 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.19.1 https://github.com/FasterXML/jackson-modules-java8/issues From a4e1d3889d035aee2cde9c7033e51c8c206a1966 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 13 Jun 2025 18:34:23 -0700 Subject: [PATCH 050/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index a5b29793..72060b56 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1 + 2.19.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index a78613e2..1df312e9 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1 + 2.19.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index b2acb95f..7f1b4f9a 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.1 + 2.19.2-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index d35e5545..c53c0c15 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.1 + 2.19.2-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.19.1 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From e8f333a677acd83d0126e429faa837003d2e2259 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 13 Jun 2025 18:36:04 -0700 Subject: [PATCH 051/140] Back to snapshot dep --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c53c0c15..2e4f779b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.1 + 2.19.2-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 85daac9426c0abaf9d6218937a0df20fcf218cec Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 18 Jul 2025 11:10:33 -0700 Subject: [PATCH 052/140] Prep for 2.19.2 --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e4f779b..94868197 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.2-SNAPSHOT + 2.19.2 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index e8a80ba8..c005a59e 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -12,6 +12,7 @@ Modules: - +2.19.2 (18-Jul-2025) 2.19.1 (13-Jun-2025) No changes since 2.19.0 From 2190cd1dc84b2b8d4baa0a5ea783321807a33c6f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 18 Jul 2025 11:12:42 -0700 Subject: [PATCH 053/140] [maven-release-plugin] prepare release jackson-modules-java8-2.19.2 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 72060b56..f2d82fd1 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.2-SNAPSHOT + 2.19.2 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1df312e9..3a56fae7 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.2-SNAPSHOT + 2.19.2 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 7f1b4f9a..90c24254 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.2-SNAPSHOT + 2.19.2 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 94868197..e4a57513 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.2-SNAPSHOT + 2.19.2 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.19.2 https://github.com/FasterXML/jackson-modules-java8/issues From 6f346f21bb7b19c6128eed6fd3b37be7b549f3f0 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 18 Jul 2025 11:12:45 -0700 Subject: [PATCH 054/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index f2d82fd1..6370041a 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.2 + 2.19.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 3a56fae7..7b463cb5 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.2 + 2.19.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 90c24254..62fdc191 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.2 + 2.19.3-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index e4a57513..34e23924 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.2 + 2.19.3-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.19.2 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 0cccc53fea877e7a586a37453b883927c9bdaf1e Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 18 Jul 2025 11:13:57 -0700 Subject: [PATCH 055/140] Back to snapshot dep --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34e23924..95940c29 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.2 + 2.19.3-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 2c1f2382ecde4c274ccb686d410f556189acb93e Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 1 Aug 2025 10:59:56 -0700 Subject: [PATCH 056/140] -> 2.20.0-rc1-SNAPSHOT --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 63b4f4ae..ddb9ac42 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-SNAPSHOT + 2.20.0-rc1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 2d6e0ab8..90957d29 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-SNAPSHOT + 2.20.0-rc1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 4cd3fc7d..76a25047 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-SNAPSHOT + 2.20.0-rc1-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 1a95e1a0..e3ff3aff 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.20.0-SNAPSHOT + 2.20.0-rc1-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.0-SNAPSHOT + 2.20.0-rc1-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types From 8194341702ac86685a290695f84851d2b40a08dd Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 4 Aug 2025 18:15:48 -0700 Subject: [PATCH 057/140] Prep for 2.20.0-rc1 --- pom.xml | 2 +- release-notes/VERSION-2.x | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e3ff3aff..2981210b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.0-rc1-SNAPSHOT + 2.20.0-rc1 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 101ffc49..d1e199aa 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,9 +8,9 @@ Modules: === Releases === ------------------------------------------------------------------------ -2.20.0 (not yet released) +2.20.0-rc1 (04-Aug-2025) -- +No changes since 2.19 2.19.2 (18-Jul-2025) 2.19.1 (13-Jun-2025) From dfe7708d7d6d3542b0c4bdccd9aa4b6d42e5c352 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 4 Aug 2025 18:17:27 -0700 Subject: [PATCH 058/140] [maven-release-plugin] prepare release jackson-modules-java8-2.20.0-rc1 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index ddb9ac42..1d9bc15c 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc1-SNAPSHOT + 2.20.0-rc1 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 90957d29..456b9b60 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc1-SNAPSHOT + 2.20.0-rc1 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 76a25047..280fcfbd 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc1-SNAPSHOT + 2.20.0-rc1 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 2981210b..814d56a6 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.0-rc1-SNAPSHOT + 2.20.0-rc1 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.20.0-rc1 https://github.com/FasterXML/jackson-modules-java8/issues From 9fd75c1c5039d9e064ddd454cb9928e85f530633 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 4 Aug 2025 18:17:30 -0700 Subject: [PATCH 059/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 1d9bc15c..e61262bf 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc1 + 2.20.0-rc2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 456b9b60..e44979d7 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc1 + 2.20.0-rc2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 280fcfbd..5041b83d 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc1 + 2.20.0-rc2-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 814d56a6..5d974cb7 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.0-rc1 + 2.20.0-rc2-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.20.0-rc1 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 429529ec9de7a446b35d66ce6697365bffc613b4 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 4 Aug 2025 18:18:32 -0700 Subject: [PATCH 060/140] Post-release version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d974cb7..65b38891 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.0-rc1 + 2.20.0-rc2-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 28e2e2926a3ae2992fac35e33b3447231bf49d08 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 14 Aug 2025 10:25:02 -0700 Subject: [PATCH 061/140] Remove rc2 from version --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index e61262bf..63b4f4ae 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc2-SNAPSHOT + 2.20.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index e44979d7..2d6e0ab8 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc2-SNAPSHOT + 2.20.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 5041b83d..4cd3fc7d 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-rc2-SNAPSHOT + 2.20.0-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 65b38891..1a95e1a0 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.20.0-rc2-SNAPSHOT + 2.20.0-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.0-rc2-SNAPSHOT + 2.20.0-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types From c9e2fa86034ff47016c436a1e16ad246bac3f569 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 Aug 2025 16:11:50 -0700 Subject: [PATCH 062/140] Prep for 2.20.0 --- pom.xml | 2 +- release-notes/VERSION-2.x | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1a95e1a0..e4348afc 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.0-SNAPSHOT + 2.20.0 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index d1e199aa..da89b1e5 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,7 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ -2.20.0-rc1 (04-Aug-2025) +2.20.0 (28-Aug-2025) No changes since 2.19 From 70a2e0f13877a65905cfda8e72ff31edea8e72f7 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 Aug 2025 16:12:23 -0700 Subject: [PATCH 063/140] [maven-release-plugin] prepare release jackson-modules-java8-2.20.0 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 63b4f4ae..a3261c64 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-SNAPSHOT + 2.20.0 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 2d6e0ab8..01ee3457 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-SNAPSHOT + 2.20.0 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 4cd3fc7d..bc2e8f54 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0-SNAPSHOT + 2.20.0 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index e4348afc..fbbb1ba7 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.0-SNAPSHOT + 2.20.0 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.20.0 https://github.com/FasterXML/jackson-modules-java8/issues From 0d71395e31b7a722d5b859623e7f7720f7f8d5b2 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 Aug 2025 16:12:26 -0700 Subject: [PATCH 064/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index a3261c64..f7ad4af3 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0 + 2.20.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 01ee3457..62803086 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0 + 2.20.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index bc2e8f54..c24a9915 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.0 + 2.20.1-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index fbbb1ba7..54cb51aa 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.0 + 2.20.1-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.20.0 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From cfe9c9d1370ba276b3dd69994201efd85bdb7b06 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 Aug 2025 16:14:01 -0700 Subject: [PATCH 065/140] Post-release dep bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 54cb51aa..4aaf6a4b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.0 + 2.20.1-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 1f8f8ad4b73fd92d8486e3c5dfab1700a85f9d8d Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 29 Aug 2025 17:38:49 -0700 Subject: [PATCH 066/140] Start 2.20 branch; update 2.x to 2.21 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- release-notes/VERSION-2.x | 4 ++++ 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index f7ad4af3..ddd1d958 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1-SNAPSHOT + 2.21.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 62803086..b017e4d4 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1-SNAPSHOT + 2.21.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index c24a9915..4da6acf9 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1-SNAPSHOT + 2.21.0-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 4aaf6a4b..eb4b8cd5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.20.1-SNAPSHOT + 2.21.0-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.1-SNAPSHOT + 2.21.0-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index da89b1e5..8c23372d 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,10 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.21.0 (not yet released) + +No changes since 2.20 + 2.20.0 (28-Aug-2025) No changes since 2.19 From b914b11dc6d28a7994251469bb7ce8b0a60398ad Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 14:06:15 -0700 Subject: [PATCH 067/140] Prep for 2.19.3 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95940c29..178a979b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.3-SNAPSHOT + 2.19.3 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index e20ad5de..bf31120e 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -12,6 +12,7 @@ Modules: - +2.19.3 (29-Oct-2025) 2.19.2 (18-Jul-2025) 2.19.1 (13-Jun-2025) From aaee96285f657329dfae793a56d4248256d30aa6 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 14:07:09 -0700 Subject: [PATCH 068/140] [maven-release-plugin] prepare release jackson-modules-java8-2.19.3 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 6370041a..3afab148 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.3-SNAPSHOT + 2.19.3 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 7b463cb5..fb4947ce 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.3-SNAPSHOT + 2.19.3 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 62fdc191..227fd4dd 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.3-SNAPSHOT + 2.19.3 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 178a979b..8feb5af4 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.3-SNAPSHOT + 2.19.3 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.19.3 https://github.com/FasterXML/jackson-modules-java8/issues From 67d7b3f87e387c9fe0bf951c626402e3abc27203 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 14:07:12 -0700 Subject: [PATCH 069/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 3afab148..d27cea0a 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.3 + 2.19.4-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index fb4947ce..06ed516e 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.3 + 2.19.4-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 227fd4dd..15d4939b 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.3 + 2.19.4-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 8feb5af4..17ed8ad6 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.3 + 2.19.4-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.19.3 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From c08fc14f3725ed3d0f05fd4489688c09883d71e4 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 14:08:28 -0700 Subject: [PATCH 070/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 17ed8ad6..cbd7038c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.3 + 2.19.4-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 9cc3d04816008bf2d640caed30ee76d71b16370c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 17:19:32 -0700 Subject: [PATCH 071/140] Prep for 2.19.4 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cbd7038c..ffbfc7dd 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.4-SNAPSHOT + 2.19.4 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index bf31120e..3e8104fe 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -12,6 +12,7 @@ Modules: - +2.19.4 (29-Oct-2025) 2.19.3 (29-Oct-2025) 2.19.2 (18-Jul-2025) 2.19.1 (13-Jun-2025) From af1020ebcafa96acb381d3484257f97595105bc9 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 17:20:03 -0700 Subject: [PATCH 072/140] [maven-release-plugin] prepare release jackson-modules-java8-2.19.4 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index d27cea0a..cd1ea2c6 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.4-SNAPSHOT + 2.19.4 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 06ed516e..4be67453 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.4-SNAPSHOT + 2.19.4 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 15d4939b..aa6e4d60 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.4-SNAPSHOT + 2.19.4 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index ffbfc7dd..5f799f99 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.4-SNAPSHOT + 2.19.4 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.19.4 https://github.com/FasterXML/jackson-modules-java8/issues From 7e9c6e87b56278b8268596304cd36d39dfb9d570 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 17:20:06 -0700 Subject: [PATCH 073/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index cd1ea2c6..84b3145b 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.4 + 2.19.5-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 4be67453..47ab8d89 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.4 + 2.19.5-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index aa6e4d60..d1047cbc 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.19.4 + 2.19.5-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 5f799f99..e4671b95 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.19.4 + 2.19.5-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.19.4 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From b326f95bcc0551cf5c66295aa81fb2b6a92942c1 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 29 Oct 2025 17:21:24 -0700 Subject: [PATCH 074/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e4671b95..cc0eb7b1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.19.4 + 2.19.5-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 65c435ebc8b3c0746861ba592e716eb006719615 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 30 Oct 2025 17:00:32 -0700 Subject: [PATCH 075/140] Prep for 2.20.1 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4aaf6a4b..a7e36bee 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.1-SNAPSHOT + 2.20.1 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 8e66e05f..89c4bc35 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.20.1 (30-Oct-2025) 2.20.0 (28-Aug-2025) No changes since 2.19 From 68133474b8b4a870138b45c1405acbe079d63a10 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 30 Oct 2025 17:01:08 -0700 Subject: [PATCH 076/140] [maven-release-plugin] prepare release jackson-modules-java8-2.20.1 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index f7ad4af3..00d751de 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1-SNAPSHOT + 2.20.1 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 62803086..e9883f7e 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1-SNAPSHOT + 2.20.1 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index c24a9915..6a104dba 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1-SNAPSHOT + 2.20.1 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index a7e36bee..e8015942 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.1-SNAPSHOT + 2.20.1 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.20.1 https://github.com/FasterXML/jackson-modules-java8/issues From cad79ca03e82cde9d9daa507ac8dfdf3a00339d2 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 30 Oct 2025 17:01:10 -0700 Subject: [PATCH 077/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 00d751de..54b06b22 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1 + 2.20.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index e9883f7e..1451adf2 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1 + 2.20.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 6a104dba..e07d6752 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.1 + 2.20.2-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index e8015942..a45fd922 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.1 + 2.20.2-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.20.1 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 08e41ac3da7cdaf9a8387a6f6a94ccfdb75663c3 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 30 Oct 2025 17:02:19 -0700 Subject: [PATCH 078/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a45fd922..025a68f4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.1 + 2.20.2-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From a460d0a9b177465358d2aa925e10f1a83d952afc Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 11 Nov 2025 19:31:31 -0800 Subject: [PATCH 079/140] Fix #377 --- parameter-names/README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/parameter-names/README.md b/parameter-names/README.md index 43dbf65d..1404490b 100644 --- a/parameter-names/README.md +++ b/parameter-names/README.md @@ -1,5 +1,4 @@ -Jackson module -that adds support for accessing parameter names; a feature added in JDK 8. +Jackson module that adds support for accessing parameter names; a feature added in JDK 8. ## Usage @@ -12,6 +11,11 @@ For maven dependency definition, click on the second badge in the previous, Stat Like all standard Jackson modules (libraries that implement Module interface), registration is done as follows: ```java +ObjectMapper mapper = JsonMapper.builder() + .addModule(new ParameterNamesModule()) + .build(); + +// Or, older (pre-2.10): ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new ParameterNamesModule()); ``` @@ -26,9 +30,9 @@ To override this behavior use the `ParameterNamesModule` constructor with `JsonC For example, to use same behavior as for constructors with multiple parameters: ```java -ObjectMapper objectMapper = new ObjectMapper(); -objectMapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)); - +ObjectMapper mapper = JsonMapper.builder() + .addModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) + .build(); ``` ### Usage example @@ -76,14 +80,15 @@ class Person { Preconditions: - - class Person must be compiled with Java 8 compliant compiler with option to store formal parameter names turned on (`-parameters` option). For more information about Java 8 API for accessing parameter names at runtime see [this][2] - - if there are multiple visible constructors and there is no default constructor, `@JsonCreator` is required to select constructor for deserialization - - if used with `jackson-databind` lower than `2.6.0`, `@JsonCreator` is required. In practice, `@JsonCreator` is also often required with `2.6.0+` due to issues with constructor discovery that will be resolved in `2.7`. - - if class Person has a single argument constructor, its argument needs to be annotated with `@JsonProperty("propertyName")`. This is to preserve legacy behavior, see [FasterXML/jackson-databind/#1498][3] +- class Person must be compiled with Java 8 compliant compiler with option to store formal parameter names turned on (`-parameters` option). For more information about Java 8 API for accessing parameter names at runtime see [this][2] +- if there are multiple visible constructors and there is no default constructor, `@JsonCreator` is required to select constructor for deserialization +- if used with `jackson-databind` lower than `2.6.0`, `@JsonCreator` is required. In practice, `@JsonCreator` is also often required with `2.6.0+` due to issues with constructor discovery that will be resolved in `2.7`. +- if class Person has a single-argument constructor, its argument needs to be annotated with `@JsonProperty("propertyName")`. This is to preserve legacy behavior, see [FasterXML/jackson-databind/#1498][3] + ## More See [Wiki](../../../wiki) for more information (javadocs, downloads). -[1]: http://jackson.codehaus.org/1.1.2/javadoc/org/codehaus/jackson/annotate/JsonProperty.html +[1]: https://javadoc.io/static/com.fasterxml.jackson.core/jackson-annotations/2.20/com/fasterxml/jackson/annotation/JsonProperty.html [2]: http://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html [3]: https://github.com/FasterXML/jackson-databind/issues/1498 From 76d6bb21b45db28d2ba2687bceb7858eaba1b46f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 11 Nov 2025 19:34:05 -0800 Subject: [PATCH 080/140] Update README --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e552afd2..40ab0ce9 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,11 @@ When used with Jackson 2.x, Java 8 support is provided via 3 separate modules: all of which are built from this repository, and accessed and used as separate Jackson modules (with separate Maven artifacts). -### Jackson 3.0 +### Jackson 3.x -Jackson 3.0 changes things as it requires Java 8 to work and can thereby directly supported features. +Jackson 3.0 changes things as it requires Java 17 to work and can thereby directly supported features. -Because of this, all 3 modules are merged into `jackson-databind` -and need not be registered (as of Jacksson `3.0.0-rc3`) +Because of this, all 3 modules are merged into `jackson-databind` and need not be registered (as of Jackson `3.0.0`) ## License @@ -33,7 +32,7 @@ All modules are licensed under [Apache License 2.0](http://www.apache.org/licens ## Status -[![Build status (github)](https://github.com/FasterXML/jackson-databind/actions/workflows/main.yml/badge.svg)](https://github.com/FasterXML/jackson-databind/actions/workflows/main.yml) +[![Build status (github)](https://github.com/FasterXML/jackson-modules-java8/actions/workflows/main.yml/badge.svg)](https://github.com/FasterXML/jackson-modules-java8/actions/workflows/main.yml) [![Tidelift](https://tidelift.com/badges/package/maven/com.fasterxml.jackson.datatype:jackson-datatype-jsr310)](https://tidelift.com/subscription/pkg/maven-com-fasterxml-jackson-datatype-jackson-datatype-jsr310?utm_source=maven-com-fasterxml-jackson-datatype-jackson-datatype-jsr310&utm_medium=referral&utm_campaign=readme) ## Usage From bf46db88321e59b1c4d5a71787e9dfe42319f0b5 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 11 Nov 2025 19:36:41 -0800 Subject: [PATCH 081/140] ... --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 40ab0ce9..1bbeef26 100644 --- a/README.md +++ b/README.md @@ -128,4 +128,4 @@ Following developers have committer access to this project. ## More -See [Wiki](../../wiki) for more information (javadocs). +See [Wiki](../../wiki) for more information. From 57084c7c65e7c914df498912af5165f1217aae3f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 10:40:26 -0800 Subject: [PATCH 082/140] Fix CI filtering --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a45e66f..4dd97f4c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,7 @@ name: Build and Deploy Snapshot on: push: + branches: [`2.*`] paths-ignore: - "README.md" - "release-notes/*" From e555c2c13ca3245f9a6cee8d00eb82e20a345b94 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 10:41:17 -0800 Subject: [PATCH 083/140] Fix the CI Fix :-/ --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4dd97f4c..421f1687 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,7 @@ name: Build and Deploy Snapshot on: push: - branches: [`2.*`] + branches: ['2.*']x paths-ignore: - "README.md" - "release-notes/*" From 6ba6fa595e0fdf38d3dbdadbe4894b81b7efaa53 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 10:41:58 -0800 Subject: [PATCH 084/140] ... --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 421f1687..778ed7bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,7 @@ name: Build and Deploy Snapshot on: push: - branches: ['2.*']x + branches: ['2.*'] paths-ignore: - "README.md" - "release-notes/*" From 236faaf8be396758c244885651055a57653f3cf5 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 10:45:30 -0800 Subject: [PATCH 085/140] Fix #359 (#378) --- .../fasterxml/jackson/datatype/jsr310/DecimalUtils.java | 8 ++++++++ .../datatype/jsr310/deser/InstantDeserializer.java | 5 +++-- .../InstantDeserializerNegative359Test.java | 4 +--- release-notes/CREDITS-2.x | 3 +++ release-notes/VERSION-2.x | 5 +++++ 5 files changed, 20 insertions(+), 5 deletions(-) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{tofix => deser}/InstantDeserializerNegative359Test.java (86%) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/DecimalUtils.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/DecimalUtils.java index ad9ead2f..a76c0139 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/DecimalUtils.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/DecimalUtils.java @@ -84,6 +84,14 @@ public static String toDecimal(long seconds, int nanoseconds) */ public static BigDecimal toBigDecimal(long seconds, int nanoseconds) { + // [modules-java8#359] For negative seconds with positive nanos (times before epoch), + // we need to compute the proper decimal value: seconds + (nanos / 1_000_000_000) + // Example: Instant{epochSecond=-1, nano=999000000} represents -0.001 seconds + if (seconds < 0 && nanoseconds > 0) { + return BigDecimal.valueOf(seconds) + .add(BigDecimal.valueOf(nanoseconds).scaleByPowerOfTen(-9)); + } + if (nanoseconds == 0L) { // 14-Mar-2015, tatu: Let's retain one zero to avoid interpretation // as integral number diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java index 0e1bf808..c882d541 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java @@ -480,8 +480,9 @@ protected T _fromDecimal(DeserializationContext context, BigDecimal value) { FromDecimalArguments args = DecimalUtils.extractSecondsAndNanos(value, (s, ns) -> new FromDecimalArguments(s, ns, getZone(context)), - // [modules-java8#337] since 2.19, only Instant needs negative adjustment - true); + // [modules-java8#359] since 2.21, Instant.ofEpochSecond() correctly handles + // negative nanoseconds, so no adjustment needed + false); return fromNanoseconds.apply(args); } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstantDeserializerNegative359Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializerNegative359Test.java similarity index 86% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstantDeserializerNegative359Test.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializerNegative359Test.java index 44ce23bf..ac4e5089 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstantDeserializerNegative359Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializerNegative359Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.tofix; +package com.fasterxml.jackson.datatype.jsr310.deser; import java.time.Instant; @@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -18,7 +17,6 @@ public class InstantDeserializerNegative359Test { private final ObjectReader READER = newMapper().readerFor(Instant.class); - @JacksonTestFailureExpected @Test public void testDeserializationAsFloat04() throws Exception diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index 39c41bf9..f75b3900 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -213,6 +213,9 @@ Kevin Mahon (@Strongbeard) * Fixed #291: `InstantDeserializer` fails to parse negative numeric timestamp strings for pre-1970 values (2.18.4) + * Reported #359: `InstantDeserializer` deserializes the nanosecond portion of fractional + negative timestamps incorrectly + (2.21.0) Joey Muia (@jmuia) * Reported #337: Negative `Duration` does not round-trip properly with diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index dd8ac134..f830b290 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -10,6 +10,11 @@ Modules: 2.21.0 (not yet released) +#359: `InstantDeserializer` deserializes the nanosecond portion of fractional + negative timestamps incorrectly + (reported by Kevin M) + (fix by @cowtowncoder, w/ Claude code) + No changes since 2.20 2.20.1 (30-Oct-2025) From c38b656d454b4a618f2c6066a473da0f6156957e Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 11:02:41 -0800 Subject: [PATCH 086/140] Note on #244 being closed --- .../datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java index a25bbb72..81a79b0c 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/ZonedDateTimeIssue244Test.java @@ -13,6 +13,8 @@ import static org.junit.jupiter.api.Assertions.*; +// 17-Nov-2025, tatu: Issue closed as not planned to be fixed: unit test +// left in for now, likely to be removed in future. /** * Test case for https://github.com/FasterXML/jackson-modules-java8/issues/244 */ From a94b8d007070d573d9297a26598835b7ddc97f43 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 11:06:16 -0800 Subject: [PATCH 087/140] Remove test for #279 since tested case was invalid --- .../tofix/OffsetDateTimeDeser279Test.java | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/OffsetDateTimeDeser279Test.java diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/OffsetDateTimeDeser279Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/OffsetDateTimeDeser279Test.java deleted file mode 100644 index 02b7869c..00000000 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/OffsetDateTimeDeser279Test.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.fasterxml.jackson.datatype.jsr310.tofix; - -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.temporal.ChronoUnit; - -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; - -import static org.junit.jupiter.api.Assertions.*; - -public class OffsetDateTimeDeser279Test extends ModuleTestBase -{ - // For [modules-java8#279] - static class Wrapper279 { - OffsetDateTime date; - - public Wrapper279(OffsetDateTime d) { date = d; } - protected Wrapper279() { } - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'") - public OffsetDateTime getDate() { - return date; - } - public void setDate(OffsetDateTime date) { - this.date = date; - } - } - - private ObjectMapper MAPPER = newMapper(); - - // For [modules-java8#279] - @JacksonTestFailureExpected - @Test - public void testWrapperWithPattern279() throws Exception - { - final OffsetDateTime date = OffsetDateTime.now(ZoneId.of("UTC")) - .truncatedTo(ChronoUnit.SECONDS); - final Wrapper279 input = new Wrapper279(date); - final String json = MAPPER.writeValueAsString(input); - - Wrapper279 result = MAPPER.readValue(json, Wrapper279.class); - assertEquals(input.date, result.date); - } -} From 23044e24f172edee19e2977d9956b921756841a5 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 11:22:38 -0800 Subject: [PATCH 088/140] Fix test for #307 to show solution --- .../InstantViaBigDecimal307Test.java} | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{tofix/InstanceViaBigDecimal307Test.java => deser/InstantViaBigDecimal307Test.java} (75%) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantViaBigDecimal307Test.java similarity index 75% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantViaBigDecimal307Test.java index 58ddf542..d1104a90 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantViaBigDecimal307Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.tofix; +package com.fasterxml.jackson.datatype.jsr310.deser; import java.time.Instant; @@ -6,14 +6,15 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.cfg.JsonNodeFeature; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; // [modules-java8#307]: Loss of precision via JsonNode for BigDecimal-valued // things (like Instant) -public class InstanceViaBigDecimal307Test extends ModuleTestBase +// Solved via `JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS` added in Jackson 2.19 +public class InstantViaBigDecimal307Test extends ModuleTestBase { static class Wrapper307 { public Instant value; @@ -24,7 +25,10 @@ protected Wrapper307() { } private final Instant ISSUED_AT = Instant.ofEpochSecond(1234567890).plusNanos(123456789); - private ObjectMapper MAPPER = newMapper(); + private ObjectMapper MAPPER = mapperBuilder() + // added in 2.19 + .enable(JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS) + .build(); @Test public void instantViaReadValue() throws Exception { @@ -33,7 +37,6 @@ public void instantViaReadValue() throws Exception { assertEquals(ISSUED_AT, deserialized.value); } - @JacksonTestFailureExpected @Test public void instantViaReadTree() throws Exception { String serialized = MAPPER.writeValueAsString(new Wrapper307(ISSUED_AT)); From cde7c554f88c7ce97e4730dfd9d81ac92faec10d Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 11:25:31 -0800 Subject: [PATCH 089/140] Update release notes wrt #307 --- release-notes/VERSION-2.x | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 3e8104fe..6c96442f 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -21,6 +21,10 @@ No changes since 2.19.0 2.19.0 (24-Apr-2025) +#307: Instant precision should be retained in ObjectMapper#readTree (add + `JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS` to force use of `BigDecimal` + for `JsonNode` reads) + (reported by @jzheaux) #336: Optimize `InstantDeserializer` `addInColonToOffsetIfMissing()` (contributed by David S) #337: Negative `Duration` does not round-trip properly with From f2f52722b51c2f36aad12cf35197242bc180dd0e Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 11:22:38 -0800 Subject: [PATCH 090/140] Fix test for #307 to show solution --- .../InstantViaBigDecimal307Test.java} | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) rename datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/{tofix/InstanceViaBigDecimal307Test.java => deser/InstantViaBigDecimal307Test.java} (75%) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantViaBigDecimal307Test.java similarity index 75% rename from datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java rename to datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantViaBigDecimal307Test.java index 58ddf542..d1104a90 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/tofix/InstanceViaBigDecimal307Test.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantViaBigDecimal307Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.datatype.jsr310.tofix; +package com.fasterxml.jackson.datatype.jsr310.deser; import java.time.Instant; @@ -6,14 +6,15 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.cfg.JsonNodeFeature; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; -import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; // [modules-java8#307]: Loss of precision via JsonNode for BigDecimal-valued // things (like Instant) -public class InstanceViaBigDecimal307Test extends ModuleTestBase +// Solved via `JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS` added in Jackson 2.19 +public class InstantViaBigDecimal307Test extends ModuleTestBase { static class Wrapper307 { public Instant value; @@ -24,7 +25,10 @@ protected Wrapper307() { } private final Instant ISSUED_AT = Instant.ofEpochSecond(1234567890).plusNanos(123456789); - private ObjectMapper MAPPER = newMapper(); + private ObjectMapper MAPPER = mapperBuilder() + // added in 2.19 + .enable(JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS) + .build(); @Test public void instantViaReadValue() throws Exception { @@ -33,7 +37,6 @@ public void instantViaReadValue() throws Exception { assertEquals(ISSUED_AT, deserialized.value); } - @JacksonTestFailureExpected @Test public void instantViaReadTree() throws Exception { String serialized = MAPPER.writeValueAsString(new Wrapper307(ISSUED_AT)); From ec2fa9121048f0b8e0b2dce2c22973078c6213eb Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 15:17:31 -0800 Subject: [PATCH 091/140] Fix #376: add factory methods/constructor for OffsetDateTime ser/deser with custom formatter (#379) --- .../jsr310/deser/InstantDeserializer.java | 17 +-- .../jsr310/ser/OffsetDateTimeSerializer.java | 22 ++++ .../jsr310/deser/OffsetDateTimeDeserTest.java | 97 ++++++++++++++++- .../jsr310/ser/OffsetDateTimeSerTest.java | 101 ++++++++++++++++++ release-notes/VERSION-2.x | 3 + 5 files changed, 229 insertions(+), 11 deletions(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java index c882d541..1a5e805f 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java @@ -200,12 +200,12 @@ protected InstantDeserializer(Class supportedType, */ @Deprecated() protected InstantDeserializer(Class supportedType, - DateTimeFormatter formatter, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust, - boolean replaceZeroOffsetAsZ + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ ) { this(supportedType, formatter, parsedToValue, fromMilliseconds, fromNanoseconds, adjust, replaceZeroOffsetAsZ, @@ -299,8 +299,11 @@ protected InstantDeserializer(InstantDeserializer base, _alwaysAllowStringifiedDateTimestamps = features.isEnabled(JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS); } + /** + * NOTE: {@code public} since 2.21 + */ @Override - protected InstantDeserializer withDateFormat(DateTimeFormatter dtf) { + public InstantDeserializer withDateFormat(DateTimeFormatter dtf) { if (dtf == _formatter) { return this; } diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java index ff7bd4c7..1a961c8d 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java @@ -35,6 +35,28 @@ public OffsetDateTimeSerializer(OffsetDateTimeSerializer base, Boolean useTimest super(base, useTimestamp, base._useNanoseconds, formatter, shape); } + /** + * Method for constructing a new {@code OffsetDateTimeSerializer} with settings + * of this serializer but with custom {@link DateTimeFormatter} overrides. + * Commonly used on {@code INSTANCE} like so: + *
+     *  DateTimeFormatter dtf = new DateTimeFormatterBuilder()
+     *          .append(DateTimeFormatter.ISO_LOCAL_DATE)
+     *          .appendLiteral('T')
+     *          // and so on
+     *          .toFormatter();
+     *  OffsetDateTimeSerializer ser = OffsetDateTimeSerializer.INSTANCE
+     *          .withFormatter(dtf);
+     *  // register via Module
+     *
+ * + * @since 2.21 + */ + public OffsetDateTimeSerializer withFormatter(DateTimeFormatter formatter) + { + return new OffsetDateTimeSerializer(this, _useTimestamp, formatter, _shape); + } + @Override protected JSR310FormattedSerializerBase withFormat(Boolean useTimestamp, DateTimeFormatter formatter, JsonFormat.Shape shape) diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java index 26b7423b..9c21a4e5 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/OffsetDateTimeDeserTest.java @@ -13,11 +13,11 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; + import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SerializationFeature; + +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.datatype.jsr310.DecimalUtils; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; @@ -873,4 +873,93 @@ private static ZoneOffset getOffset(OffsetDateTime date, ZoneId zone) private static String offsetWithoutColon(String string){ return new StringBuilder(string).deleteCharAt(string.lastIndexOf(":")).toString(); } + + /* + /********************************************************************** + /* Tests for custom formatter (modules-java8#376) + /********************************************************************** + */ + + @Test + public void testDeserializationWithCustomFormatter() throws Exception + { + // Create a custom formatter that can parse ISO_LOCAL_DATE_TIME and default offset to 0 + DateTimeFormatter customFormatter = new java.time.format.DateTimeFormatterBuilder() + .append(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + .optionalStart() + .parseLenient() + .appendOffsetId() + .parseStrict() + .optionalEnd() + .parseDefaulting(java.time.temporal.ChronoField.OFFSET_SECONDS, 0) + .toFormatter(); + + // Create custom deserializer with the custom formatter + InstantDeserializer customDeserializer = + InstantDeserializer.OFFSET_DATE_TIME.withDateFormat(customFormatter); + + // Create a custom module to override the default deserializer + SimpleModule customModule = new SimpleModule("CustomOffsetDateTimeModule") + .addDeserializer(OffsetDateTime.class, customDeserializer); + + // Add both JavaTimeModule (for other types) and our custom module + // The custom module will override OffsetDateTime deserialization + ObjectMapper mapper = mapperBuilder() + .addModule(customModule) + .build(); + + // Test deserializing date-time without offset (should default to +00:00) + // This is the main use case from issue #376 - parsing ISO_LOCAL_DATE_TIME with default offset + String jsonWithoutOffset = q("2025-01-01T22:01:05"); + OffsetDateTime result = mapper.readValue(jsonWithoutOffset, OffsetDateTime.class); + + assertNotNull(result); + assertEquals(2025, result.getYear()); + assertEquals(1, result.getMonthValue()); + assertEquals(1, result.getDayOfMonth()); + assertEquals(22, result.getHour()); + assertEquals(1, result.getMinute()); + assertEquals(5, result.getSecond()); + assertEquals(ZoneOffset.UTC, result.getOffset()); + + // Test that standard ISO format with offset still works + String jsonWithOffset = q("2025-01-01T22:01:05+02:00"); + OffsetDateTime resultWithOffset = mapper.readValue(jsonWithOffset, OffsetDateTime.class); + + assertNotNull(resultWithOffset); + assertEquals(2025, resultWithOffset.getYear()); + // Verify parsing succeeded - the exact time may be adjusted based on offset conversion + assertTrue(resultWithOffset.toInstant().equals(OffsetDateTime.parse("2025-01-01T22:01:05+02:00").toInstant())); + } + + @Test + public void testDeserializationWithCustomFormatterRoundTrip() throws Exception + { + // Create a custom formatter that can parse ISO_LOCAL_DATE_TIME and default offset to 0 + DateTimeFormatter customFormatter = new java.time.format.DateTimeFormatterBuilder() + .append(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + .optionalStart() + .parseLenient() + .appendOffsetId() + .parseStrict() + .optionalEnd() + .parseDefaulting(java.time.temporal.ChronoField.OFFSET_SECONDS, 0) + .toFormatter(); + + InstantDeserializer customDeserializer = + InstantDeserializer.OFFSET_DATE_TIME.withDateFormat(customFormatter); + SimpleModule customModule = new SimpleModule("CustomOffsetDateTimeModule") + .addDeserializer(OffsetDateTime.class, customDeserializer); + + ObjectMapper mapper = mapperBuilder() + .addModule(customModule) + .build(); + + // Verify standard ISO format still works + OffsetDateTime original = OffsetDateTime.of(2025, 1, 1, 22, 1, 5, 0, ZoneOffset.UTC); + String json = mapper.writeValueAsString(original); + OffsetDateTime roundTripped = mapper.readValue(json, OffsetDateTime.class); + + assertIsEqual(original, roundTripped); + } } diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java index e41dcd12..689d8644 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerTest.java @@ -3,8 +3,10 @@ import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.Temporal; import java.util.TimeZone; @@ -13,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.DecimalUtils; import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration; import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; @@ -284,4 +287,102 @@ public void testShapeInt() throws Exception { String json1 = newMapper().writeValueAsString(new Pojo1()); assertEquals("{\"t1\":1651053600000,\"t2\":1651053600.000000000}", json1); } + + /* + /********************************************************************** + /* Tests for custom formatter (modules-java8#376) + /********************************************************************** + */ + + @Test + public void testSerializationWithCustomFormatter() throws Exception + { + // Create a custom formatter that displays only 3 digits of nano-seconds instead of 9 + // Use ISO_LOCAL_DATE and ISO_LOCAL_TIME separately to control nanosecond precision + DateTimeFormatter customFormatter = new DateTimeFormatterBuilder() + .append(DateTimeFormatter.ISO_LOCAL_DATE) + .appendLiteral('T') + .appendValue(java.time.temporal.ChronoField.HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(java.time.temporal.ChronoField.MINUTE_OF_HOUR, 2) + .optionalStart() + .appendLiteral(':') + .appendValue(java.time.temporal.ChronoField.SECOND_OF_MINUTE, 2) + .optionalStart() + .appendFraction(java.time.temporal.ChronoField.NANO_OF_SECOND, 3, 3, true) + .optionalEnd() + .optionalEnd() + .appendOffsetId() + .toFormatter(); + + // Create a date with nanoseconds (123456789 nanos = .123456789 seconds) + OffsetDateTime date = OffsetDateTime.of(2025, 1, 1, 22, 1, 5, 123456789, ZoneOffset.UTC); + String json = _mapper(customFormatter).writeValueAsString(date); + + // Should output with only 3 digits of nano precision (.123 instead of .123456789) + assertEquals(q("2025-01-01T22:01:05.123Z"), json); + } + + @Test + public void testSerializationWithCustomFormatterNoNanos() throws Exception + { + // Create a formatter without nanoseconds + DateTimeFormatter customFormatter = new DateTimeFormatterBuilder() + .append(DateTimeFormatter.ISO_LOCAL_DATE) + .appendLiteral('T') + .appendValue(java.time.temporal.ChronoField.HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(java.time.temporal.ChronoField.MINUTE_OF_HOUR, 2) + .optionalStart() + .appendLiteral(':') + .appendValue(java.time.temporal.ChronoField.SECOND_OF_MINUTE, 2) + .optionalEnd() + .appendOffsetId() + .toFormatter(); + + OffsetDateTime date = OffsetDateTime.of(2025, 1, 1, 22, 1, 5, 123456789, ZoneOffset.UTC); + String json = _mapper(customFormatter).writeValueAsString(date); + + // Should output without nanoseconds + assertEquals(q("2025-01-01T22:01:05Z"), json); + } + + @Test + public void testSerializationWithCustomFormatterAndOffset() throws Exception + { + // Create a custom formatter that displays only 3 digits of nano-seconds + DateTimeFormatter customFormatter = new DateTimeFormatterBuilder() + .append(DateTimeFormatter.ISO_LOCAL_DATE) + .appendLiteral('T') + .appendValue(java.time.temporal.ChronoField.HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(java.time.temporal.ChronoField.MINUTE_OF_HOUR, 2) + .optionalStart() + .appendLiteral(':') + .appendValue(java.time.temporal.ChronoField.SECOND_OF_MINUTE, 2) + .optionalStart() + .appendFraction(java.time.temporal.ChronoField.NANO_OF_SECOND, 3, 3, true) + .optionalEnd() + .optionalEnd() + .appendOffsetId() + .toFormatter(); + + + // Create a date with a non-UTC offset + OffsetDateTime date = OffsetDateTime.of(2025, 1, 1, 22, 1, 5, 123456789, ZoneOffset.ofHours(5)); + String json = _mapper(customFormatter).writeValueAsString(date); + + // Should output with offset +05:00 and 3 digits of nano precision + assertEquals(q("2025-01-01T22:01:05.123+05:00"), json); + } + + private ObjectMapper _mapper(DateTimeFormatter dtf) { + OffsetDateTimeSerializer customSerializer = OffsetDateTimeSerializer.INSTANCE + .withFormatter(dtf); + SimpleModule customModule = new SimpleModule("CustomOffsetDateTimeModule") + .addSerializer(OffsetDateTime.class, customSerializer); + return mapperBuilder() + .addModule(customModule) + .build(); + } } diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index bdd6942c..63ec26b5 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -14,6 +14,9 @@ Modules: negative timestamps incorrectly (reported by Kevin M) (fix by @cowtowncoder, w/ Claude code) +#376: Allow specifying custom `DateTimeFormatter` for `OffsetDateTime` ser/deser + (new constructors?) + (requested by @ZIRAKrezovic) No changes since 2.20 From ad491b8c12af2bd4d18e3abec7ab5b5707c2c8f3 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 17 Nov 2025 16:29:59 -0800 Subject: [PATCH 092/140] Change `OffsetTimeSerializer._serializeAsArrayContents()` to `protected` to allow overriding --- .../jackson/datatype/jsr310/ser/OffsetTimeSerializer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerializer.java index f1dec8b9..30fc1037 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetTimeSerializer.java @@ -89,7 +89,7 @@ public void serializeWithType(OffsetTime value, JsonGenerator g, SerializerProvi typeSer.writeTypeSuffix(g, typeIdDef); } - private final void _serializeAsArrayContents(OffsetTime value, JsonGenerator g, + protected void _serializeAsArrayContents(OffsetTime value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeNumber(value.getHour()); @@ -99,7 +99,7 @@ private final void _serializeAsArrayContents(OffsetTime value, JsonGenerator g, if ((secs > 0) || (nanos > 0)) { g.writeNumber(secs); if (nanos > 0) { - if(useNanoseconds(provider)) { + if (useNanoseconds(provider)) { g.writeNumber(nanos); } else { g.writeNumber(value.get(ChronoField.MILLI_OF_SECOND)); From aa4de63a2bcd04e43225da49af68480a47f827fc Mon Sep 17 00:00:00 2001 From: AlbertLovers Date: Wed, 31 Dec 2025 03:02:12 +0100 Subject: [PATCH 093/140] Fix a potential problem in `JavaTimeModule._findFactory()` (#381) * Update JavaTimeModule.java Validate the order of the argument types against the order of the parameters. The previous version ignored mismatches and returned the first method with the correct name and correct number of parameters regardless of parameter types. --- .../datatype/jsr310/JavaTimeModule.java | 26 ++++++++++++------- release-notes/CREDITS-2.x | 6 ++++- release-notes/VERSION-2.x | 4 +-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java index 575d53c4..ae953380 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java @@ -266,21 +266,27 @@ protected AnnotatedMethod _findFactory(AnnotatedClass cls, String name, Class { final int argCount = argTypes.length; for (AnnotatedMethod method : cls.getFactoryMethods()) { - if (!name.equals(method.getName()) - || (method.getParameterCount() != argCount)) { - continue; + if (name.equals(method.getName()) + && (method.getParameterCount() == argCount) + && _allArgTypesMatch(argTypes, method)) { + return method; } - for (int i = 0; i < argCount; ++i) { - Class argType = method.getParameter(i).getRawType(); - if (!argType.isAssignableFrom(argTypes[i])) { - continue; - } - } - return method; } return null; } + // @since 2.21 + private boolean _allArgTypesMatch(Class[] expectedArgTypes, AnnotatedMethod method) + { + for (int i = 0, len = expectedArgTypes.length; i < len; ++i) { + Class argType = method.getParameter(i).getRawType(); + if (!argType.isAssignableFrom(expectedArgTypes[i])) { + return false; + } + } + return true; + } + /** * Container for serializers, with one tweak; specific lookup we need to deal * with specific {@code TemporalAdjuster} closure subtypes. diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index f75b3900..58147120 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -222,7 +222,7 @@ Joey Muia (@jmuia) `WRITE_DURATIONS_AS_TIMESTAMPS` enabled (2.19.0) -Henning Pöttker (@ hpoettker) +Henning Pöttker (@hpoettker) * Contributed #342: Lenient deserialization of `LocalDate` is not time-zone aware (2.19.0) @@ -230,3 +230,7 @@ Boleslav Bobcik (@bbobcik) * Reported, contributed fix for #364: Deserialization of Month in ONE_BASED_MONTHS mode fails for value "12" (2.19.0) + +Albert Lovers (@AlbertLovers) + * Reported, contributed fix for #381: Fix a potential problem in `JavaTimeModule._findFactory()` + (2.21.0) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 63ec26b5..863d16ad 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -17,8 +17,8 @@ Modules: #376: Allow specifying custom `DateTimeFormatter` for `OffsetDateTime` ser/deser (new constructors?) (requested by @ZIRAKrezovic) - -No changes since 2.20 +#381: Fix a potential problem in `JavaTimeModule._findFactory()` + (reported, fix by, Albert L) 2.20.1 (30-Oct-2025) 2.20.0 (28-Aug-2025) From 796595cb5ddc30cd7ca6bcd1adc77af0166baca1 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 18 Jan 2026 15:48:34 -0800 Subject: [PATCH 094/140] Prep for 2.21.0 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index eb4b8cd5..3c172fc4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.0-SNAPSHOT + 2.21.0 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 863d16ad..16f9cda0 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,7 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ -2.21.0 (not yet released) +2.21.0 (18-Jan-2026) #359: `InstantDeserializer` deserializes the nanosecond portion of fractional negative timestamps incorrectly From ee8346328a2ac58f2357d3ba4bd649e674a41556 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 18 Jan 2026 15:49:42 -0800 Subject: [PATCH 095/140] [maven-release-plugin] prepare release jackson-modules-java8-2.21.0 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index ddd1d958..a36d231b 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.0-SNAPSHOT + 2.21.0 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index b017e4d4..1a73468c 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.0-SNAPSHOT + 2.21.0 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 4da6acf9..c921070e 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.0-SNAPSHOT + 2.21.0 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 3c172fc4..dc318e0e 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.0-SNAPSHOT + 2.21.0 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.21.0 https://github.com/FasterXML/jackson-modules-java8/issues From dc6ff08d4b21835f769467e0a3ecd41423d21879 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 18 Jan 2026 15:49:44 -0800 Subject: [PATCH 096/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index a36d231b..e188f4cd 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.0 + 2.21.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1a73468c..2c572519 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.0 + 2.21.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index c921070e..9a213818 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.0 + 2.21.1-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index dc318e0e..a5f473ba 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.0 + 2.21.1-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.21.0 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 63f39fe92d700efbbf030b944789b9edeb22d9b9 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 18 Jan 2026 15:51:43 -0800 Subject: [PATCH 097/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a5f473ba..c6be8334 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.0 + 2.21.1-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 48739e69f50040cd96558f998c713480998feea9 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 18 Jan 2026 15:53:15 -0800 Subject: [PATCH 098/140] Start 2.21 branch; 2.x -> 2.22.0-SNAPSHOT --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index e188f4cd..906befdf 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1-SNAPSHOT + 2.22.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 2c572519..dfd63b4d 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1-SNAPSHOT + 2.22.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 9a213818..da2451eb 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1-SNAPSHOT + 2.22.0-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index c6be8334..5da83b3e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.21.1-SNAPSHOT + 2.22.0-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.1-SNAPSHOT + 2.22.0-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types From 39968d8f58743ad074d468e056a17221ea24ac46 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 19 Jan 2026 13:39:30 -0800 Subject: [PATCH 099/140] Prep for 2.20.2 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 025a68f4..1d0eb2b6 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.2-SNAPSHOT + 2.20.2 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 29ef8eb6..a4afc9e2 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.20.2 (19-Jan-2025) 2.20.1 (30-Oct-2025) 2.20.0 (28-Aug-2025) From b7facb91a49a869a8fd566b2604d91d79855ab41 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 19 Jan 2026 13:41:02 -0800 Subject: [PATCH 100/140] [maven-release-plugin] prepare release jackson-modules-java8-2.20.2 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 54b06b22..c01bc619 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.2-SNAPSHOT + 2.20.2 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1451adf2..e0f628fa 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.2-SNAPSHOT + 2.20.2 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index e07d6752..361d0a0c 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.2-SNAPSHOT + 2.20.2 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 1d0eb2b6..7bca19de 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.2-SNAPSHOT + 2.20.2 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.20.2 https://github.com/FasterXML/jackson-modules-java8/issues From 3f95f35d87def32b7643ccfff8b4551f280d6dde Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 19 Jan 2026 13:41:05 -0800 Subject: [PATCH 101/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index c01bc619..7005a0e2 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.2 + 2.20.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index e0f628fa..b00b21b4 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.2 + 2.20.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 361d0a0c..00566553 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.20.2 + 2.20.3-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 7bca19de..380ddcca 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.20.2 + 2.20.3-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.20.2 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 2f4cbbd32082ac826ba50d3892f26edf71f757f6 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 19 Jan 2026 13:43:07 -0800 Subject: [PATCH 102/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 380ddcca..1aac84eb 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.20.2 + 2.20.3-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From dba95462cbf44ad1a058b26b4b7f7a43cdd150b9 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 22 Feb 2026 17:48:23 -0800 Subject: [PATCH 103/140] Prep for 2.21.1 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6be8334..c0fb32a0 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.1-SNAPSHOT + 2.21.1 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 004926a8..f20bd253 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,10 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.21.1 (22-Feb-2026) + +No changes since 2.21.0 + 2.21.0 (18-Jan-2026) #359: `InstantDeserializer` deserializes the nanosecond portion of fractional From 7598d877e0072da6e67f33c73958f51f4f9fcaba Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 22 Feb 2026 17:52:40 -0800 Subject: [PATCH 104/140] [maven-release-plugin] prepare release jackson-modules-java8-2.21.1 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index e188f4cd..87ad00df 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1-SNAPSHOT + 2.21.1 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 2c572519..a079f857 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1-SNAPSHOT + 2.21.1 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 9a213818..e77b2165 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1-SNAPSHOT + 2.21.1 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index c0fb32a0..3033456c 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.1-SNAPSHOT + 2.21.1 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.21.1 https://github.com/FasterXML/jackson-modules-java8/issues From 286948d45dd58fed015f932aade32002a983df54 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 22 Feb 2026 17:52:43 -0800 Subject: [PATCH 105/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 87ad00df..992931eb 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1 + 2.21.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index a079f857..414bf04e 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1 + 2.21.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index e77b2165..f3c39fc3 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.1 + 2.21.2-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 3033456c..bbc2d036 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.1 + 2.21.2-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.21.1 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 1ea2856bc1b6757b9c246aa1c936568660f7640a Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 22 Feb 2026 17:54:27 -0800 Subject: [PATCH 106/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bbc2d036..306f312c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.1 + 2.21.2-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From f422597b4549e4a840ebefcefe4cddbe88dd95be Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 20 Mar 2026 10:08:16 -0700 Subject: [PATCH 107/140] Prep for 2.21.2 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 306f312c..4a47731d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.2-SNAPSHOT + 2.21.2 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index f20bd253..3881b848 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.21.2 (20-Mar-2026) 2.21.1 (22-Feb-2026) No changes since 2.21.0 From 6c06e553eb183215e1be4807088318debf409b5e Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 20 Mar 2026 10:09:49 -0700 Subject: [PATCH 108/140] [maven-release-plugin] prepare release jackson-modules-java8-2.21.2 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 992931eb..600b19b5 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.2-SNAPSHOT + 2.21.2 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 414bf04e..d2aefd1a 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.2-SNAPSHOT + 2.21.2 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index f3c39fc3..588502e4 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.2-SNAPSHOT + 2.21.2 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 4a47731d..a0747936 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.2-SNAPSHOT + 2.21.2 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.21.2 https://github.com/FasterXML/jackson-modules-java8/issues From 4b3f07efaa1c446ada43a8baff0455c3209f64f5 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 20 Mar 2026 10:09:51 -0700 Subject: [PATCH 109/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 600b19b5..19e1fe4e 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.2 + 2.21.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index d2aefd1a..05aafe10 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.2 + 2.21.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 588502e4..0d614458 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.2 + 2.21.3-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index a0747936..fdcbbd68 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.2 + 2.21.3-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.21.2 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 68677342def9bddf29ff037df060cac743c5b588 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 20 Mar 2026 10:12:02 -0700 Subject: [PATCH 110/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fdcbbd68..c64f7502 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.2 + 2.21.3-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 8a35d4ab6117149bd2b13dc621ea2f4961126f61 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 28 Apr 2026 13:27:47 -0700 Subject: [PATCH 111/140] Prep for 2.21.3 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c64f7502..dfef8c0d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.3-SNAPSHOT + 2.21.3 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index d83f1a43..03f1970a 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.21.3 (28-Apr-2026) 2.21.2 (20-Mar-2026) 2.21.1 (22-Feb-2026) From 962da84688808e4deba7eb322f61dd3177231504 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 28 Apr 2026 13:32:08 -0700 Subject: [PATCH 112/140] [maven-release-plugin] prepare release jackson-modules-java8-2.21.3 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 19e1fe4e..2c4975fe 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.3-SNAPSHOT + 2.21.3 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 05aafe10..1d704e8c 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.3-SNAPSHOT + 2.21.3 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 0d614458..827d07bf 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.3-SNAPSHOT + 2.21.3 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index dfef8c0d..b218b72c 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.3-SNAPSHOT + 2.21.3 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.21.3 https://github.com/FasterXML/jackson-modules-java8/issues From 097c6b0f2fdfadc7084f39f22127879bdd79c65e Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 28 Apr 2026 13:32:11 -0700 Subject: [PATCH 113/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 2c4975fe..f21d3279 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.3 + 2.21.4-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1d704e8c..c4cec898 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.3 + 2.21.4-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 827d07bf..bad6c339 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.3 + 2.21.4-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index b218b72c..47c72f66 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.3 + 2.21.4-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.21.3 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 684956395c3b66b2e00ceeb56c52aea25d4d5e25 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 28 Apr 2026 13:34:04 -0700 Subject: [PATCH 114/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47c72f66..70c47818 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.3 + 2.21.4-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 442b21432ac53b760de2534d1bb601b663bad94d Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 May 2026 21:37:02 -0700 Subject: [PATCH 115/140] Prep for 2.21.4 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70c47818..13078623 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.4-SNAPSHOT + 2.21.4 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index db4f7835..54a909f4 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.21.4 (28-May-2026) 2.21.3 (28-Apr-2026) 2.21.2 (20-Mar-2026) 2.21.1 (22-Feb-2026) From a64f041cd15c4884a076bc7691babbcdf27b0ff6 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 May 2026 21:37:34 -0700 Subject: [PATCH 116/140] [maven-release-plugin] prepare release jackson-modules-java8-2.21.4 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index f21d3279..0cefbbd4 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.4-SNAPSHOT + 2.21.4 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index c4cec898..e93bcda5 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.4-SNAPSHOT + 2.21.4 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index bad6c339..74945ae1 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.4-SNAPSHOT + 2.21.4 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 13078623..685ec9f7 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.4-SNAPSHOT + 2.21.4 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.21.4 https://github.com/FasterXML/jackson-modules-java8/issues From 33f9ec77250a03b1d4e1114eae2e14f2d36e22d3 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 May 2026 21:37:38 -0700 Subject: [PATCH 117/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 0cefbbd4..d7665e71 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.4 + 2.21.5-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index e93bcda5..1104213e 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.4 + 2.21.5-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 74945ae1..7552ce91 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.4 + 2.21.5-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 685ec9f7..0d5eab22 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.4 + 2.21.5-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.21.4 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From ee732b8264270ccee3454bce9f5871f8099ab15a Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 May 2026 21:38:58 -0700 Subject: [PATCH 118/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0d5eab22..b2893507 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.4 + 2.21.5-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 1cb9ada8bb835adaa43e38ea1163301ac0a64347 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 31 May 2026 18:54:15 -0700 Subject: [PATCH 119/140] Prep for 2.22.0 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5da83b3e..1a1186b1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.22.0-SNAPSHOT + 2.22.0 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 54a909f4..a5b49cf0 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,14 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.23.0 (not yet released) + +No changes since 2.22 + +2.22.0 (31-May-2026) + +No changes since 2.21 + 2.21.4 (28-May-2026) 2.21.3 (28-Apr-2026) 2.21.2 (20-Mar-2026) From dccbb35aff5ba4c72d64f26ebfe57a8acb6c2f71 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 31 May 2026 18:54:51 -0700 Subject: [PATCH 120/140] [maven-release-plugin] prepare release jackson-modules-java8-2.22.0 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 906befdf..408ea8be 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.0-SNAPSHOT + 2.22.0 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index dfd63b4d..86324ef7 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.0-SNAPSHOT + 2.22.0 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index da2451eb..a39c8bd9 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.0-SNAPSHOT + 2.22.0 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 1a1186b1..8c4702ac 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.22.0-SNAPSHOT + 2.22.0 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.22.0 https://github.com/FasterXML/jackson-modules-java8/issues From 3ffc8da89f14046c64ef80fdaa2c942661a84d6f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 31 May 2026 18:54:55 -0700 Subject: [PATCH 121/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 408ea8be..b5c1a232 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.0 + 2.22.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 86324ef7..08133733 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.0 + 2.22.1-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index a39c8bd9..dd687a5e 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.0 + 2.22.1-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 8c4702ac..dbae2ff2 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.22.0 + 2.22.1-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.22.0 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 31f08f080a269fe2b87725cca39c09d25e1ff200 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 31 May 2026 18:56:09 -0700 Subject: [PATCH 122/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbae2ff2..67ef3854 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.22.0 + 2.22.1-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From bd086c0aae6cfe3357868af6a469ce539a12ea2d Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 31 May 2026 18:56:48 -0700 Subject: [PATCH 123/140] 2.x -> 2.23 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index b5c1a232..c1c67e2c 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1-SNAPSHOT + 2.23.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 08133733..2790b394 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1-SNAPSHOT + 2.23.0-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index dd687a5e..7a5baf8b 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1-SNAPSHOT + 2.23.0-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 67ef3854..209fb36d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ com.fasterxml.jackson jackson-base - 2.22.1-SNAPSHOT + 2.23.0-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.22.1-SNAPSHOT + 2.23.0-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types From 3e64baa1a4c4f18cd24f4ae9ad67eee555dd95fc Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 6 Jul 2026 19:32:22 -0700 Subject: [PATCH 124/140] Prep for 2.21.5 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b2893507..dd9ed4e2 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.5-SNAPSHOT + 2.21.5 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 54a909f4..edbbc672 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.21.5 (06-Jul-2026) 2.21.4 (28-May-2026) 2.21.3 (28-Apr-2026) 2.21.2 (20-Mar-2026) From e9562cd82c0a0d7ab322b6108954ed9124f295ed Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 6 Jul 2026 19:33:00 -0700 Subject: [PATCH 125/140] [maven-release-plugin] prepare release jackson-modules-java8-2.21.5 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index d7665e71..702a1d8d 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.5-SNAPSHOT + 2.21.5 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1104213e..1de9b2f3 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.5-SNAPSHOT + 2.21.5 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 7552ce91..28ffc398 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.5-SNAPSHOT + 2.21.5 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index dd9ed4e2..378f6f49 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.5-SNAPSHOT + 2.21.5 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.21.5 https://github.com/FasterXML/jackson-modules-java8/issues From 1c28bd3ead52f7c102106f6c85823e926c8abefe Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 6 Jul 2026 19:33:04 -0700 Subject: [PATCH 126/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 702a1d8d..d425b393 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.5 + 2.21.6-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1de9b2f3..7cb70e08 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.5 + 2.21.6-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 28ffc398..97903afa 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.5 + 2.21.6-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 378f6f49..fe40a0e4 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.5 + 2.21.6-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.21.5 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From fd4df1a1ba0f7afac0838ac54b2dd07218a57c2e Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 6 Jul 2026 19:35:09 -0700 Subject: [PATCH 127/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fe40a0e4..cf15137e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.5 + 2.21.6-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 7b6c6bd79362090a61c07d6ecb6390ffa5749609 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 7 Jul 2026 15:08:57 -0700 Subject: [PATCH 128/140] Prep for 2.22.1 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 67ef3854..d79caa7c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.22.1-SNAPSHOT + 2.22.1 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 0b6393f4..fa7849ab 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -12,6 +12,7 @@ Modules: No changes since 2.22 +2.22.1 (07-Jul-2026) 2.22.0 (31-May-2026) No changes since 2.21 From 8935c2688ec64c4a56b09cdede2c3876be38c8b5 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 7 Jul 2026 15:10:23 -0700 Subject: [PATCH 129/140] [maven-release-plugin] prepare release jackson-modules-java8-2.22.1 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index b5c1a232..24ab28f0 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1-SNAPSHOT + 2.22.1 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 08133733..1424f605 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1-SNAPSHOT + 2.22.1 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index dd687a5e..a0a3529a 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1-SNAPSHOT + 2.22.1 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index d79caa7c..78b3f431 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.22.1-SNAPSHOT + 2.22.1 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.22.1 https://github.com/FasterXML/jackson-modules-java8/issues From eb3ae821c39804c56af7fe6140917fdcbb1bba4b Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 7 Jul 2026 15:10:27 -0700 Subject: [PATCH 130/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 24ab28f0..0708329f 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1 + 2.22.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 1424f605..f77ace6e 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1 + 2.22.2-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index a0a3529a..b24787e4 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.1 + 2.22.2-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 78b3f431..94dd9d94 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.22.1 + 2.22.2-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.22.1 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 076f9a0feb57dea8d362320cc4a3f64924d11af9 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 7 Jul 2026 15:25:22 -0700 Subject: [PATCH 131/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 94dd9d94..07875fc0 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.22.1 + 2.22.2-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 261d6fc76b074bd57d2913a5bc1247fe66992c5b Mon Sep 17 00:00:00 2001 From: seonwoojung Date: Tue, 11 Aug 2026 10:55:48 +0900 Subject: [PATCH 132/140] Add `JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS` (#76) (#386) --- .../datatype/jsr310/JavaTimeFeature.java | 35 ++- .../datatype/jsr310/JavaTimeModule.java | 8 +- .../deser/JSR310DateTimeDeserializerBase.java | 2 +- .../jsr310/ser/InstantSerializer.java | 66 ++++++ .../jsr310/ser/InstantSerializerBase.java | 20 +- .../ser/JSR310FormattedSerializerBase.java | 44 +++- .../jsr310/ser/LocalDateTimeSerializer.java | 28 ++- .../jsr310/ser/OffsetDateTimeSerializer.java | 24 +++ .../jsr310/ser/SubSecondFormatters.java | 91 ++++++++ .../jsr310/ser/ZonedDateTimeSerializer.java | 53 ++++- .../ser/AlwaysWriteSubSecondDigits76Test.java | 203 ++++++++++++++++++ release-notes/CREDITS-2.x | 9 + release-notes/VERSION-2.x | 5 +- 13 files changed, 569 insertions(+), 19 deletions(-) create mode 100644 datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/SubSecondFormatters.java create mode 100644 datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/AlwaysWriteSubSecondDigits76Test.java diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeFeature.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeFeature.java index b509af6e..36bebe27 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeFeature.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeFeature.java @@ -51,7 +51,40 @@ public enum JavaTimeFeature implements JacksonFeature *

* Default setting is false, meaning that Month is serialized/deserialized as a zero-based index. */ - ONE_BASED_MONTHS(false) + ONE_BASED_MONTHS(false), + + /** + * Feature that determines whether sub-second digits are always written when + * serializing {@link java.time.Instant}, {@link java.time.OffsetDateTime}, + * {@link java.time.ZonedDateTime} and {@link java.time.LocalDateTime} values + * as ISO-8601 Strings using the default format. + *

+ * When disabled (the default), the JDK-provided ISO formatters are used and + * a zero sub-second value is omitted altogether -- {@code 2017-09-14T04:28:48Z} + * -- which means that output width varies with the value, breaking systems + * that expect fixed-precision timestamps (or that sort timestamps as text). + *

+ * When enabled, at least 3 (millisecond) sub-second digits are always written, + * zero-padded if necessary -- {@code 2017-09-14T04:28:48.000Z}. Higher precision + * is preserved: a value with microsecond or nanosecond precision is written with + * 6 or 9 digits respectively, so no information is lost. + *

+ * Only affects the default format: an explicit {@code DateTimeFormatter} or + * a {@link com.fasterxml.jackson.annotation.JsonFormat} pattern takes precedence, + * as does writing values as numeric timestamps. + *

+ * Also note that this only applies to values, and NOT to {@link java.util.Map} + * keys: date/time keys keep being written using the JDK-provided ISO formatters, + * so a zero sub-second value is still omitted there. Types other than the four + * listed above -- notably {@link java.time.LocalTime} and + * {@link java.time.OffsetTime}, whose ISO formats also omit the seconds field -- + * are likewise unaffected. + *

+ * Default setting is disabled, for backwards compatibility. + * + * @since 2.23 + */ + ALWAYS_WRITE_SUBSECOND_DIGITS(false) ; /** diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java index ae953380..80ede099 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java @@ -157,12 +157,12 @@ public void setupModule(SetupContext context) { JavaTimeSerializers sers = new JavaTimeSerializers(); sers.addSerializer(Duration.class, DurationSerializer.INSTANCE); - sers.addSerializer(Instant.class, InstantSerializer.INSTANCE); - sers.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE); + sers.addSerializer(Instant.class, InstantSerializer.INSTANCE.withFeatures(_features)); + sers.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE.withFeatures(_features)); sers.addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE); sers.addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE); sers.addSerializer(MonthDay.class, MonthDaySerializer.INSTANCE); - sers.addSerializer(OffsetDateTime.class, OffsetDateTimeSerializer.INSTANCE); + sers.addSerializer(OffsetDateTime.class, OffsetDateTimeSerializer.INSTANCE.withFeatures(_features)); sers.addSerializer(OffsetTime.class, OffsetTimeSerializer.INSTANCE); sers.addSerializer(Period.class, new ToStringSerializer(Period.class)); sers.addSerializer(Year.class, YearSerializer.INSTANCE); @@ -173,7 +173,7 @@ public void setupModule(SetupContext context) { * serialization with timezone offset only, not timezone id. * But this is configurable. */ - sers.addSerializer(ZonedDateTime.class, ZonedDateTimeSerializer.INSTANCE); + sers.addSerializer(ZonedDateTime.class, ZonedDateTimeSerializer.INSTANCE.withFeatures(_features)); // since 2.11: need to override Type Id handling // (actual concrete type is `ZoneRegion`, but that's not visible) diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DateTimeDeserializerBase.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DateTimeDeserializerBase.java index 8ec7efba..68e42954 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DateTimeDeserializerBase.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DateTimeDeserializerBase.java @@ -27,7 +27,7 @@ public abstract class JSR310DateTimeDeserializerBase protected final DateTimeFormatter _formatter; /** - * Setting that indicates the {@Link JsonFormat.Shape} specified for this deserializer + * Setting that indicates the {@link JsonFormat.Shape} specified for this deserializer * as a {@link com.fasterxml.jackson.annotation.JsonFormat.Shape} annotation on * property or class, or due to per-type "config override", or from global settings: * If Shape is NUMBER_INT, the input value is considered to be epoch days. If not a diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializer.java index 0ed65bcd..0340d177 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializer.java @@ -22,6 +22,10 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import com.fasterxml.jackson.core.util.JacksonFeatureSet; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; + /** * Serializer for Java 8 temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. * @@ -34,10 +38,20 @@ public class InstantSerializer extends InstantSerializerBase public static final InstantSerializer INSTANCE = new InstantSerializer(); + /** + * Whether {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS} + * is enabled: if so, the default representation is padded to at least 3 sub-second + * digits. + * + * @since 2.23 + */ + private final boolean _alwaysWriteSubsecondDigits; + protected InstantSerializer() { super(Instant.class, Instant::toEpochMilli, Instant::getEpochSecond, Instant::getNano, // null -> use 'value.toString()', default format null); + _alwaysWriteSubsecondDigits = false; } @Deprecated // since 2.14 @@ -52,11 +66,63 @@ protected InstantSerializer(InstantSerializer base, protected InstantSerializer(InstantSerializer base, Boolean useTimestamp, DateTimeFormatter formatter, JsonFormat.Shape shape) { super(base, useTimestamp, base._useNanoseconds, formatter, shape); + _alwaysWriteSubsecondDigits = base._alwaysWriteSubsecondDigits; } protected InstantSerializer(InstantSerializer base, Boolean useTimestamp, Boolean useNanoseconds, DateTimeFormatter formatter) { super(base, useTimestamp, useNanoseconds, formatter); + _alwaysWriteSubsecondDigits = base._alwaysWriteSubsecondDigits; + } + + /** + * @since 2.23 + */ + protected InstantSerializer(InstantSerializer base, boolean alwaysWriteSubsecondDigits) { + super(base, base._useTimestamp, base._useNanoseconds, base._formatter, base._shape); + _alwaysWriteSubsecondDigits = alwaysWriteSubsecondDigits; + } + + /** + * Method called by {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeModule} + * to apply module-level {@link JavaTimeFeature} settings. + * + * @since 2.23 + */ + public InstantSerializer withFeatures(JacksonFeatureSet features) { + if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) { + return new InstantSerializer(this, true); + } + return this; + } + + /** + * Overridden to implement + * {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS} + * by padding the default representation, instead of swapping in a different formatter. + *

+ * Rationale: the default representation is {@link Instant#toString()}, that is, + * {@link DateTimeFormatter#ISO_INSTANT}, which writes exactly 0, 3, 6 or 9 sub-second + * digits -- so the only case needing a fix is the zero one. Formatting through a + * zone-bound {@code DateTimeFormatter} instead would resolve the value via + * {@link java.time.LocalDateTime}, whose year range is narrower than that of + * {@code Instant}, and would thereby fail for {@link Instant#MIN} / {@link Instant#MAX}. + * + * @since 2.23 + */ + @Override + protected String formatValue(Instant value, SerializerProvider provider) + { + String formatted = super.formatValue(value, provider); + // Only applies to the default representation: an explicit formatter wins + if (_alwaysWriteSubsecondDigits && (_formatter == null) && (value.getNano() == 0)) { + final int last = formatted.length() - 1; + // Defensive: `ISO_INSTANT` always ends in 'Z', but do not corrupt output if not + if ((last >= 0) && (formatted.charAt(last) == 'Z')) { + formatted = formatted.substring(0, last) + ".000Z"; + } + } + return formatted; } @Override diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java index 1305a1c2..81c3ebd8 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java @@ -47,8 +47,6 @@ public abstract class InstantSerializerBase extends JSR310FormattedSerializerBase { - private final DateTimeFormatter defaultFormat; - private final ToLongFunction getEpochMillis; private final ToLongFunction getEpochSeconds; @@ -61,8 +59,7 @@ protected InstantSerializerBase(Class supportedType, ToLongFunction getEpo { // Bit complicated, just because we actually want to "hide" default formatter, // so that it won't accidentally force use of textual presentation - super(supportedType, null); - this.defaultFormat = defaultFormat; + super(supportedType, null, defaultFormat); this.getEpochMillis = getEpochMillis; this.getEpochSeconds = getEpochSeconds; this.getNanoseconds = getNanoseconds; @@ -86,7 +83,18 @@ protected InstantSerializerBase(InstantSerializerBase base, protected InstantSerializerBase(InstantSerializerBase base, Boolean useTimestamp, Boolean useNanoseconds, DateTimeFormatter dtf, JsonFormat.Shape shape) { super(base, useTimestamp, useNanoseconds, dtf, shape); - defaultFormat = base.defaultFormat; + getEpochMillis = base.getEpochMillis; + getEpochSeconds = base.getEpochSeconds; + getNanoseconds = base.getNanoseconds; + } + + /** + * @since 2.23 + */ + protected InstantSerializerBase(InstantSerializerBase base, + DateTimeFormatter defaultFormat) + { + super(base, defaultFormat); getEpochMillis = base.getEpochMillis; getEpochSeconds = base.getEpochSeconds; getNanoseconds = base.getNanoseconds; @@ -147,7 +155,7 @@ protected JsonToken serializationShape(SerializerProvider provider) { // @since 2.12 protected String formatValue(T value, SerializerProvider provider) { - DateTimeFormatter formatter = (_formatter == null) ? defaultFormat :_formatter; + DateTimeFormatter formatter = (_formatter == null) ? _defaultFormat :_formatter; if (formatter != null) { if (formatter.getZone() == null) { // timezone set if annotated on property // If the user specified to use the context TimeZone explicitly, and the formatter provided doesn't contain a TZ diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/JSR310FormattedSerializerBase.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/JSR310FormattedSerializerBase.java index 0b465f95..b17bd3f3 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/JSR310FormattedSerializerBase.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/JSR310FormattedSerializerBase.java @@ -65,6 +65,18 @@ abstract class JSR310FormattedSerializerBase */ protected final DateTimeFormatter _formatter; + /** + * Format to use when no explicit {@link #_formatter} is configured. Unlike + * {@code _formatter}, a non-null value here does NOT force serialization as a + * JSON String -- which is exactly why the two cannot be collapsed into one. + *

+ * May be {@code null}, in which case the sub-class decides the fallback + * (typically either a JDK {@code ISO_*} constant or {@code value.toString()}). + * + * @since 2.23 + */ + protected final DateTimeFormatter _defaultFormat; + protected final JsonFormat.Shape _shape; /** @@ -81,13 +93,22 @@ protected JSR310FormattedSerializerBase(Class supportedType) { protected JSR310FormattedSerializerBase(Class supportedType, DateTimeFormatter formatter) { + this(supportedType, formatter, null); + } + + /** + * @since 2.23 + */ + protected JSR310FormattedSerializerBase(Class supportedType, + DateTimeFormatter formatter, DateTimeFormatter defaultFormat) { super(supportedType); _useTimestamp = null; _useNanoseconds = null; _shape = null; _formatter = formatter; + _defaultFormat = defaultFormat; } - + protected JSR310FormattedSerializerBase(JSR310FormattedSerializerBase base, Boolean useTimestamp, DateTimeFormatter dtf, JsonFormat.Shape shape) { @@ -103,6 +124,27 @@ protected JSR310FormattedSerializerBase(JSR310FormattedSerializerBase base, _useNanoseconds = useNanoseconds; _formatter = dtf; _shape = shape; + _defaultFormat = base._defaultFormat; + } + + /** + * Copy-constructor used for replacing the default format -- and only that -- + * of an existing serializer; needed for + * {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS}. + * Note that the replacement must NOT be passed as {@code _formatter}, since a + * non-null {@code _formatter} also forces serialization as a JSON String. + * + * @since 2.23 + */ + protected JSR310FormattedSerializerBase(JSR310FormattedSerializerBase base, + DateTimeFormatter defaultFormat) + { + super(base.handledType()); + _useTimestamp = base._useTimestamp; + _useNanoseconds = base._useNanoseconds; + _formatter = base._formatter; + _shape = base._shape; + _defaultFormat = defaultFormat; } protected abstract JSR310FormattedSerializerBase withFormat(Boolean useTimestamp, diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerializer.java index 4383a36a..f22bbf9d 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/LocalDateTimeSerializer.java @@ -25,8 +25,10 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.WritableTypeId; +import com.fasterxml.jackson.core.util.JacksonFeatureSet; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; /** * Serializer for Java 8 temporal {@link LocalDateTime}s. @@ -39,13 +41,13 @@ public class LocalDateTimeSerializer extends JSR310FormattedSerializerBase features) { + if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) { + return new LocalDateTimeSerializer(this, SubSecondFormatters.LOCAL_DATE_TIME); + } + return this; + } + @Override protected JSR310FormattedSerializerBase withFormat(Boolean useTimestamp, DateTimeFormatter f, JsonFormat.Shape shape) { return new LocalDateTimeSerializer(this, useTimestamp, _useNanoseconds, f); } protected DateTimeFormatter _defaultFormatter() { - return DateTimeFormatter.ISO_LOCAL_DATE_TIME; + return _defaultFormat; } @Override diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java index 1a961c8d..7bdd0e9c 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/OffsetDateTimeSerializer.java @@ -4,6 +4,9 @@ import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; +import com.fasterxml.jackson.core.util.JacksonFeatureSet; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; + public class OffsetDateTimeSerializer extends InstantSerializerBase { private static final long serialVersionUID = 1L; @@ -35,6 +38,27 @@ public OffsetDateTimeSerializer(OffsetDateTimeSerializer base, Boolean useTimest super(base, useTimestamp, base._useNanoseconds, formatter, shape); } + /** + * @since 2.23 + */ + protected OffsetDateTimeSerializer(OffsetDateTimeSerializer base, + DateTimeFormatter defaultFormat) { + super(base, defaultFormat); + } + + /** + * Method called by {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeModule} + * to apply module-level {@link JavaTimeFeature} settings. + * + * @since 2.23 + */ + public OffsetDateTimeSerializer withFeatures(JacksonFeatureSet features) { + if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) { + return new OffsetDateTimeSerializer(this, SubSecondFormatters.OFFSET_DATE_TIME); + } + return this; + } + /** * Method for constructing a new {@code OffsetDateTimeSerializer} with settings * of this serializer but with custom {@link DateTimeFormatter} overrides. diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/SubSecondFormatters.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/SubSecondFormatters.java new file mode 100644 index 00000000..825bf845 --- /dev/null +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/SubSecondFormatters.java @@ -0,0 +1,91 @@ +package com.fasterxml.jackson.datatype.jsr310.ser; + +import java.time.chrono.IsoChronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.ResolverStyle; +import java.time.temporal.ChronoField; + +/** + * Container for the ISO-8601 {@link DateTimeFormatter}s used in place of the + * JDK-provided defaults when + * {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS} + * is enabled. + *

+ * These differ from the JDK counterparts only in the sub-second field: instead of + * omitting it when zero, at least 3 (millisecond) digits are always written, and up + * to 9 when the value carries higher precision (so nothing is truncated). They are + * otherwise built the same way -- including {@link ResolverStyle#STRICT} and the ISO + * chronology -- so that they remain drop-in replacements even though they are only + * ever used for printing here. + *

+ * Note that there is deliberately no counterpart of {@link DateTimeFormatter#ISO_INSTANT} + * here: formatting an {@link java.time.Instant} through a zone-bound formatter goes via + * {@link java.time.LocalDateTime}, whose year range is narrower than {@code Instant}'s, + * so {@link java.time.Instant#MIN} / {@link java.time.Instant#MAX} would fail. See + * {@link InstantSerializer#formatValue} for the handling used instead. + * + * @since 2.23 + */ +class SubSecondFormatters +{ + private SubSecondFormatters() { } + + /** + * Date and time down to the seconds field, followed by 3 to 9 sub-second digits: + * the shared prefix of all formatters here. + */ + private static DateTimeFormatterBuilder _localDateTimeBuilder() { + return new DateTimeFormatterBuilder() + .append(DateTimeFormatter.ISO_LOCAL_DATE) + .appendLiteral('T') + .appendValue(ChronoField.HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(ChronoField.MINUTE_OF_HOUR, 2) + .appendLiteral(':') + .appendValue(ChronoField.SECOND_OF_MINUTE, 2) + .appendFraction(ChronoField.NANO_OF_SECOND, 3, 9, true); + } + + /** + * {@link #_localDateTimeBuilder()} followed by the offset: the shared prefix of the + * offset- and zone-based formatters. + */ + private static DateTimeFormatterBuilder _offsetDateTimeBuilder() { + return _localDateTimeBuilder().appendOffsetId(); + } + + /** + * Completes a builder the way the JDK completes its own {@code ISO_*} constants. + *

+ * Note that {@link DateTimeFormatterBuilder#toFormatter()} alone would yield + * {@link ResolverStyle#SMART} and no chronology, which is not what the constants + * these replace do. + */ + private static DateTimeFormatter _isoFormatter(DateTimeFormatterBuilder b) { + return b.toFormatter() + .withResolverStyle(ResolverStyle.STRICT) + .withChronology(IsoChronology.INSTANCE); + } + + /** + * Counterpart of {@link DateTimeFormatter#ISO_LOCAL_DATE_TIME}. + */ + final static DateTimeFormatter LOCAL_DATE_TIME = _isoFormatter(_localDateTimeBuilder()); + + /** + * Counterpart of {@link DateTimeFormatter#ISO_OFFSET_DATE_TIME}. + */ + final static DateTimeFormatter OFFSET_DATE_TIME = _isoFormatter(_offsetDateTimeBuilder()); + + /** + * Counterpart of {@link DateTimeFormatter#ISO_ZONED_DATE_TIME}, that is, + * {@link #OFFSET_DATE_TIME} with the optional {@code [Zone/Id]} suffix. + */ + final static DateTimeFormatter ZONED_DATE_TIME = _isoFormatter(_offsetDateTimeBuilder() + .optionalStart() + .appendLiteral('[') + .parseCaseSensitive() + .appendZoneRegionId() + .appendLiteral(']')); +} diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerializer.java index f84f950b..58d0817c 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/ZonedDateTimeSerializer.java @@ -7,8 +7,10 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.util.JacksonFeatureSet; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; public class ZonedDateTimeSerializer extends InstantSerializerBase { private static final long serialVersionUID = 1L; @@ -21,7 +23,21 @@ public class ZonedDateTimeSerializer extends InstantSerializerBase + * Separate from the inherited {@code _defaultFormat} on purpose: writing with the + * zone id is a second output shape that has always used {@code ISO_ZONED_DATE_TIME} + * regardless of the default format (including a custom one passed to + * {@link #ZonedDateTimeSerializer(DateTimeFormatter)}), so the two cannot be + * collapsed without changing existing behaviour. + * + * @since 2.23 + */ + protected final DateTimeFormatter _zoneIdFormat; + protected ZonedDateTimeSerializer() { // ISO_ZONED_DATE_TIME is an extended version of ISO compliant format // ISO_OFFSET_DATE_TIME with additional information :Zone Id @@ -34,6 +50,7 @@ public ZonedDateTimeSerializer(DateTimeFormatter formatter) { ZonedDateTime::toEpochSecond, ZonedDateTime::getNano, formatter); _writeZoneId = null; + _zoneIdFormat = null; } protected ZonedDateTimeSerializer(ZonedDateTimeSerializer base, @@ -56,6 +73,31 @@ protected ZonedDateTimeSerializer(ZonedDateTimeSerializer base, JsonFormat.Shape shape, Boolean writeZoneId) { super(base, useTimestamp, useNanoseconds, formatter, shape); _writeZoneId = writeZoneId; + _zoneIdFormat = base._zoneIdFormat; + } + + /** + * @since 2.23 + */ + protected ZonedDateTimeSerializer(ZonedDateTimeSerializer base, + DateTimeFormatter defaultFormat, DateTimeFormatter zoneIdFormat) { + super(base, defaultFormat); + _writeZoneId = base._writeZoneId; + _zoneIdFormat = zoneIdFormat; + } + + /** + * Method called by {@link com.fasterxml.jackson.datatype.jsr310.JavaTimeModule} + * to apply module-level {@link JavaTimeFeature} settings. + * + * @since 2.23 + */ + public ZonedDateTimeSerializer withFeatures(JacksonFeatureSet features) { + if (features.isEnabled(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)) { + return new ZonedDateTimeSerializer(this, + SubSecondFormatters.OFFSET_DATE_TIME, SubSecondFormatters.ZONED_DATE_TIME); + } + return this; } @Override @@ -89,7 +131,7 @@ public void serialize(ZonedDateTime value, JsonGenerator g, SerializerProvider p ; // use default handling } else if (shouldWriteWithZoneId(provider)) { // write with zone - g.writeString(DateTimeFormatter.ISO_ZONED_DATE_TIME.format(value)); + g.writeString(_zoneIdFormatter().format(value)); return; } } @@ -110,6 +152,13 @@ protected String formatValue(ZonedDateTime value, SerializerProvider provider) { return formatted; } + /** + * @since 2.23 + */ + protected DateTimeFormatter _zoneIdFormatter() { + return (_zoneIdFormat == null) ? DateTimeFormatter.ISO_ZONED_DATE_TIME : _zoneIdFormat; + } + /** * @since 2.8 */ diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/AlwaysWriteSubSecondDigits76Test.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/AlwaysWriteSubSecondDigits76Test.java new file mode 100644 index 00000000..4ecd5698 --- /dev/null +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ser/AlwaysWriteSubSecondDigits76Test.java @@ -0,0 +1,203 @@ +package com.fasterxml.jackson.datatype.jsr310.ser; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Locale; + +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for [modules-java8#76]: {@link JavaTimeFeature#ALWAYS_WRITE_SUBSECOND_DIGITS}. + */ +public class AlwaysWriteSubSecondDigits76Test extends ModuleTestBase +{ + static class Wrapper { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") + public OffsetDateTime value; + + Wrapper(OffsetDateTime v) { value = v; } + } + + static class ShapeOnlyWrapper { + @JsonFormat(shape = JsonFormat.Shape.STRING) + public Instant value; + + ShapeOnlyWrapper(Instant v) { value = v; } + } + + // NOTE: cannot use `ModuleTestBase.mapperBuilder()` here, since it already registers a + // plain `JavaTimeModule` and duplicate registrations of the same module are ignored + private static JsonMapper.Builder builderWithFeature() { + return JsonMapper.builder() + .defaultLocale(Locale.ENGLISH) + .addModule(new JavaTimeModule() + .enable(JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS)); + } + + private final ObjectMapper MAPPER = builderWithFeature() + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + + private final ObjectMapper DEFAULT_MAPPER = mapperBuilder() + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + + @Test + public void testInstantZeroSubSecond() throws Exception + { + Instant value = Instant.parse("2017-09-14T04:28:48Z"); + // Default: sub-second field omitted entirely + assertEquals(q("2017-09-14T04:28:48Z"), DEFAULT_MAPPER.writeValueAsString(value)); + // Enabled: zero-padded to millisecond precision + assertEquals(q("2017-09-14T04:28:48.000Z"), MAPPER.writeValueAsString(value)); + } + + @Test + public void testInstantHigherPrecisionNotTruncated() throws Exception + { + assertEquals(q("2017-09-14T04:28:48.100Z"), + MAPPER.writeValueAsString(Instant.parse("2017-09-14T04:28:48.100Z"))); + assertEquals(q("2017-09-14T04:28:48.123456Z"), + MAPPER.writeValueAsString(Instant.parse("2017-09-14T04:28:48.123456Z"))); + assertEquals(q("2017-09-14T04:28:48.123456789Z"), + MAPPER.writeValueAsString(Instant.parse("2017-09-14T04:28:48.123456789Z"))); + } + + @Test + public void testOffsetDateTime() throws Exception + { + OffsetDateTime value = OffsetDateTime.parse("2017-09-14T04:28:48+02:00"); + assertEquals(q("2017-09-14T04:28:48+02:00"), DEFAULT_MAPPER.writeValueAsString(value)); + assertEquals(q("2017-09-14T04:28:48.000+02:00"), MAPPER.writeValueAsString(value)); + + // Note: the JDK ISO formatter renders 100 msec as ".1"; with the feature on, + // width is stable at (at least) 3 digits + OffsetDateTime millis = OffsetDateTime.parse("2017-09-14T04:28:48.100+02:00"); + assertEquals(q("2017-09-14T04:28:48.1+02:00"), DEFAULT_MAPPER.writeValueAsString(millis)); + assertEquals(q("2017-09-14T04:28:48.100+02:00"), MAPPER.writeValueAsString(millis)); + } + + @Test + public void testZonedDateTime() throws Exception + { + ZonedDateTime value = ZonedDateTime.parse("2017-09-14T04:28:48+02:00[Europe/Budapest]"); + assertEquals(q("2017-09-14T04:28:48.000+02:00"), MAPPER.writeValueAsString(value)); + } + + @Test + public void testZonedDateTimeWithZoneId() throws Exception + { + ObjectMapper mapper = builderWithFeature() + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) + .build(); + ZonedDateTime value = ZonedDateTime.parse("2017-09-14T04:28:48+02:00[Europe/Budapest]"); + assertEquals(q("2017-09-14T04:28:48.000+02:00[Europe/Budapest]"), + mapper.writeValueAsString(value)); + } + + @Test + public void testLocalDateTime() throws Exception + { + LocalDateTime value = LocalDateTime.parse("2017-09-14T04:28:48"); + assertEquals(q("2017-09-14T04:28:48"), DEFAULT_MAPPER.writeValueAsString(value)); + assertEquals(q("2017-09-14T04:28:48.000"), MAPPER.writeValueAsString(value)); + + // Seconds keep being written even when zero (as with the JDK ISO formatter) + LocalDateTime noSeconds = LocalDateTime.parse("2017-09-14T04:28"); + assertEquals(q("2017-09-14T04:28:00"), DEFAULT_MAPPER.writeValueAsString(noSeconds)); + assertEquals(q("2017-09-14T04:28:00.000"), MAPPER.writeValueAsString(noSeconds)); + } + + // Feature must not leak into numeric timestamp serialization + @Test + public void testTimestampsUnaffected() throws Exception + { + ObjectMapper mapper = builderWithFeature() + .enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + assertEquals("1505363328.000000000", + mapper.writeValueAsString(Instant.parse("2017-09-14T04:28:48Z"))); + } + + // ... nor override an explicit `@JsonFormat` pattern + @Test + public void testExplicitPatternWins() throws Exception + { + assertEquals(a2q("{'value':'2017-09-14T04:28:48'}"), + MAPPER.writeValueAsString(new Wrapper(OffsetDateTime.parse("2017-09-14T04:28:48Z")))); + } + + // Values written with the feature on must still be readable + @Test + public void testRoundTrip() throws Exception + { + for (String raw : new String[] { + "2017-09-14T04:28:48Z", "2017-09-14T04:28:48.123456789Z", + "1970-01-01T00:00:00Z", "+10000-09-14T04:28:48Z", "-0100-09-14T04:28:48Z" }) { + Instant value = Instant.parse(raw); + String json = MAPPER.writeValueAsString(value); + assertEquals(value, MAPPER.readValue(json, Instant.class), + "Round-trip failed for " + raw + " (serialized as " + json + ")"); + } + } + + // The full `Instant` range must keep working: it is wider than that of + // `LocalDateTime`, so the feature must not route `Instant` through a + // zone-bound formatter + @Test + public void testInstantMinMax() throws Exception + { + // no sub-second part -> padded + assertEquals(q("-1000000000-01-01T00:00:00Z"), + DEFAULT_MAPPER.writeValueAsString(Instant.MIN)); + assertEquals(q("-1000000000-01-01T00:00:00.000Z"), + MAPPER.writeValueAsString(Instant.MIN)); + + // already at nanosecond precision -> unchanged + assertEquals(q("+1000000000-12-31T23:59:59.999999999Z"), + DEFAULT_MAPPER.writeValueAsString(Instant.MAX)); + assertEquals(q("+1000000000-12-31T23:59:59.999999999Z"), + MAPPER.writeValueAsString(Instant.MAX)); + + // and just inside the `LocalDateTime` boundary, either side + assertEquals(q("-999999999-01-01T00:00:00.000Z"), + MAPPER.writeValueAsString(LocalDateTime.MIN.toInstant(ZoneOffset.UTC))); + assertEquals(q("-1000000000-12-31T23:59:59.000Z"), + MAPPER.writeValueAsString(LocalDateTime.MIN.toInstant(ZoneOffset.UTC).minusSeconds(1))); + } + + // `Instant.toString()` writes 0, 3, 6 or 9 sub-second digits; only the + // zero case may be rewritten, the rest must be passed through untouched + @Test + public void testInstantSubSecondWidthsPreserved() throws Exception + { + assertEquals(q("1970-01-01T00:00:00.000000001Z"), + MAPPER.writeValueAsString(Instant.ofEpochSecond(0, 1))); + assertEquals(q("1970-01-01T00:00:00.000001Z"), + MAPPER.writeValueAsString(Instant.ofEpochSecond(0, 1000))); + assertEquals(q("1970-01-01T00:00:00.001Z"), + MAPPER.writeValueAsString(Instant.ofEpochSecond(0, 1000000))); + } + + // `@JsonFormat(shape=STRING)` without a pattern must not lose the padding + @Test + public void testShapeStringWithoutPattern() throws Exception + { + assertEquals(a2q("{'value':'2017-09-14T04:28:48.000Z'}"), + MAPPER.writeValueAsString(new ShapeOnlyWrapper(Instant.parse("2017-09-14T04:28:48Z")))); + } +} diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index 58147120..c8693d31 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -234,3 +234,12 @@ Boleslav Bobcik (@bbobcik) Albert Lovers (@AlbertLovers) * Reported, contributed fix for #381: Fix a potential problem in `JavaTimeModule._findFactory()` (2.21.0) + +Ryan (@rycler) + * Reported #76: Missing milliseconds, when serializing Java 8 date-time, if they are zeros + (2.23.0) + +Seonwoo Jung (@seonwooj0810) + * Contributed fix for #76: Missing milliseconds, when serializing Java 8 date-time, + if they are zeros + (2.23.0) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index d8d684d5..e19f3731 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -10,7 +10,10 @@ Modules: 2.23.0 (not yet released) -No changes since 2.22 +#76: Missing milliseconds, when serializing Java 8 date-time if they are zeros (Add + `JavaTimeFeature.ALWAYS_WRITE_SUBSECOND_DIGITS`) + (reported by @rycler) + (fix contributed by Seonwoo J) 2.22.1 (07-Jul-2026) 2.22.0 (31-May-2026) From a57be5edd1d246ac44367e44b7f9dc3215d8ead4 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 14 Aug 2026 16:03:17 -0700 Subject: [PATCH 133/140] Prep for 2.21.6 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf15137e..0e23638a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.6-SNAPSHOT + 2.21.6 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index eef97ba2..33d3ae8a 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,7 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.21.6 (14-Aug-2026) 2.21.5 (06-Jul-2026) 2.21.4 (28-May-2026) 2.21.3 (28-Apr-2026) From bb755d9c9ad5b102d14bb571a50c1f7a2db62733 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 14 Aug 2026 16:59:03 -0700 Subject: [PATCH 134/140] [maven-release-plugin] prepare release jackson-modules-java8-2.21.6 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index d425b393..1acc3e61 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.6-SNAPSHOT + 2.21.6 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 7cb70e08..ecdccdfc 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.6-SNAPSHOT + 2.21.6 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index 97903afa..e54f936f 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.6-SNAPSHOT + 2.21.6 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 0e23638a..66355cee 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.6-SNAPSHOT + 2.21.6 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.21.6 https://github.com/FasterXML/jackson-modules-java8/issues From d231d32c39c3952470e0a730130c97bd7460cdb2 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 14 Aug 2026 16:59:07 -0700 Subject: [PATCH 135/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 1acc3e61..aa75087f 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.6 + 2.21.7-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index ecdccdfc..3051e0c4 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.6 + 2.21.7-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index e54f936f..513e6ff2 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.21.6 + 2.21.7-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 66355cee..a1072dd3 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.21.6 + 2.21.7-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.21.6 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 32bae873ce9e3387e17ed8573e7a20b208baba4c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 14 Aug 2026 17:00:32 -0700 Subject: [PATCH 136/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a1072dd3..f823260d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.21.6 + 2.21.7-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8 From 52cbdbbd0e6072a080269b85e51272682c26a197 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 16 Aug 2026 09:58:57 -0700 Subject: [PATCH 137/140] Prep for 2.22.2 release --- pom.xml | 2 +- release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 07875fc0..4109dc32 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.22.2-SNAPSHOT + 2.22.2 com.fasterxml.jackson.module jackson-modules-java8 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index bb6813f6..08ed2161 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -12,6 +12,7 @@ Modules: No changes since 2.22 +2.22.2 (16-Aug-2026) 2.22.1 (07-Jul-2026) 2.22.0 (31-May-2026) From fc76f4db6543aa6d23827c8081f6868aa66a8d64 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 16 Aug 2026 09:59:32 -0700 Subject: [PATCH 138/140] [maven-release-plugin] prepare release jackson-modules-java8-2.22.2 --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 0708329f..71eb39f3 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.2-SNAPSHOT + 2.22.2 com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index f77ace6e..0d030b3e 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.2-SNAPSHOT + 2.22.2 com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index b24787e4..c0b32dce 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.2-SNAPSHOT + 2.22.2 jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 4109dc32..05df5e15 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.22.2-SNAPSHOT + 2.22.2 pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - HEAD + jackson-modules-java8-2.22.2 https://github.com/FasterXML/jackson-modules-java8/issues From d92ae4dcb624a5224a189654d6d7cad0c8ae4cdc Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 16 Aug 2026 09:59:36 -0700 Subject: [PATCH 139/140] [maven-release-plugin] prepare for next development iteration --- datatypes/pom.xml | 2 +- datetime/pom.xml | 2 +- parameter-names/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datatypes/pom.xml b/datatypes/pom.xml index 71eb39f3..c20d1887 100644 --- a/datatypes/pom.xml +++ b/datatypes/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.2 + 2.22.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jdk8 diff --git a/datetime/pom.xml b/datetime/pom.xml index 0d030b3e..d83e2ef3 100644 --- a/datetime/pom.xml +++ b/datetime/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.2 + 2.22.3-SNAPSHOT com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/parameter-names/pom.xml b/parameter-names/pom.xml index c0b32dce..f9ef6fd8 100644 --- a/parameter-names/pom.xml +++ b/parameter-names/pom.xml @@ -9,7 +9,7 @@ com.fasterxml.jackson.module jackson-modules-java8 - 2.22.2 + 2.22.3-SNAPSHOT jackson-module-parameter-names Jackson-module-parameter-names diff --git a/pom.xml b/pom.xml index 05df5e15..96eb9aa3 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.fasterxml.jackson.module jackson-modules-java8 Jackson modules: Java 8 - 2.22.2 + 2.22.3-SNAPSHOT pom Parent pom for Jackson modules needed to support Java 8 features and types @@ -24,7 +24,7 @@ scm:git:git@github.com:FasterXML/jackson-modules-java8.git scm:git:git@github.com:FasterXML/jackson-modules-java8.git http://github.com/FasterXML/jackson-modules-java8 - jackson-modules-java8-2.22.2 + HEAD https://github.com/FasterXML/jackson-modules-java8/issues From 28444468f417ffa1f688f043b0bd039b84298dc1 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 16 Aug 2026 10:01:17 -0700 Subject: [PATCH 140/140] Post-release dep version bump --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 96eb9aa3..6a634996 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.fasterxml.jackson jackson-base - 2.22.2 + 2.22.3-SNAPSHOT com.fasterxml.jackson.module jackson-modules-java8