use of com.nextdoor.bender.ipc.generic.GenericTransportBuffer in project bender by Nextdoor.
the class GenericTransportBufferTest method testDoubleClose.
@Test
public void testDoubleClose() throws IOException, TransportException {
GenericTransportSerializer serializer = mock(GenericTransportSerializer.class);
GenericTransportBuffer buffer = new GenericTransportBuffer(1, true, serializer);
buffer.close();
buffer.close();
}
use of com.nextdoor.bender.ipc.generic.GenericTransportBuffer in project bender by Nextdoor.
the class GenericTransportBufferTest method testAddBufferFull.
@Test(expected = IllegalStateException.class)
public void testAddBufferFull() throws IOException {
GenericTransportSerializer serializer = mock(GenericTransportSerializer.class);
doReturn("foo".getBytes()).when(serializer).serialize(any(InternalEvent.class));
GenericTransportBuffer buffer = new GenericTransportBuffer(1, false, serializer);
InternalEvent mockEvent = mock(InternalEvent.class);
buffer.add(mockEvent);
buffer.add(mockEvent);
}
use of com.nextdoor.bender.ipc.generic.GenericTransportBuffer in project bender by Nextdoor.
the class GenericTransportBufferTest method testClear.
@Test
public void testClear() throws IOException {
GenericTransportSerializer serializer = mock(GenericTransportSerializer.class);
doReturn("foo".getBytes()).when(serializer).serialize(any(InternalEvent.class));
GenericTransportBuffer buffer = new GenericTransportBuffer(1, false, serializer);
InternalEvent mockEvent = mock(InternalEvent.class);
buffer.add(mockEvent);
buffer.close();
String actual = new String(buffer.getInternalBuffer().toByteArray());
assertEquals("foo", actual);
buffer.clear();
assertEquals(true, buffer.isEmpty());
}
use of com.nextdoor.bender.ipc.generic.GenericTransportBuffer in project bender by Nextdoor.
the class HttpTransport method sendBatch.
public void sendBatch(TransportBuffer buf) throws TransportException {
GenericTransportBuffer buffer = (GenericTransportBuffer) buf;
sendBatch(buffer.getInternalBuffer().toByteArray());
}
use of com.nextdoor.bender.ipc.generic.GenericTransportBuffer in project bender by Nextdoor.
the class StdoutTransportTest method testStdout.
@Test
public void testStdout() throws IllegalStateException, IOException {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
System.setOut(new PrintStream(bo));
StdoutTransport transport = new StdoutTransport();
GenericTransportBuffer buf = new GenericTransportBuffer(1, false, new StdoutTransportSerializer());
InternalEvent event = new InternalEvent("junk", new TestContext(), 123);
event.setSerialized("junk");
buf.add(event);
transport.sendBatch(buf);
bo.flush();
String allWrittenLines = new String(bo.toByteArray());
assertEquals("junk\n", allWrittenLines);
}
Aggregations