From e16a9a0c68b1aad60921e78b93f24aeaa77e3524 Mon Sep 17 00:00:00 2001 From: joewitt Date: Fri, 1 Jan 2016 14:08:46 -0500 Subject: [PATCH] NIFI-1343 added unit tests to verify behavior --- .../processors/standard/TestRouteText.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java index 760986df5a..7c40445666 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteText.java @@ -132,6 +132,42 @@ public class TestRouteText { outUnmatched.assertContentEquals("not match".getBytes("UTF-8")); } + @Test + public void testSimpleCaseSensitiveStartsMatch() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new RouteText()); + runner.setProperty(RouteText.MATCH_STRATEGY, RouteText.STARTS_WITH); + runner.setProperty(RouteText.IGNORE_CASE, "false"); + runner.setProperty("simple", "start"); + + runner.enqueue("STart middle end\nstart middle end".getBytes("UTF-8")); + runner.run(); + + runner.assertTransferCount("simple", 1); + runner.assertTransferCount("unmatched", 1); + runner.assertTransferCount("original", 1); + final MockFlowFile outMatched = runner.getFlowFilesForRelationship("simple").get(0); + outMatched.assertContentEquals("start middle end".getBytes("UTF-8")); + final MockFlowFile outUnmatched = runner.getFlowFilesForRelationship("unmatched").get(0); + outUnmatched.assertContentEquals("STart middle end\n".getBytes("UTF-8")); + } + + @Test + public void testSimpleCaseInsensitiveStartsMatch() throws IOException { + final TestRunner runner = TestRunners.newTestRunner(new RouteText()); + runner.setProperty(RouteText.MATCH_STRATEGY, RouteText.STARTS_WITH); + runner.setProperty(RouteText.IGNORE_CASE, "true"); + runner.setProperty("simple", "start"); + + runner.enqueue("start middle end\nSTart middle end".getBytes("UTF-8")); + runner.run(); + + runner.assertTransferCount("simple", 1); + runner.assertTransferCount("unmatched", 0); + runner.assertTransferCount("original", 1); + final MockFlowFile outMatched = runner.getFlowFilesForRelationship("simple").get(0); + outMatched.assertContentEquals("start middle end\nSTart middle end".getBytes("UTF-8")); + } + @Test public void testSimpleDefaultEnd() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new RouteText());