mirror of https://github.com/apache/nifi.git
NIFI-1343 added unit tests to verify behavior
This commit is contained in:
parent
02b325b07e
commit
e16a9a0c68
|
@ -132,6 +132,42 @@ public class TestRouteText {
|
||||||
outUnmatched.assertContentEquals("not match".getBytes("UTF-8"));
|
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
|
@Test
|
||||||
public void testSimpleDefaultEnd() throws IOException {
|
public void testSimpleDefaultEnd() throws IOException {
|
||||||
final TestRunner runner = TestRunners.newTestRunner(new RouteText());
|
final TestRunner runner = TestRunners.newTestRunner(new RouteText());
|
||||||
|
|
Loading…
Reference in New Issue