From dbcfff6c5e4ee7ddad7e0d63a37e00aca67889a2 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 1 Nov 2021 20:43:53 -0700 Subject: [PATCH] Add failing test for #303 --- .../ion/failing/UncaughtException303Test.java | 38 ++++++++++++++++++ .../ion/misc/UncaughtExceptionsTest.java | 1 - ion/src/test/resources/data/issue-303.ion | Bin 0 -> 56 bytes 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/UncaughtException303Test.java create mode 100644 ion/src/test/resources/data/issue-303.ion diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/UncaughtException303Test.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/UncaughtException303Test.java new file mode 100644 index 000000000..ecefa255e --- /dev/null +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/UncaughtException303Test.java @@ -0,0 +1,38 @@ +package com.fasterxml.jackson.dataformat.ion.failing; + +import java.net.URL; + +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; + +import static org.junit.Assert.*; + +public class UncaughtException303Test +{ + private final IonObjectMapper MAPPER = IonObjectMapper.builder().build(); + + // [dataformats-binary#303] + @Test + public void testUncaughtException303() throws Exception + { + URL poc = getClass().getResource("/data/issue-303.ion"); + try { + MAPPER.readTree(poc); + fail("Should not pass with invalid content"); + } catch (JsonProcessingException e) { + // !!! TODO: change to match what we actually expect + verifyException(e, "MATCH MESSAGE"); + } + } + + void verifyException(Throwable e, String match) + { + String msg = e.getMessage(); + String lmsg = (msg == null) ? "" : msg.toLowerCase(); + if (lmsg.indexOf(match.toLowerCase()) < 0) { + fail("Expected an exception with a substrings ("+match+"): got one with message \""+msg+"\""); + } + } +} diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java index b1ff1bb1c..6dec9d161 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java @@ -1,7 +1,6 @@ package com.fasterxml.jackson.dataformat.ion.misc; import java.net.URL; -import java.util.Arrays; import org.junit.Test; diff --git a/ion/src/test/resources/data/issue-303.ion b/ion/src/test/resources/data/issue-303.ion new file mode 100644 index 0000000000000000000000000000000000000000..7bc8dde364a93d94235f281e65a107ea756bd38e GIT binary patch literal 56 zcmaFB$nfeN