use of com.carrotsearch.ant.tasks.junit4.events.EventType in project randomizedtesting by randomizedtesting.
the class DumpStreamsFromEventStream method main.
public static void main(String[] args) throws Exception {
File inputFile;
if (args.length != 1) {
System.err.println("Usage: [input.events]");
System.exit(1);
return;
} else {
inputFile = new File(args[0]);
}
Closer closer = Closer.create();
try {
OutputStream sysout = new BufferedOutputStream(new FileOutputStream(new File(inputFile.getAbsolutePath() + ".sysout")));
closer.register(sysout);
OutputStream syserr = new BufferedOutputStream(new FileOutputStream(new File(inputFile.getAbsolutePath() + ".syserr")));
closer.register(syserr);
InputStream is = new BufferedInputStream(new FileInputStream(inputFile));
closer.register(is);
JsonReader input = new JsonReader(new InputStreamReader(is, Charsets.UTF_8));
input.setLenient(true);
JsonToken peek;
while (true) {
peek = input.peek();
if (peek == JsonToken.END_DOCUMENT) {
return;
}
input.beginArray();
EventType type = EventType.valueOf(input.nextString());
switch(type) {
case APPEND_STDERR:
IStreamEvent.class.cast(type.deserialize(input)).copyTo(syserr);
break;
case APPEND_STDOUT:
IStreamEvent.class.cast(type.deserialize(input)).copyTo(sysout);
break;
default:
input.skipValue();
}
input.endArray();
}
} catch (Throwable t) {
throw closer.rethrow(t);
} finally {
closer.close();
}
}
use of com.carrotsearch.ant.tasks.junit4.events.EventType in project randomizedtesting by randomizedtesting.
the class Deserializer method deserialize.
public IEvent deserialize() throws IOException {
JsonToken peek = input.peek();
if (peek == JsonToken.END_ARRAY)
return null;
input.beginArray();
EventType type = EventType.valueOf(input.nextString());
IEvent event = type.deserialize(input);
input.endArray();
return event;
}
Aggregations