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());
}
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());
}
Aggregations