-
-
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.
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
- Loading branch information
1 parent
973b3dc
commit c0a056d
Showing
4 changed files
with
59 additions
and
12 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
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
31 changes: 31 additions & 0 deletions
31
avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzzTestUtil.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,31 @@ | ||
package com.fasterxml.jackson.dataformat.avro.fuzz; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class AvroFuzzTestUtil | ||
{ | ||
public static byte[] readResource(String ref) | ||
{ | ||
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); | ||
final byte[] buf = new byte[4000]; | ||
|
||
InputStream in = AvroFuzzTestUtil.class.getResourceAsStream(ref); | ||
if (in != null) { | ||
try { | ||
int len; | ||
while ((len = in.read(buf)) > 0) { | ||
bytes.write(buf, 0, len); | ||
} | ||
in.close(); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to read resource '"+ref+"': "+e); | ||
} | ||
} | ||
if (bytes.size() == 0) { | ||
throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?"); | ||
} | ||
return bytes.toByteArray(); | ||
} | ||
} |
Binary file not shown.