blob: 797c1d159a6d5ce68afed065f0186640573a373d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package org.brotli.dec;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
/**
* Common utility methods.
*/
public final class TestUtils {
public static InputStream newBrotliInputStream(InputStream input) throws IOException {
String brotliClass = System.getProperty("BROTLI_INPUT_STREAM");
if (brotliClass == null) {
return new BrotliInputStream(input);
}
try {
Class<?> clazz = Class.forName(brotliClass);
Constructor<?> ctor = clazz.getConstructor(InputStream.class);
return (InputStream) ctor.newInstance(new Object[] { input });
} catch (Exception e) {
throw new RuntimeException(e);
}
}
static byte[] readUniBytes(String uniBytes) {
byte[] result = new byte[uniBytes.length()];
for (int i = 0; i < result.length; ++i) {
result[i] = (byte) uniBytes.charAt(i);
}
return result;
}
private TestUtils() {}
}
|