Search in sources :

Example 6 with ChannelResponse

use of org.apache.nifi.processor.util.listen.response.ChannelResponse in project nifi by apache.

the class TestRELPFrameHandler method testClose.

@Test
public void testClose() throws IOException, InterruptedException {
    final RELPFrame openFrame = new RELPFrame.Builder().txnr(1).command("close").dataLength(0).data(new byte[0]).build();
    final String sender = "sender1";
    final CapturingChannelResponder responder = new CapturingChannelResponder();
    // call the handler and verify respond() was called once with once response
    frameHandler.handle(openFrame, responder, sender);
    Assert.assertEquals(1, responder.responded);
    Assert.assertEquals(1, responder.responses.size());
    // verify the response sent back the offers that were received
    final ChannelResponse response = responder.responses.get(0);
    final String responseData = new String(response.toByteArray(), charset);
    Assert.assertTrue(responseData.contains("200 OK"));
}
Also used : ChannelResponse(org.apache.nifi.processor.util.listen.response.ChannelResponse) RELPFrame(org.apache.nifi.processors.standard.relp.frame.RELPFrame) Test(org.junit.Test)

Aggregations

ChannelResponse (org.apache.nifi.processor.util.listen.response.ChannelResponse)6 IOException (java.io.IOException)3 ChannelResponder (org.apache.nifi.processor.util.listen.response.ChannelResponder)3 RELPFrame (org.apache.nifi.processors.standard.relp.frame.RELPFrame)2 RELPChannelResponse (org.apache.nifi.processors.standard.relp.response.RELPChannelResponse)2 Test (org.junit.Test)2 Map (java.util.Map)1 BeatsChannelResponse (org.apache.nifi.processors.beats.response.BeatsChannelResponse)1 LumberjackChannelResponse (org.apache.nifi.processors.lumberjack.response.LumberjackChannelResponse)1