You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/04/28 16:04:36 UTC
[02/50] [abbrv] incubator-nifi git commit: NIFI-271
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
index 89f330b..7a480a8 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceTextWithMapping.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.processors.standard.ReplaceTextWithMapping;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
@@ -36,23 +35,15 @@ public class TestReplaceTextWithMapping {
@Test
public void testSimple() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
- final String mappingFile = Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").
- toFile().
- getAbsolutePath();
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "roses are apple\n"
+ "violets are blueberry\n"
@@ -63,12 +54,8 @@ public class TestReplaceTextWithMapping {
@Test
public void testExpressionLanguageInText() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
- final String mappingFile = Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").
- toFile().
- getAbsolutePath();
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
String text = "${foo} red ${baz}";
@@ -76,11 +63,8 @@ public class TestReplaceTextWithMapping {
runner.enqueue(text.getBytes());
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "${foo} apple ${baz}";
assertEquals(expected, outputString);
@@ -88,27 +72,19 @@ public class TestReplaceTextWithMapping {
@Test
public void testExpressionLanguageInText2() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
- final String mappingFile = Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").
- toFile().
- getAbsolutePath();
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
runner.setProperty(ReplaceTextWithMapping.REGEX, "\\|(.*?)\\|");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
String text = "${foo}|red|${baz}";
runner.enqueue(text.getBytes());
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "${foo}|apple|${baz}";
assertEquals(expected, outputString);
@@ -116,27 +92,19 @@ public class TestReplaceTextWithMapping {
@Test
public void testExpressionLanguageInText3() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
- final String mappingFile = Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").
- toFile().
- getAbsolutePath();
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ final String mappingFile = Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath();
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, mappingFile);
runner.setProperty(ReplaceTextWithMapping.REGEX, ".*\\|(.*?)\\|.*");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
String text = "${foo}|red|${baz}";
runner.enqueue(text.getBytes());
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "${foo}|apple|${baz}";
assertEquals(expected, outputString);
@@ -144,25 +112,16 @@ public class TestReplaceTextWithMapping {
@Test
public void testWithMatchingGroupAndContext() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "-roses- are -apple-\n"
+ "violets are -blueberry-\n"
@@ -173,25 +132,16 @@ public class TestReplaceTextWithMapping {
@Test
public void testBackReference() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "(\\S+)");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-backreference-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-backreference-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "roses are red apple\n"
+ "violets are blue blueberry\n"
@@ -202,47 +152,32 @@ public class TestReplaceTextWithMapping {
@Test
public void testRoutesToFailureIfTooLarge() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "[123]");
runner.setProperty(ReplaceTextWithMapping.MAX_BUFFER_SIZE, "1 b");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").
- toFile().
- getAbsolutePath());
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-mapping.txt").toFile().getAbsolutePath());
final Map<String, String> attributes = new HashMap<>();
attributes.put("abc", "Good");
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_FAILURE, 1);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_FAILURE, 1);
}
@Test
public void testBackReferenceWithTooLargeOfIndexIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "-roses- are -red$2 apple-\n"
+ "violets are -blue$2 blueberry-\n"
@@ -253,23 +188,15 @@ public class TestReplaceTextWithMapping {
@Test
public void testBackReferenceWithTooLargeOfIndexIsEscapedSimple() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE,
- Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping-simple.txt").
- toFile().
- getAbsolutePath());
+ Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-excessive-backreference-mapping-simple.txt").toFile().getAbsolutePath());
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "roses are red$1 apple\n"
+ "violets are blue$1 blueberry\n"
@@ -280,25 +207,16 @@ public class TestReplaceTextWithMapping {
@Test
public void testBackReferenceWithInvalidReferenceIsEscaped() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "(\\S+)");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-invalid-backreference-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-invalid-backreference-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "roses are red$d apple\n"
+ "violets are blue$d blueberry\n"
@@ -309,25 +227,16 @@ public class TestReplaceTextWithMapping {
@Test
public void testEscapingDollarSign() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-escaped-dollar-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-escaped-dollar-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "-roses- are -$1 apple-\n"
+ "violets are -$1 blueberry-\n"
@@ -338,22 +247,14 @@ public class TestReplaceTextWithMapping {
@Test
public void testEscapingDollarSignSimple() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-escaped-dollar-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-escaped-dollar-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "roses are $1 apple\n"
+ "violets are $1 blueberry\n"
@@ -364,22 +265,14 @@ public class TestReplaceTextWithMapping {
@Test
public void testReplaceWithEmptyString() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-blank-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-blank-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "roses are \n"
+ "violets are \n"
@@ -390,22 +283,14 @@ public class TestReplaceTextWithMapping {
@Test
public void testReplaceWithSpaceInString() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-space-mapping.txt").
- toFile().
- getAbsolutePath());
-
- runner.enqueue(Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-space-mapping.txt").toFile().getAbsolutePath());
+
+ runner.enqueue(Paths.get("src/test/resources/TestReplaceTextWithMapping/colors-without-dashes.txt"));
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = "roses are really red\n"
+ "violets are super blue\n"
@@ -416,26 +301,17 @@ public class TestReplaceTextWithMapping {
@Test
public void testWithNoMatch() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-fruit-no-match-mapping.txt").
- toFile().
- getAbsolutePath());
-
- final Path path = Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors.txt");
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "1");
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-fruit-no-match-mapping.txt").toFile().getAbsolutePath());
+
+ final Path path = Paths.get("src/test/resources/TestReplaceTextWithMapping/colors.txt");
runner.enqueue(path);
runner.run();
- runner.
- assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
- final MockFlowFile out = runner.
- getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).
- get(0);
+ runner.assertAllFlowFilesTransferred(ReplaceTextWithMapping.REL_SUCCESS, 1);
+ final MockFlowFile out = runner.getFlowFilesForRelationship(ReplaceTextWithMapping.REL_SUCCESS).get(0);
String outputString = new String(out.toByteArray());
String expected = new String(Files.readAllBytes(path));
assertEquals(expected, outputString);
@@ -443,18 +319,12 @@ public class TestReplaceTextWithMapping {
@Test(expected = java.lang.AssertionError.class)
public void testMatchingGroupForLookupKeyTooLarge() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new ReplaceTextWithMapping());
+ final TestRunner runner = TestRunners.newTestRunner(new ReplaceTextWithMapping());
runner.setProperty(ReplaceTextWithMapping.REGEX, "-(.*?)-");
- runner.
- setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "2");
- runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.
- get("src/test/resources/TestReplaceTextWithMapping/color-mapping.txt").
- toFile().
- getAbsolutePath());
-
- final Path path = Paths.
- get("src/test/resources/TestReplaceTextWithMapping/colors.txt");
+ runner.setProperty(ReplaceTextWithMapping.MATCHING_GROUP_FOR_LOOKUP_KEY, "2");
+ runner.setProperty(ReplaceTextWithMapping.MAPPING_FILE, Paths.get("src/test/resources/TestReplaceTextWithMapping/color-mapping.txt").toFile().getAbsolutePath());
+
+ final Path path = Paths.get("src/test/resources/TestReplaceTextWithMapping/colors.txt");
runner.enqueue(path);
runner.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java
index 56996fe..2eac3f2 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.processors.standard.RouteOnAttribute;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -40,8 +39,7 @@ public class TestRouteOnAttribute {
public void testInvalidOnMisconfiguredProperty() {
final RouteOnAttribute proc = new RouteOnAttribute();
final MockProcessContext ctx = new MockProcessContext(proc);
- final ValidationResult validationResult = ctx.
- setProperty("RouteA", "${a:equals('b')"); // Missing closing brace
+ final ValidationResult validationResult = ctx.setProperty("RouteA", "${a:equals('b')"); // Missing closing brace
assertFalse(validationResult.isValid());
}
@@ -49,15 +47,13 @@ public class TestRouteOnAttribute {
public void testInvalidOnNonBooleanProperty() {
final RouteOnAttribute proc = new RouteOnAttribute();
final MockProcessContext ctx = new MockProcessContext(proc);
- final ValidationResult validationResult = ctx.
- setProperty("RouteA", "${a:length()"); // Should be boolean
+ final ValidationResult validationResult = ctx.setProperty("RouteA", "${a:length()"); // Should be boolean
assertFalse(validationResult.isValid());
}
@Test
public void testSimpleEquals() {
- final TestRunner runner = TestRunners.
- newTestRunner(new RouteOnAttribute());
+ final TestRunner runner = TestRunners.newTestRunner(new RouteOnAttribute());
runner.setProperty("RouteA", "${a:equals('b')}");
final Map<String, String> attributes = new HashMap<>();
@@ -66,24 +62,16 @@ public class TestRouteOnAttribute {
runner.run();
- runner.assertAllFlowFilesTransferred(new Relationship.Builder().
- name("RouteA").
- build(), 1);
- final List<MockFlowFile> flowFiles = runner.
- getFlowFilesForRelationship("RouteA");
- flowFiles.get(0).
- assertAttributeEquals("a", "b");
- flowFiles.get(0).
- assertAttributeEquals(RouteOnAttribute.ROUTE_ATTRIBUTE_KEY, "RouteA");
+ runner.assertAllFlowFilesTransferred(new Relationship.Builder().name("RouteA").build(), 1);
+ final List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship("RouteA");
+ flowFiles.get(0).assertAttributeEquals("a", "b");
+ flowFiles.get(0).assertAttributeEquals(RouteOnAttribute.ROUTE_ATTRIBUTE_KEY, "RouteA");
}
@Test
public void testMatchAll() {
- final TestRunner runner = TestRunners.
- newTestRunner(new RouteOnAttribute());
- runner.
- setProperty(RouteOnAttribute.ROUTE_STRATEGY, RouteOnAttribute.ROUTE_ALL_MATCH.
- getValue());
+ final TestRunner runner = TestRunners.newTestRunner(new RouteOnAttribute());
+ runner.setProperty(RouteOnAttribute.ROUTE_STRATEGY, RouteOnAttribute.ROUTE_ALL_MATCH.getValue());
runner.setProperty("RouteA", "${a:equals('b')}");
runner.setProperty("RouteB", "${b:equals('a')}");
@@ -103,36 +91,27 @@ public class TestRouteOnAttribute {
runner.run(4);
- final List<MockFlowFile> match = runner.
- getFlowFilesForRelationship(RouteOnAttribute.REL_MATCH);
- final List<MockFlowFile> noMatch = runner.
- getFlowFilesForRelationship(RouteOnAttribute.REL_NO_MATCH);
+ final List<MockFlowFile> match = runner.getFlowFilesForRelationship(RouteOnAttribute.REL_MATCH);
+ final List<MockFlowFile> noMatch = runner.getFlowFilesForRelationship(RouteOnAttribute.REL_NO_MATCH);
assertEquals(1, match.size());
assertEquals(3, noMatch.size());
for (final MockFlowFile ff : noMatch) {
- ff.
- assertAttributeEquals(RouteOnAttribute.ROUTE_ATTRIBUTE_KEY, "unmatched");
+ ff.assertAttributeEquals(RouteOnAttribute.ROUTE_ATTRIBUTE_KEY, "unmatched");
}
- final Map<String, String> matchedAttrs = match.iterator().
- next().
- getAttributes();
+ final Map<String, String> matchedAttrs = match.iterator().next().getAttributes();
assertEquals("b", matchedAttrs.get("a"));
assertEquals("a", matchedAttrs.get("b"));
- assertEquals("matched", matchedAttrs.
- get(RouteOnAttribute.ROUTE_ATTRIBUTE_KEY));
+ assertEquals("matched", matchedAttrs.get(RouteOnAttribute.ROUTE_ATTRIBUTE_KEY));
}
@Test
public void testMatchAny() {
- final TestRunner runner = TestRunners.
- newTestRunner(new RouteOnAttribute());
+ final TestRunner runner = TestRunners.newTestRunner(new RouteOnAttribute());
runner.setThreadCount(4);
- runner.
- setProperty(RouteOnAttribute.ROUTE_STRATEGY, RouteOnAttribute.ROUTE_ANY_MATCHES.
- getValue());
+ runner.setProperty(RouteOnAttribute.ROUTE_STRATEGY, RouteOnAttribute.ROUTE_ANY_MATCHES.getValue());
runner.setProperty("RouteA", "${a:equals('b')}");
runner.setProperty("RouteB", "${b:equals('a')}");
@@ -152,20 +131,16 @@ public class TestRouteOnAttribute {
runner.run(4);
- final List<MockFlowFile> match = runner.
- getFlowFilesForRelationship(RouteOnAttribute.REL_MATCH);
- final List<MockFlowFile> noMatch = runner.
- getFlowFilesForRelationship(RouteOnAttribute.REL_NO_MATCH);
+ final List<MockFlowFile> match = runner.getFlowFilesForRelationship(RouteOnAttribute.REL_MATCH);
+ final List<MockFlowFile> noMatch = runner.getFlowFilesForRelationship(RouteOnAttribute.REL_NO_MATCH);
assertEquals(2, match.size());
assertEquals(2, noMatch.size());
// Get attributes for both matching FlowFiles
final Iterator<MockFlowFile> itr = match.iterator();
- final Map<String, String> attrs1 = itr.next().
- getAttributes();
- final Map<String, String> attrs2 = itr.next().
- getAttributes();
+ final Map<String, String> attrs1 = itr.next().getAttributes();
+ final Map<String, String> attrs2 = itr.next().getAttributes();
// Both matches should map a -> b
assertEquals("b", attrs1.get("a"));
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnContent.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnContent.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnContent.java
index 96c281a..fb89d86 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnContent.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnContent.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.processors.standard.RouteOnContent;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.HashMap;
@@ -31,10 +30,8 @@ public class TestRouteOnContent {
@Test
public void testCloning() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new RouteOnContent());
- runner.
- setProperty(RouteOnContent.MATCH_REQUIREMENT, RouteOnContent.MATCH_SUBSEQUENCE);
+ final TestRunner runner = TestRunners.newTestRunner(new RouteOnContent());
+ runner.setProperty(RouteOnContent.MATCH_REQUIREMENT, RouteOnContent.MATCH_SUBSEQUENCE);
runner.setProperty("hello", "Hello");
runner.setProperty("world", "World");
@@ -48,10 +45,8 @@ public class TestRouteOnContent {
@Test
public void testSubstituteAttributes() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new RouteOnContent());
- runner.
- setProperty(RouteOnContent.MATCH_REQUIREMENT, RouteOnContent.MATCH_SUBSEQUENCE);
+ final TestRunner runner = TestRunners.newTestRunner(new RouteOnContent());
+ runner.setProperty(RouteOnContent.MATCH_REQUIREMENT, RouteOnContent.MATCH_SUBSEQUENCE);
runner.setProperty("attr", "Hel${highLow}");
final Map<String, String> attributes = new HashMap<>();
@@ -64,10 +59,8 @@ public class TestRouteOnContent {
@Test
public void testBufferSize() throws IOException {
- final TestRunner runner = TestRunners.
- newTestRunner(new RouteOnContent());
- runner.
- setProperty(RouteOnContent.MATCH_REQUIREMENT, RouteOnContent.MATCH_ALL);
+ final TestRunner runner = TestRunners.newTestRunner(new RouteOnContent());
+ runner.setProperty(RouteOnContent.MATCH_REQUIREMENT, RouteOnContent.MATCH_ALL);
runner.setProperty(RouteOnContent.BUFFER_SIZE, "3 B");
runner.setProperty("rel", "Hel");
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanAttribute.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanAttribute.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanAttribute.java
index 982cf57..b4a4136 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanAttribute.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestScanAttribute.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.processors.standard.ScanAttribute;
import java.util.HashMap;
import java.util.Map;
@@ -30,8 +29,7 @@ public class TestScanAttribute {
@Test
public void testSingleMatch() {
final TestRunner runner = TestRunners.newTestRunner(new ScanAttribute());
- runner.
- setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary1");
+ runner.setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary1");
final Map<String, String> attributes = new HashMap<>();
attributes.put("abc", "world");
@@ -67,10 +65,8 @@ public class TestScanAttribute {
@Test
public void testAllMatch() {
final TestRunner runner = TestRunners.newTestRunner(new ScanAttribute());
- runner.
- setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary1");
- runner.
- setProperty(ScanAttribute.MATCHING_CRITERIA, ScanAttribute.MATCH_CRITERIA_ALL);
+ runner.setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary1");
+ runner.setProperty(ScanAttribute.MATCHING_CRITERIA, ScanAttribute.MATCH_CRITERIA_ALL);
runner.setProperty(ScanAttribute.ATTRIBUTE_PATTERN, "a.*");
final Map<String, String> attributes = new HashMap<>();
@@ -106,8 +102,7 @@ public class TestScanAttribute {
@Test
public void testWithEmptyEntries() {
final TestRunner runner = TestRunners.newTestRunner(new ScanAttribute());
- runner.
- setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary-with-empty-new-lines");
+ runner.setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary-with-empty-new-lines");
final Map<String, String> attributes = new HashMap<>();
attributes.put("abc", "");
@@ -127,8 +122,7 @@ public class TestScanAttribute {
@Test
public void testWithDictionaryFilter() {
final TestRunner runner = TestRunners.newTestRunner(new ScanAttribute());
- runner.
- setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary-with-extra-info");
+ runner.setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary-with-extra-info");
runner.setProperty(ScanAttribute.DICTIONARY_FILTER, "(.*)<greeting>");
final Map<String, String> attributes = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/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 442aa63..8c36845 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
@@ -50,22 +50,15 @@ public class TestScanContent {
final byte[] termBytes = baos.toByteArray();
final Path dictionaryPath = Paths.get("target/dictionary");
- Files.
- write(dictionaryPath, termBytes, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
+ Files.write(dictionaryPath, termBytes, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
- final TestRunner runner = TestRunners.
- newTestRunner(new ScanContent());
+ final TestRunner runner = TestRunners.newTestRunner(new ScanContent());
runner.setThreadCount(1);
- runner.
- setProperty(ScanContent.DICTIONARY, dictionaryPath.
- toString());
- runner.
- setProperty(ScanContent.DICTIONARY_ENCODING, ScanContent.BINARY_ENCODING);
+ runner.setProperty(ScanContent.DICTIONARY, dictionaryPath.toString());
+ runner.setProperty(ScanContent.DICTIONARY_ENCODING, ScanContent.BINARY_ENCODING);
- runner.enqueue(Paths.
- get("src/test/resources/TestScanContent/helloWorld"));
- runner.enqueue(Paths.
- get("src/test/resources/TestScanContent/wellthengood-bye"));
+ runner.enqueue(Paths.get("src/test/resources/TestScanContent/helloWorld"));
+ runner.enqueue(Paths.get("src/test/resources/TestScanContent/wellthengood-bye"));
runner.enqueue(new byte[0]);
while (!runner.isQueueEmpty()) {
@@ -79,18 +72,13 @@ public class TestScanContent {
runner.assertTransferCount(ScanContent.REL_MATCH, 2);
runner.assertTransferCount(ScanContent.REL_NO_MATCH, 1);
- final List<MockFlowFile> matched = runner.
- getFlowFilesForRelationship(ScanContent.REL_MATCH);
- final List<MockFlowFile> unmatched = runner.
- getFlowFilesForRelationship(ScanContent.REL_NO_MATCH);
+ final List<MockFlowFile> matched = runner.getFlowFilesForRelationship(ScanContent.REL_MATCH);
+ final List<MockFlowFile> unmatched = runner.getFlowFilesForRelationship(ScanContent.REL_NO_MATCH);
- matched.get(0).
- assertAttributeEquals(ScanContent.MATCH_ATTRIBUTE_KEY, "hello");
- matched.get(1).
- assertAttributeEquals(ScanContent.MATCH_ATTRIBUTE_KEY, "good-bye");
+ matched.get(0).assertAttributeEquals(ScanContent.MATCH_ATTRIBUTE_KEY, "hello");
+ matched.get(1).assertAttributeEquals(ScanContent.MATCH_ATTRIBUTE_KEY, "good-bye");
- unmatched.get(0).
- assertAttributeNotExists(ScanContent.MATCH_ATTRIBUTE_KEY);
+ unmatched.get(0).assertAttributeNotExists(ScanContent.MATCH_ATTRIBUTE_KEY);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSegmentContent.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSegmentContent.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSegmentContent.java
index 7a6001c..5a88323 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSegmentContent.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSegmentContent.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.processors.standard.SegmentContent;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
@@ -32,15 +31,13 @@ public class TestSegmentContent {
@Test
public void test() throws IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new SegmentContent());
+ final TestRunner testRunner = TestRunners.newTestRunner(new SegmentContent());
testRunner.setProperty(SegmentContent.SIZE, "4 B");
testRunner.enqueue(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9});
testRunner.run();
- final List<MockFlowFile> flowFiles = testRunner.
- getFlowFilesForRelationship(SegmentContent.REL_SEGMENTS);
+ final List<MockFlowFile> flowFiles = testRunner.getFlowFilesForRelationship(SegmentContent.REL_SEGMENTS);
assertEquals(3, flowFiles.size());
final MockFlowFile out1 = flowFiles.get(0);
@@ -54,17 +51,14 @@ public class TestSegmentContent {
@Test
public void testTransferSmall() throws IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new SegmentContent());
+ final TestRunner testRunner = TestRunners.newTestRunner(new SegmentContent());
testRunner.setProperty(SegmentContent.SIZE, "4 KB");
testRunner.enqueue(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9});
testRunner.run();
testRunner.assertTransferCount(SegmentContent.REL_SEGMENTS, 1);
- final MockFlowFile out1 = testRunner.
- getFlowFilesForRelationship(SegmentContent.REL_SEGMENTS).
- get(0);
+ final MockFlowFile out1 = testRunner.getFlowFilesForRelationship(SegmentContent.REL_SEGMENTS).get(0);
out1.assertContentEquals(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9});
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestServer.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestServer.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestServer.java
index b9c623e..7e5dd7b 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestServer.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestServer.java
@@ -44,8 +44,7 @@ public class TestServer {
/**
* Creates the test server.
*
- * @param sslProperties SSLProps to be used in the secure connection. The
- * keys should should use the StandardSSLContextService properties.
+ * @param sslProperties SSLProps to be used in the secure connection. The keys should should use the StandardSSLContextService properties.
*/
public TestServer(final Map<String, String> sslProperties) {
createServer(sslProperties);
@@ -78,21 +77,15 @@ public class TestServer {
SslContextFactory ssl = new SslContextFactory();
if (sslProperties.get(StandardSSLContextService.KEYSTORE.getName()) != null) {
- ssl.setKeyStorePath(sslProperties.
- get(StandardSSLContextService.KEYSTORE.getName()));
- ssl.setKeyStorePassword(sslProperties.
- get(StandardSSLContextService.KEYSTORE_PASSWORD.getName()));
- ssl.setKeyStoreType(sslProperties.
- get(StandardSSLContextService.KEYSTORE_TYPE.getName()));
+ ssl.setKeyStorePath(sslProperties.get(StandardSSLContextService.KEYSTORE.getName()));
+ ssl.setKeyStorePassword(sslProperties.get(StandardSSLContextService.KEYSTORE_PASSWORD.getName()));
+ ssl.setKeyStoreType(sslProperties.get(StandardSSLContextService.KEYSTORE_TYPE.getName()));
}
if (sslProperties.get(StandardSSLContextService.TRUSTSTORE.getName()) != null) {
- ssl.setTrustStorePath(sslProperties.
- get(StandardSSLContextService.TRUSTSTORE.getName()));
- ssl.setTrustStorePassword(sslProperties.
- get(StandardSSLContextService.TRUSTSTORE_PASSWORD.getName()));
- ssl.setTrustStoreType(sslProperties.
- get(StandardSSLContextService.TRUSTSTORE_TYPE.getName()));
+ ssl.setTrustStorePath(sslProperties.get(StandardSSLContextService.TRUSTSTORE.getName()));
+ ssl.setTrustStorePassword(sslProperties.get(StandardSSLContextService.TRUSTSTORE_PASSWORD.getName()));
+ ssl.setTrustStoreType(sslProperties.get(StandardSSLContextService.TRUSTSTORE_TYPE.getName()));
}
final String clientAuth = sslProperties.get(NEED_CLIENT_AUTH);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitContent.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitContent.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitContent.java
index ea3da22..6d9fba9 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitContent.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitContent.java
@@ -16,8 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.processors.standard.MergeContent;
-import org.apache.nifi.processors.standard.SplitContent;
import java.io.IOException;
import java.util.List;
@@ -32,13 +30,10 @@ public class TestSplitContent {
@Test
public void testTextFormatLeadingPosition() {
final TestRunner runner = TestRunners.newTestRunner(new SplitContent());
- runner.setProperty(SplitContent.FORMAT, SplitContent.UTF8_FORMAT.
- getValue());
+ runner.setProperty(SplitContent.FORMAT, SplitContent.UTF8_FORMAT.getValue());
runner.setProperty(SplitContent.BYTE_SEQUENCE, "ub");
runner.setProperty(SplitContent.KEEP_SEQUENCE, "true");
- runner.
- setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.LEADING_POSITION.
- getValue());
+ runner.setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.LEADING_POSITION.getValue());
runner.enqueue("rub-a-dub-dub".getBytes());
runner.run();
@@ -47,31 +42,22 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 4);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals("r");
- splits.get(1).
- assertContentEquals("ub-a-d");
- splits.get(2).
- assertContentEquals("ub-d");
- splits.get(3).
- assertContentEquals("ub");
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ splits.get(0).assertContentEquals("r");
+ splits.get(1).assertContentEquals("ub-a-d");
+ splits.get(2).assertContentEquals("ub-d");
+ splits.get(3).assertContentEquals("ub");
}
@Test
public void testTextFormatSplits() {
final TestRunner runner = TestRunners.newTestRunner(new SplitContent());
- runner.setProperty(SplitContent.FORMAT, SplitContent.UTF8_FORMAT.
- getValue());
+ runner.setProperty(SplitContent.FORMAT, SplitContent.UTF8_FORMAT.getValue());
runner.setProperty(SplitContent.BYTE_SEQUENCE, "test");
runner.setProperty(SplitContent.KEEP_SEQUENCE, "true");
- runner.
- setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.LEADING_POSITION.
- getValue());
+ runner.setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.LEADING_POSITION.getValue());
- final byte[] input = "This is a test. This is another test. And this is yet another test. Finally this is the last Test.".
- getBytes();
+ final byte[] input = "This is a test. This is another test. And this is yet another test. Finally this is the last Test.".getBytes();
runner.enqueue(input);
runner.run();
@@ -79,16 +65,11 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 4);
runner.assertQueueEmpty();
- List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals("This is a ");
- splits.get(1).
- assertContentEquals("test. This is another ");
- splits.get(2).
- assertContentEquals("test. And this is yet another ");
- splits.get(3).
- assertContentEquals("test. Finally this is the last Test.");
+ List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ splits.get(0).assertContentEquals("This is a ");
+ splits.get(1).assertContentEquals("test. This is another ");
+ splits.get(2).assertContentEquals("test. And this is yet another ");
+ splits.get(3).assertContentEquals("test. Finally this is the last Test.");
runner.clearTransferState();
runner.setProperty(SplitContent.KEEP_SEQUENCE, "false");
@@ -97,77 +78,50 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitContent.REL_SPLITS, 4);
splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals("This is a ");
- splits.get(1).
- assertContentEquals(". This is another ");
- splits.get(2).
- assertContentEquals(". And this is yet another ");
- splits.get(3).
- assertContentEquals(". Finally this is the last Test.");
+ splits.get(0).assertContentEquals("This is a ");
+ splits.get(1).assertContentEquals(". This is another ");
+ splits.get(2).assertContentEquals(". And this is yet another ");
+ splits.get(3).assertContentEquals(". Finally this is the last Test.");
runner.clearTransferState();
runner.setProperty(SplitContent.KEEP_SEQUENCE, "true");
- runner.
- setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.TRAILING_POSITION.
- getValue());
+ runner.setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.TRAILING_POSITION.getValue());
runner.enqueue(input);
runner.run();
runner.assertTransferCount(SplitContent.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitContent.REL_SPLITS, 4);
splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals("This is a test");
- splits.get(1).
- assertContentEquals(". This is another test");
- splits.get(2).
- assertContentEquals(". And this is yet another test");
- splits.get(3).
- assertContentEquals(". Finally this is the last Test.");
+ splits.get(0).assertContentEquals("This is a test");
+ splits.get(1).assertContentEquals(". This is another test");
+ splits.get(2).assertContentEquals(". And this is yet another test");
+ splits.get(3).assertContentEquals(". Finally this is the last Test.");
runner.clearTransferState();
runner.setProperty(SplitContent.KEEP_SEQUENCE, "true");
- runner.
- setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.TRAILING_POSITION.
- getValue());
- runner.
- enqueue("This is a test. This is another test. And this is yet another test. Finally this is the last test".
- getBytes());
+ runner.setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.TRAILING_POSITION.getValue());
+ runner.enqueue("This is a test. This is another test. And this is yet another test. Finally this is the last test".getBytes());
runner.run();
runner.assertTransferCount(SplitContent.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitContent.REL_SPLITS, 4);
splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals("This is a test");
- splits.get(1).
- assertContentEquals(". This is another test");
- splits.get(2).
- assertContentEquals(". And this is yet another test");
- splits.get(3).
- assertContentEquals(". Finally this is the last test");
+ splits.get(0).assertContentEquals("This is a test");
+ splits.get(1).assertContentEquals(". This is another test");
+ splits.get(2).assertContentEquals(". And this is yet another test");
+ splits.get(3).assertContentEquals(". Finally this is the last test");
runner.clearTransferState();
runner.setProperty(SplitContent.KEEP_SEQUENCE, "true");
- runner.
- setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.LEADING_POSITION.
- getValue());
- runner.
- enqueue("This is a test. This is another test. And this is yet another test. Finally this is the last test".
- getBytes());
+ runner.setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.LEADING_POSITION.getValue());
+ runner.enqueue("This is a test. This is another test. And this is yet another test. Finally this is the last test".getBytes());
runner.run();
runner.assertTransferCount(SplitContent.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitContent.REL_SPLITS, 5);
splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals("This is a ");
- splits.get(1).
- assertContentEquals("test. This is another ");
- splits.get(2).
- assertContentEquals("test. And this is yet another ");
- splits.get(3).
- assertContentEquals("test. Finally this is the last ");
- splits.get(4).
- assertContentEquals("test");
+ splits.get(0).assertContentEquals("This is a ");
+ splits.get(1).assertContentEquals("test. This is another ");
+ splits.get(2).assertContentEquals("test. And this is yet another ");
+ splits.get(3).assertContentEquals("test. Finally this is the last ");
+ splits.get(4).assertContentEquals("test");
runner.clearTransferState();
}
@@ -175,13 +129,10 @@ public class TestSplitContent {
@Test
public void testTextFormatTrailingPosition() {
final TestRunner runner = TestRunners.newTestRunner(new SplitContent());
- runner.setProperty(SplitContent.FORMAT, SplitContent.UTF8_FORMAT.
- getValue());
+ runner.setProperty(SplitContent.FORMAT, SplitContent.UTF8_FORMAT.getValue());
runner.setProperty(SplitContent.BYTE_SEQUENCE, "ub");
runner.setProperty(SplitContent.KEEP_SEQUENCE, "true");
- runner.
- setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.TRAILING_POSITION.
- getValue());
+ runner.setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.TRAILING_POSITION.getValue());
runner.enqueue("rub-a-dub-dub".getBytes());
runner.run();
@@ -190,14 +141,10 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 3);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals("rub");
- splits.get(1).
- assertContentEquals("-a-dub");
- splits.get(2).
- assertContentEquals("-dub");
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ splits.get(0).assertContentEquals("rub");
+ splits.get(1).assertContentEquals("-a-dub");
+ splits.get(2).assertContentEquals("-dub");
}
@Test
@@ -206,16 +153,14 @@ public class TestSplitContent {
runner.setProperty(SplitContent.KEEP_SEQUENCE, "false");
runner.setProperty(SplitContent.BYTE_SEQUENCE.getName(), "FFFF");
- runner.
- enqueue(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 5, 4, 3, 2, 1});
+ runner.enqueue(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 5, 4, 3, 2, 1});
runner.run();
runner.assertTransferCount(SplitContent.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitContent.REL_SPLITS, 2);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
final MockFlowFile split2 = splits.get(1);
@@ -236,8 +181,7 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 2);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
final MockFlowFile split2 = splits.get(1);
@@ -261,8 +205,7 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 2);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
final MockFlowFile split2 = splits.get(1);
@@ -287,8 +230,7 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 2);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
final MockFlowFile split2 = splits.get(1);
@@ -310,8 +252,7 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 1);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
split1.assertContentEquals(new byte[]{1, 2, 3, 4});
@@ -331,8 +272,7 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 1);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
split1.assertContentEquals(new byte[]{1, 2, 3, 4, 5, 5, 5, 5});
@@ -352,8 +292,7 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 1);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
split1.assertContentEquals(new byte[]{1, 2, 3, 4});
@@ -373,12 +312,9 @@ public class TestSplitContent {
runner.assertTransferCount(SplitContent.REL_SPLITS, 2);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
- splits.get(0).
- assertContentEquals(new byte[]{5, 5, 5, 5});
- splits.get(1).
- assertContentEquals(new byte[]{1, 2, 3, 4});
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ splits.get(0).assertContentEquals(new byte[]{5, 5, 5, 5});
+ splits.get(1).assertContentEquals(new byte[]{1, 2, 3, 4});
}
@Test
@@ -387,29 +323,23 @@ public class TestSplitContent {
runner.setProperty(SplitContent.KEEP_SEQUENCE, "true");
runner.setProperty(SplitContent.BYTE_SEQUENCE.getName(), "FFFF");
- runner.
- enqueue(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 5, 4, 3, 2, 1});
+ runner.enqueue(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 5, 4, 3, 2, 1});
runner.run();
runner.assertTransferCount(SplitContent.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitContent.REL_SPLITS, 2);
runner.assertQueueEmpty();
- final List<MockFlowFile> splits = runner.
- getFlowFilesForRelationship(SplitContent.REL_SPLITS);
+ final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
final MockFlowFile split1 = splits.get(0);
final MockFlowFile split2 = splits.get(1);
- split1.
- assertContentEquals(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF});
+ split1.assertContentEquals(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF});
split2.assertContentEquals(new byte[]{(byte) 0xFF, 5, 4, 3, 2, 1});
- final TestRunner mergeRunner = TestRunners.
- newTestRunner(new MergeContent());
- mergeRunner.
- setProperty(MergeContent.MERGE_FORMAT, MergeContent.MERGE_FORMAT_CONCAT);
- mergeRunner.
- setProperty(MergeContent.MERGE_STRATEGY, MergeContent.MERGE_STRATEGY_DEFRAGMENT);
+ final TestRunner mergeRunner = TestRunners.newTestRunner(new MergeContent());
+ mergeRunner.setProperty(MergeContent.MERGE_FORMAT, MergeContent.MERGE_FORMAT_CONCAT);
+ mergeRunner.setProperty(MergeContent.MERGE_STRATEGY, MergeContent.MERGE_STRATEGY_DEFRAGMENT);
mergeRunner.enqueue(splits.toArray(new MockFlowFile[0]));
mergeRunner.run();
@@ -417,9 +347,7 @@ public class TestSplitContent {
mergeRunner.assertTransferCount(MergeContent.REL_ORIGINAL, 2);
mergeRunner.assertTransferCount(MergeContent.REL_FAILURE, 0);
- final List<MockFlowFile> packed = mergeRunner.
- getFlowFilesForRelationship(MergeContent.REL_MERGED);
- packed.get(0).
- assertContentEquals(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 5, 4, 3, 2, 1});
+ final List<MockFlowFile> packed = mergeRunner.getFlowFilesForRelationship(MergeContent.REL_MERGED);
+ packed.get(0).assertContentEquals(new byte[]{1, 2, 3, 4, 5, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 5, 4, 3, 2, 1});
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java
index 9503182..fc07386 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java
@@ -35,18 +35,15 @@ import java.nio.file.Paths;
public class TestSplitJson {
- private static final Path JSON_SNIPPET = Paths.
- get("src/test/resources/TestJson/json-sample.json");
- private static final Path XML_SNIPPET = Paths.
- get("src/test/resources/TestXml/xml-snippet.xml");
+ private static final Path JSON_SNIPPET = Paths.get("src/test/resources/TestJson/json-sample.json");
+ private static final Path XML_SNIPPET = Paths.get("src/test/resources/TestXml/xml-snippet.xml");
@Test(expected = AssertionError.class)
public void testInvalidJsonPath() {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$..");
- Assert.
- fail("An improper JsonPath expression was not detected as being invalid.");
+ Assert.fail("An improper JsonPath expression was not detected as being invalid.");
}
@Test
@@ -58,9 +55,7 @@ public class TestSplitJson {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(SplitJson.REL_FAILURE, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(SplitJson.REL_FAILURE).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(SplitJson.REL_FAILURE).get(0);
// Verify that the content was unchanged
out.assertContentEquals(XML_SNIPPET);
}
@@ -76,36 +71,28 @@ public class TestSplitJson {
Relationship expectedRel = SplitJson.REL_FAILURE;
testRunner.assertAllFlowFilesTransferred(expectedRel, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(expectedRel).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(expectedRel).get(0);
out.assertContentEquals(JSON_SNIPPET);
}
@Test
public void testSplit_arrayResult_oneValue() throws Exception {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
- testRunner.
- setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[0].range[?(@ == 0)]");
+ testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[0].range[?(@ == 0)]");
testRunner.enqueue(JSON_SNIPPET);
testRunner.run();
testRunner.assertTransferCount(SplitJson.REL_ORIGINAL, 1);
testRunner.assertTransferCount(SplitJson.REL_SPLIT, 1);
- testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).
- get(0).
- assertContentEquals(JSON_SNIPPET);
- testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).
- get(0).
- assertContentEquals("0");
+ testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0).assertContentEquals(JSON_SNIPPET);
+ testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).get(0).assertContentEquals("0");
}
@Test
public void testSplit_arrayResult_multipleValues() throws Exception {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
- testRunner.
- setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[0].range");
+ testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[0].range");
testRunner.enqueue(JSON_SNIPPET);
testRunner.run();
@@ -114,63 +101,49 @@ public class TestSplitJson {
testRunner.assertTransferCount(SplitJson.REL_ORIGINAL, 1);
testRunner.assertTransferCount(SplitJson.REL_SPLIT, numSplitsExpected);
- final MockFlowFile originalOut = testRunner.
- getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).
- get(0);
+ final MockFlowFile originalOut = testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0);
originalOut.assertContentEquals(JSON_SNIPPET);
}
@Test
public void testSplit_arrayResult_nonScalarValues() throws Exception {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
- testRunner.
- setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[*].name");
+ testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[*].name");
testRunner.enqueue(JSON_SNIPPET);
testRunner.run();
testRunner.assertTransferCount(SplitJson.REL_ORIGINAL, 1);
testRunner.assertTransferCount(SplitJson.REL_SPLIT, 7);
- testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).
- get(0).
- assertContentEquals(JSON_SNIPPET);
- testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).
- get(0).
- assertContentEquals("{\"first\":\"Shaffer\",\"last\":\"Pearson\"}");
+ testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0).assertContentEquals(JSON_SNIPPET);
+ testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).get(0).assertContentEquals("{\"first\":\"Shaffer\",\"last\":\"Pearson\"}");
}
@Test
public void testSplit_pathNotFound() throws Exception {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
- testRunner.
- setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.nonexistent");
+ testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.nonexistent");
testRunner.enqueue(JSON_SNIPPET);
testRunner.run();
testRunner.assertTransferCount(SplitJson.REL_FAILURE, 1);
- testRunner.getFlowFilesForRelationship(SplitJson.REL_FAILURE).
- get(0).
- assertContentEquals(JSON_SNIPPET);
+ testRunner.getFlowFilesForRelationship(SplitJson.REL_FAILURE).get(0).assertContentEquals(JSON_SNIPPET);
}
@Test
public void testSplit_pathToNullValue() throws Exception {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
- testRunner.
- setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.nullField");
+ testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.nullField");
- ProcessSession session = testRunner.getProcessSessionFactory().
- createSession();
+ ProcessSession session = testRunner.getProcessSessionFactory().createSession();
FlowFile ff = session.create();
ff = session.write(ff, new OutputStreamCallback() {
@Override
public void process(OutputStream out) throws IOException {
try (OutputStream outputStream = new BufferedOutputStream(out)) {
- outputStream.
- write("{\"stringField\": \"String Value\", \"nullField\": null}".
- getBytes(StandardCharsets.UTF_8));
+ outputStream.write("{\"stringField\": \"String Value\", \"nullField\": null}".getBytes(StandardCharsets.UTF_8));
}
}
});
@@ -184,20 +157,16 @@ public class TestSplitJson {
@Test
public void testSplit_pathToArrayWithNulls_emptyStringRepresentation() throws Exception {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
- testRunner.
- setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.arrayOfNulls");
+ testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.arrayOfNulls");
- ProcessSession session = testRunner.getProcessSessionFactory().
- createSession();
+ ProcessSession session = testRunner.getProcessSessionFactory().createSession();
FlowFile ff = session.create();
ff = session.write(ff, new OutputStreamCallback() {
@Override
public void process(OutputStream out) throws IOException {
try (OutputStream outputStream = new BufferedOutputStream(out)) {
- outputStream.
- write("{\"stringField\": \"String Value\", \"arrayOfNulls\": [null, null, null]}".
- getBytes(StandardCharsets.UTF_8));
+ outputStream.write("{\"stringField\": \"String Value\", \"arrayOfNulls\": [null, null, null]}".getBytes(StandardCharsets.UTF_8));
}
}
});
@@ -209,31 +178,25 @@ public class TestSplitJson {
int expectedFiles = 3;
testRunner.assertTransferCount(SplitJson.REL_SPLIT, expectedFiles);
for (int i = 0; i < expectedFiles; i++) {
- testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).
- get(i).
- assertContentEquals("");
+ testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).get(i).assertContentEquals("");
}
}
@Test
public void testSplit_pathToArrayWithNulls_nullStringRepresentation() throws Exception {
final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
- testRunner.
- setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.arrayOfNulls");
+ testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$.arrayOfNulls");
testRunner.setProperty(SplitJson.NULL_VALUE_DEFAULT_REPRESENTATION,
AbstractJsonPathProcessor.NULL_STRING_OPTION);
- ProcessSession session = testRunner.getProcessSessionFactory().
- createSession();
+ ProcessSession session = testRunner.getProcessSessionFactory().createSession();
FlowFile ff = session.create();
ff = session.write(ff, new OutputStreamCallback() {
@Override
public void process(OutputStream out) throws IOException {
try (OutputStream outputStream = new BufferedOutputStream(out)) {
- outputStream.
- write("{\"stringField\": \"String Value\", \"arrayOfNulls\": [null, null, null]}".
- getBytes(StandardCharsets.UTF_8));
+ outputStream.write("{\"stringField\": \"String Value\", \"arrayOfNulls\": [null, null, null]}".getBytes(StandardCharsets.UTF_8));
}
}
});
@@ -245,9 +208,7 @@ public class TestSplitJson {
int expectedFiles = 3;
testRunner.assertTransferCount(SplitJson.REL_SPLIT, expectedFiles);
for (int i = 0; i < expectedFiles; i++) {
- testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).
- get(i).
- assertContentEquals("null");
+ testRunner.getFlowFilesForRelationship(SplitJson.REL_SPLIT).get(i).assertContentEquals("null");
}
}
}