-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap the method call with try catch block
Signed-off-by: Arthur Chan <[email protected]>
- Loading branch information
1 parent
e4a993c
commit 4c47b75
Showing
4 changed files
with
66 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_65274_NPETest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.fasterxml.jackson.dataformat.ion.fuzz; | ||
|
||
import java.io.InputStream; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.core.exc.StreamReadException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.ion.*; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.*; | ||
import java.nio.file.*; | ||
|
||
// [dataformats-binary#434 | ||
public class Fuzz434_65268_65274_NPETest | ||
{ | ||
@Test | ||
public void testFuzz65268() throws Exception { | ||
final IonFactory factory = | ||
IonFactory.builderForTextualWriters().build(); | ||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65268.ion")) { | ||
try (JsonParser p = factory.createParser(in)) { | ||
p.nextToken(); | ||
p.getText(); | ||
p.nextTextValue(); | ||
p.getNumberType(); | ||
} | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("not integer")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testFuzz65274() throws Exception { | ||
final ObjectMapper MAPPER = | ||
IonObjectMapper.builder( | ||
IonFactory.builderForBinaryWriters() | ||
.enable(IonParser.Feature.USE_NATIVE_TYPE_ID) | ||
.build()) | ||
.build(); | ||
|
||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65274.ion")) { | ||
byte[] invalid = in.readAllBytes(); | ||
try (JsonParser p = MAPPER.getFactory().createParser(new ByteArrayInputStream(invalid))) { | ||
MAPPER.readTree(p); | ||
} | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("not integer")); | ||
} | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_NPETest.java
This file was deleted.
Oops, something went wrong.
Binary file not shown.