use of org.apache.nifi.cluster.protocol.impl.testutils.DelayedProtocolHandler in project nifi by apache.
the class SocketProtocolListenerTest method testDelayedRequest.
@Test
public void testDelayedRequest() throws Exception {
ProtocolMessage msg = new PingMessage();
DelayedProtocolHandler handler = new DelayedProtocolHandler(2000);
listener.addHandler(handler);
// marshal message to output stream
marshaller.marshal(msg, socket.getOutputStream());
try {
socket.getInputStream().read();
fail("Socket timeout not received.");
} catch (SocketTimeoutException ste) {
}
assertEquals(1, handler.getMessages().size());
assertEquals(msg.getType(), handler.getMessages().get(0).getType());
}
use of org.apache.nifi.cluster.protocol.impl.testutils.DelayedProtocolHandler in project nifi by apache.
the class SocketProtocolListenerTest method testBadRequest.
@Test
public void testBadRequest() throws Exception {
DelayedProtocolHandler handler = new DelayedProtocolHandler(0);
listener.addHandler(handler);
socket.getOutputStream().write(5);
Thread.sleep(250);
assertEquals(0, handler.getMessages().size());
}
Aggregations