Skip to content

Commit

Permalink
Add failing test for #303
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 2, 2021
1 parent d4b80c5 commit dbcfff6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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+"\"");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.fasterxml.jackson.dataformat.ion.misc;

import java.net.URL;
import java.util.Arrays;

import org.junit.Test;

Expand Down
Binary file added ion/src/test/resources/data/issue-303.ion
Binary file not shown.

0 comments on commit dbcfff6

Please sign in to comment.