Skip to content

Commit e697c72

Browse files
committed
minor addition to base test
1 parent 7322aa4 commit e697c72

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/BaseTestForSmile.java

+19
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,23 @@ public String quote(String str) {
225225
protected static String aposToQuotes(String str) {
226226
return str.replace("'", "\"");
227227
}
228+
229+
protected byte[] readResource(String ref)
230+
{
231+
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
232+
final byte[] buf = new byte[4000];
233+
234+
try (InputStream in = getClass().getResourceAsStream(ref)) {
235+
int len;
236+
while ((len = in.read(buf)) > 0) {
237+
bytes.write(buf, 0, len);
238+
}
239+
} catch (IOException e) {
240+
throw new RuntimeException("Failed to read resource '"+ref+"': "+e);
241+
}
242+
if (bytes.size() == 0) {
243+
throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?");
244+
}
245+
return bytes.toByteArray();
246+
}
228247
}

0 commit comments

Comments
 (0)