You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2019/02/26 14:40:37 UTC

[nifi] branch master updated: NIFI-6076 syslog5424 should support missing MSG - newer lib version and better test

This is an automated email from the ASF dual-hosted git repository.

bbende pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new 922da68  NIFI-6076 syslog5424 should support missing MSG - newer lib version and better test
922da68 is described below

commit 922da68a235b5e8f20095ead6a3258490ba9323a
Author: Otto Fowler <ot...@gmail.com>
AuthorDate: Sun Feb 24 20:40:48 2019 -0500

    NIFI-6076 syslog5424 should support missing MSG
    - newer lib version and better test
    
    This closes #3331.
    
    Signed-off-by: Bryan Bende <bb...@apache.org>
---
 .../nifi-extension-utils/nifi-syslog-utils/pom.xml |  2 +-
 .../syslog/BaseStrictSyslog5424ParserTest.java     | 29 +++++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml
index d7d7bbe..74950e5 100644
--- a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml
+++ b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml
@@ -26,7 +26,7 @@
         <dependency>
             <groupId>com.github.palindromicity</groupId>
             <artifactId>simple-syslog-5424</artifactId>
-            <version>0.0.8</version>
+            <version>0.0.11</version>
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java
index 082fbbd..6b19749 100644
--- a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java
+++ b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java
@@ -149,7 +149,7 @@ public abstract class BaseStrictSyslog5424ParserTest {
     public void testVariety() {
         final List<String> messages = new ArrayList<>();
 
-        // supported examples from RFC 5424
+        // supported examples from RFC 5424 including structured data with no message
         messages.add("<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - " +
                 "ID47 - BOM'su root' failed for lonvick on /dev/pts/8");
         messages.add("<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc " +
@@ -171,6 +171,33 @@ public abstract class BaseStrictSyslog5424ParserTest {
     }
 
     @Test
+    public void testMessagePartNotRequired() {
+        final List<String> messages = new ArrayList<>();
+
+        messages.add("<14>1 2014-06-20T09:14:07+00:00 loggregator"
+            + " d0602076-b14a-4c55-852a-981e7afeed38 DEA MSG-01"
+            + " [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"]");
+
+        messages.add("<14>1 2014-06-20T09:14:07+00:00 loggregator"
+            + " d0602076-b14a-4c55-852a-981e7afeed38 DEA MSG-01"
+            + " [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"]"
+            + " [exampleSDID@32480 iut=\"4\" eventSource=\"Other Application\" eventID=\"2022\"]");
+
+        for (final String message : messages) {
+            final byte[] bytes = message.getBytes(CHARSET);
+            final ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
+            buffer.clear();
+            buffer.put(bytes);
+
+            final Syslog5424Event event = parser.parseEvent(buffer);
+            Assert.assertTrue(event.isValid());
+            Assert.assertNull(event.getFieldMap().get(SyslogAttributes.SYSLOG_BODY));
+        }
+
+
+    }
+
+    @Test
     public void testInvalidPriority() {
         final String message = "10 Oct 13 14:14:43 localhost some body of the message";