nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joew...@apache.org
Subject [2/3] incubator-nifi git commit: NIFI-613 just needed to check for line of length 0. Added unit test to prove fail and fix
Date Fri, 05 Jun 2015 03:55:40 GMT
NIFI-613 just needed to check for line of length 0.  Added unit test to prove fail and fix


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/1fb6aa49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/1fb6aa49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/1fb6aa49

Branch: refs/heads/develop
Commit: 1fb6aa49ba6a5e2fd45e8482deaf35401bcaace2
Parents: 819b65f
Author: joewitt <joewitt@apache.org>
Authored: Thu Jun 4 23:22:23 2015 -0400
Committer: joewitt <joewitt@apache.org>
Committed: Thu Jun 4 23:22:23 2015 -0400

----------------------------------------------------------------------
 .../nifi/processors/standard/ScanContent.java    |  2 +-
 .../processors/standard/TestScanContent.java     | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1fb6aa49/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ScanContent.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ScanContent.java
b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ScanContent.java
index ab5e8b5..445249b 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ScanContent.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ScanContent.java
@@ -261,7 +261,7 @@ public class ScanContent extends AbstractProcessor {
         @Override
         public SearchTerm<byte[]> nextTerm() throws IOException {
             final String nextLine = reader.readLine();
-            if (nextLine == null) {
+            if (nextLine == null || nextLine.isEmpty()) {
                 return null;
             }
             return new SearchTerm<>(nextLine.getBytes("UTF-8"));

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1fb6aa49/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanContent.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanContent.java
b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanContent.java
index 8c36845..c221965 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanContent.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanContent.java
@@ -18,6 +18,7 @@ package org.apache.nifi.processors.standard;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.io.StringWriter;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -34,6 +35,24 @@ import org.junit.Test;
 
 public class TestScanContent {
 
+    @Test
+    public void testBlankLineInDictionaryTextEncoding() throws IOException {
+        final String dictionaryWithBlankLine = "Line1\n\nLine3";
+        final byte[] dictionaryBytes = dictionaryWithBlankLine.getBytes(ScanContent.UTF8);
+        final Path dictionaryPath = Paths.get("target/dictionary");
+        Files.write(dictionaryPath, dictionaryBytes, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
+
+        final TestRunner runner = TestRunners.newTestRunner(new ScanContent());
+        runner.setThreadCount(1);
+        runner.setProperty(ScanContent.DICTIONARY, dictionaryPath.toString());
+        runner.setProperty(ScanContent.DICTIONARY_ENCODING, ScanContent.TEXT_ENCODING);
+
+        runner.enqueue(new byte[0]);
+        runner.run();
+        runner.assertTransferCount(ScanContent.REL_NO_MATCH, 1);
+
+    }
+
     @Ignore("This test has a race condition/ordering problem")
     @Test
     public void testBinaryScan() throws IOException {


Mime
View raw message