Search in sources :

Example 6 with SocketChannelResponder

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

the class TestRELPEventFactory method testCreateRELPEvent.

@Test
public void testCreateRELPEvent() {
    final byte[] data = "this is an event".getBytes(StandardCharsets.UTF_8);
    final String sender = "sender1";
    final long txnr = 1;
    final String command = "syslog";
    final Map<String, String> metadata = new HashMap<>();
    metadata.put(EventFactory.SENDER_KEY, sender);
    metadata.put(RELPMetadata.TXNR_KEY, String.valueOf(txnr));
    metadata.put(RELPMetadata.COMMAND_KEY, command);
    final ChannelResponder responder = new SocketChannelResponder(null);
    final EventFactory<RELPEvent> factory = new RELPEventFactory();
    final RELPEvent event = factory.create(data, metadata, responder);
    Assert.assertEquals(data, event.getData());
    Assert.assertEquals(sender, event.getSender());
    Assert.assertEquals(txnr, event.getTxnr());
    Assert.assertEquals(command, event.getCommand());
    Assert.assertEquals(responder, event.getResponder());
}
Also used : SocketChannelResponder(org.apache.nifi.processor.util.listen.response.socket.SocketChannelResponder) ChannelResponder(org.apache.nifi.processor.util.listen.response.ChannelResponder) SocketChannelResponder(org.apache.nifi.processor.util.listen.response.socket.SocketChannelResponder) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 7 with SocketChannelResponder

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

the class TestBeatsEventFactory method testCreateLumberJackEvent.

@Test
public void testCreateLumberJackEvent() {
    final String sender = "testsender1";
    final byte[] data = "this is a test line".getBytes();
    final int seqNumber = 1;
    final String fields = "{\"file\":\"test\"}";
    final Map<String, String> metadata = new HashMap<>();
    metadata.put(EventFactory.SENDER_KEY, sender);
    metadata.put(BeatsMetadata.SEQNUMBER_KEY, String.valueOf(seqNumber));
    final ChannelResponder responder = new SocketChannelResponder(null);
    final EventFactory<BeatsEvent> factory = new BeatsEventFactory();
    final BeatsEvent event = factory.create(data, metadata, responder);
    Assert.assertEquals(sender, event.getSender());
    Assert.assertEquals(seqNumber, event.getSeqNumber());
    Assert.assertEquals(data, event.getData());
}
Also used : SocketChannelResponder(org.apache.nifi.processor.util.listen.response.socket.SocketChannelResponder) ChannelResponder(org.apache.nifi.processor.util.listen.response.ChannelResponder) SocketChannelResponder(org.apache.nifi.processor.util.listen.response.socket.SocketChannelResponder) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

SocketChannelResponder (org.apache.nifi.processor.util.listen.response.socket.SocketChannelResponder)7 InetAddress (java.net.InetAddress)4 HashMap (java.util.HashMap)3 ChannelResponder (org.apache.nifi.processor.util.listen.response.ChannelResponder)3 Test (org.junit.Test)3 BeatsFrame (org.apache.nifi.processors.beats.frame.BeatsFrame)1 BeatsFrameException (org.apache.nifi.processors.beats.frame.BeatsFrameException)1 LumberjackFrame (org.apache.nifi.processors.lumberjack.frame.LumberjackFrame)1 LumberjackFrameException (org.apache.nifi.processors.lumberjack.frame.LumberjackFrameException)1 RELPFrame (org.apache.nifi.processors.standard.relp.frame.RELPFrame)1 RELPFrameException (org.apache.nifi.processors.standard.relp.frame.RELPFrameException)1