Skip to content

Commit f798ced

Browse files
committed
Merge branch '2.11' into 2.12
2 parents 9ba1a0b + e697c72 commit f798ced

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,23 @@ protected static byte[] concat(byte[] ... chunks)
255255
}
256256
return bout.toByteArray();
257257
}
258+
259+
protected byte[] readResource(String ref)
260+
{
261+
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
262+
final byte[] buf = new byte[4000];
263+
264+
try (InputStream in = getClass().getResourceAsStream(ref)) {
265+
int len;
266+
while ((len = in.read(buf)) > 0) {
267+
bytes.write(buf, 0, len);
268+
}
269+
} catch (IOException e) {
270+
throw new RuntimeException("Failed to read resource '"+ref+"': "+e);
271+
}
272+
if (bytes.size() == 0) {
273+
throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?");
274+
}
275+
return bytes.toByteArray();
276+
}
258277
}

0 commit comments

Comments
 (0)