use of com.carrotsearch.ant.tasks.junit4.events.FailureEvent in project randomizedtesting by randomizedtesting.
the class AggregatedSuiteResultEvent method serializeEvents.
private void serializeEvents(JsonWriter w, boolean outputStreams) throws IOException {
final Charset charset = getSlave().getCharset();
int lineBuffer = 160;
final StringWriter out = new StringWriter();
final StringWriter err = new StringWriter();
WriterOutputStream stdout = new WriterOutputStream(out, charset, lineBuffer, false);
WriterOutputStream stderr = new WriterOutputStream(err, charset, lineBuffer, false);
for (IEvent evt : getEventStream()) {
try {
switch(evt.getType()) {
case SUITE_FAILURE:
case TEST_IGNORED_ASSUMPTION:
case TEST_IGNORED:
case TEST_STARTED:
case TEST_FINISHED:
case TEST_FAILURE:
flushBoth(w, out, err, stdout, stderr);
w.beginObject();
w.name("event").value(evt.getType().toString());
w.name("description");
JsonHelpers.writeDescription(w, ((IDescribable) evt).getDescription());
if (evt instanceof FailureEvent) {
w.name("failure");
((FailureEvent) evt).serialize(w);
}
w.endObject();
break;
case APPEND_STDOUT:
if (outputStreams) {
flush(APPEND_STDERR, w, stderr, err);
((IStreamEvent) evt).copyTo(stdout);
}
break;
case APPEND_STDERR:
if (outputStreams) {
flush(APPEND_STDOUT, w, stdout, out);
((IStreamEvent) evt).copyTo(stderr);
}
break;
default:
break;
}
} catch (IOException ex) {
// Ignore.
}
}
flushBoth(w, out, err, stdout, stderr);
}
Aggregations