use of com.carrotsearch.ant.tasks.junit4.events.Deserializer in project randomizedtesting by randomizedtesting.
the class LocalSlaveStreamHandler method pumpEvents.
/**
* Pump events from event stream.
*/
void pumpEvents(InputStream eventStream) {
try {
Deserializer deserializer = new Deserializer(eventStream, refLoader);
IEvent event = null;
while ((event = deserializer.deserialize()) != null) {
switch(event.getType()) {
case APPEND_STDERR:
case APPEND_STDOUT:
// Ignore these two on activity heartbeats. GH-117
break;
default:
lastActivity = System.currentTimeMillis();
break;
}
try {
switch(event.getType()) {
case QUIT:
eventBus.post(event);
return;
case IDLE:
eventBus.post(new SlaveIdle(stdinWriter));
break;
case BOOTSTRAP:
clientCharset = Charset.forName(((BootstrapEvent) event).getDefaultCharsetName());
stdinWriter = new OutputStreamWriter(stdin, clientCharset);
eventBus.post(event);
break;
case APPEND_STDERR:
case APPEND_STDOUT:
assert streamsBuffer.getFilePointer() == streamsBuffer.length();
final long bufferStart = streamsBuffer.getFilePointer();
IStreamEvent streamEvent = (IStreamEvent) event;
streamEvent.copyTo(streamsBufferWrapper);
final long bufferEnd = streamsBuffer.getFilePointer();
event = new OnDiskStreamEvent(event.getType(), streamsBuffer, bufferStart, bufferEnd);
eventBus.post(event);
break;
default:
eventBus.post(event);
}
} catch (Throwable t) {
warnStream.println("Event bus dispatch error: " + t.toString());
t.printStackTrace(warnStream);
}
}
lastActivity = null;
} catch (Throwable e) {
if (!stopping) {
warnStream.println("Event stream error: " + e.toString());
e.printStackTrace(warnStream);
}
}
}
use of com.carrotsearch.ant.tasks.junit4.events.Deserializer in project randomizedtesting by randomizedtesting.
the class TestJsonByteArrayRoundtrip method check.
private void check(byte[] bytes) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Serializer s = new Serializer(baos);
s.serialize(new AppendStdErrEvent(bytes, 0, bytes.length));
s.flush();
s.close();
Deserializer deserializer = new Deserializer(new ByteArrayInputStream(baos.toByteArray()), Thread.currentThread().getContextClassLoader());
IEvent deserialize = deserializer.deserialize();
Assert.assertTrue(deserialize instanceof AppendStdErrEvent);
AppendStdErrEvent e = ((AppendStdErrEvent) deserialize);
baos.reset();
e.copyTo(baos);
Assert.assertTrue("Exp: " + Arrays.toString(bytes) + "\n" + "was: " + Arrays.toString(baos.toByteArray()), Arrays.equals(bytes, baos.toByteArray()));
}
Aggregations