use of org.apache.nifi.cluster.protocol.message.PingMessage 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.message.PingMessage in project nifi by apache.
the class SocketProtocolListenerTest method testRequest.
@Test
public void testRequest() throws Exception {
ProtocolMessage msg = new PingMessage();
ReflexiveProtocolHandler handler = new ReflexiveProtocolHandler();
listener.addHandler(handler);
// marshal message to output stream
marshaller.marshal(msg, socket.getOutputStream());
// unmarshall response and return
ProtocolMessage response = unmarshaller.unmarshal(socket.getInputStream());
assertEquals(msg.getType(), response.getType());
assertEquals(1, handler.getMessages().size());
assertEquals(msg.getType(), handler.getMessages().get(0).getType());
}
Aggregations