Repository: incubator-nifi Updated Branches: refs/heads/develop 548188939 -> d29a2d688
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/TestSplitText.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitText.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitText.java index aeb887a..aa28cc0 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitText.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitText.java @@ -36,16 +36,6 @@ public class TestSplitText { final Path dataPath = Paths.get("src/test/resources/TestSplitText"); final Path file = dataPath.resolve(originalFilename); -// public static void main(final String[] args) throws IOException { -// for (int i=1; i <= 4; i++) { -// final Path path = Paths.get("src/test/resources/TestSplitText/" + i + ".txt"); -// final byte[] data = Files.readAllBytes(path); -// final String text = new String(data, StandardCharsets.UTF_8); -// final String updated = text.replace("\n", "\r\n"); -// final Path updatedPath = Paths.get("src/test/resources/TestSplitText/updated/" + i + ".txt"); -// Files.write(updatedPath, updated.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW); -// } -// } @Test public void testRoutesToFailureIfHeaderLinesNotAllPresent() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new SplitText()); @@ -81,22 +71,17 @@ public class TestSplitText { runner.assertTransferCount(SplitText.REL_ORIGINAL, 1); runner.assertTransferCount(SplitText.REL_SPLITS, 4); - final List<MockFlowFile> splits = runner. - getFlowFilesForRelationship(SplitText.REL_SPLITS); + final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitText.REL_SPLITS); final String expected0 = "Header Line #1\nHeader Line #2\nLine #1"; final String expected1 = "Line #2\nLine #3\nLine #4"; final String expected2 = "Line #5\nLine #6\nLine #7"; final String expected3 = "Line #8\nLine #9\nLine #10"; - splits.get(0). - assertContentEquals(expected0); - splits.get(1). - assertContentEquals(expected1); - splits.get(2). - assertContentEquals(expected2); - splits.get(3). - assertContentEquals(expected3); + splits.get(0).assertContentEquals(expected0); + splits.get(1).assertContentEquals(expected1); + splits.get(2).assertContentEquals(expected2); + splits.get(3).assertContentEquals(expected3); } @Test @@ -112,14 +97,11 @@ public class TestSplitText { runner.assertTransferCount(SplitText.REL_ORIGINAL, 1); runner.assertTransferCount(SplitText.REL_SPLITS, 4); - final List<MockFlowFile> splits = runner. - getFlowFilesForRelationship(SplitText.REL_SPLITS); + final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitText.REL_SPLITS); for (int i = 0; i < splits.size(); i++) { final MockFlowFile split = splits.get(i); - split.assertContentEquals(file.getParent(). - resolve((i + 1) + ".txt")); - split.assertAttributeEquals(SplitText.FRAGMENT_INDEX, String. - valueOf(i + 1)); + split.assertContentEquals(file.getParent().resolve((i + 1) + ".txt")); + split.assertAttributeEquals(SplitText.FRAGMENT_INDEX, String.valueOf(i + 1)); } } @@ -136,26 +118,16 @@ public class TestSplitText { runner.assertTransferCount(SplitText.REL_ORIGINAL, 1); runner.assertTransferCount(SplitText.REL_SPLITS, 2); - final List<MockFlowFile> splits = runner. - getFlowFilesForRelationship(SplitText.REL_SPLITS); - splits.get(0). - assertContentEquals(file.getParent(). - resolve("5.txt")); - splits.get(0). - assertAttributeEquals(SplitText.FRAGMENT_INDEX, String. - valueOf(1)); - splits.get(1). - assertContentEquals(file.getParent(). - resolve("6.txt")); - splits.get(1). - assertAttributeEquals(SplitText.FRAGMENT_INDEX, String. - valueOf(2)); + final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitText.REL_SPLITS); + splits.get(0).assertContentEquals(file.getParent().resolve("5.txt")); + splits.get(0).assertAttributeEquals(SplitText.FRAGMENT_INDEX, String.valueOf(1)); + splits.get(1).assertContentEquals(file.getParent().resolve("6.txt")); + splits.get(1).assertAttributeEquals(SplitText.FRAGMENT_INDEX, String.valueOf(2)); } @Test public void testSplitThenMerge() throws IOException { - final TestRunner splitRunner = TestRunners. - newTestRunner(new SplitText()); + final TestRunner splitRunner = TestRunners.newTestRunner(new SplitText()); splitRunner.setProperty(SplitText.LINE_SPLIT_COUNT, "3"); splitRunner.setProperty(SplitText.REMOVE_TRAILING_NEWLINES, "false"); @@ -166,20 +138,15 @@ public class TestSplitText { splitRunner.assertTransferCount(SplitText.REL_ORIGINAL, 1); splitRunner.assertTransferCount(SplitText.REL_FAILURE, 0); - final List<MockFlowFile> splits = splitRunner. - getFlowFilesForRelationship(SplitText.REL_SPLITS); + final List<MockFlowFile> splits = splitRunner.getFlowFilesForRelationship(SplitText.REL_SPLITS); for (final MockFlowFile flowFile : splits) { - flowFile. - assertAttributeEquals(SplitText.SEGMENT_ORIGINAL_FILENAME, originalFilename); + flowFile.assertAttributeEquals(SplitText.SEGMENT_ORIGINAL_FILENAME, originalFilename); flowFile.assertAttributeEquals(SplitText.FRAGMENT_COUNT, "4"); } - 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(); @@ -187,13 +154,10 @@ public class TestSplitText { mergeRunner.assertTransferCount(MergeContent.REL_ORIGINAL, 4); mergeRunner.assertTransferCount(MergeContent.REL_FAILURE, 0); - final List<MockFlowFile> packed = mergeRunner. - getFlowFilesForRelationship(MergeContent.REL_MERGED); + final List<MockFlowFile> packed = mergeRunner.getFlowFilesForRelationship(MergeContent.REL_MERGED); MockFlowFile flowFile = packed.get(0); - flowFile. - assertAttributeEquals(CoreAttributes.FILENAME.key(), originalFilename); - assertEquals(Files.size(dataPath.resolve(originalFilename)), flowFile. - getSize()); + flowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), originalFilename); + assertEquals(Files.size(dataPath.resolve(originalFilename)), flowFile.getSize()); flowFile.assertContentEquals(file); } } 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/TestSplitXml.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitXml.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitXml.java index 3f9e426..a84e031 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitXml.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitXml.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.processors.standard; -import org.apache.nifi.processors.standard.SplitXml; import java.io.IOException; import java.io.StringReader; import java.nio.file.Paths; @@ -97,8 +96,7 @@ public class TestSplitXml { for (MockFlowFile out : flowfiles) { final byte[] outData = out.toByteArray(); final String outXml = new String(outData, "UTF-8"); - saxParser. - parse(new InputSource(new StringReader(outXml)), new DefaultHandler()); + saxParser.parse(new InputSource(new StringReader(outXml)), new DefaultHandler()); } } } 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/TestTransformXml.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestTransformXml.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestTransformXml.java index 620cb77..7074ec9 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestTransformXml.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestTransformXml.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.processors.standard; -import org.apache.nifi.processors.standard.TransformXml; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -39,18 +38,15 @@ public class TestTransformXml { @Test public void testStylesheetNotFound() throws IOException { - final TestRunner controller = TestRunners. - newTestRunner(TransformXml.class); - controller. - setProperty(TransformXml.XSLT_FILE_NAME, "/no/path/to/math.xsl"); + final TestRunner controller = TestRunners.newTestRunner(TransformXml.class); + controller.setProperty(TransformXml.XSLT_FILE_NAME, "/no/path/to/math.xsl"); controller.assertNotValid(); } @Test public void testNonXmlContent() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new TransformXml()); - runner. - setProperty(TransformXml.XSLT_FILE_NAME, "src/test/resources/TestTransformXml/math.xsl"); + runner.setProperty(TransformXml.XSLT_FILE_NAME, "src/test/resources/TestTransformXml/math.xsl"); final Map<String, String> attributes = new HashMap<>(); runner.enqueue("not xml".getBytes(), attributes); @@ -58,11 +54,8 @@ public class TestTransformXml { runner.run(); runner.assertAllFlowFilesTransferred(TransformXml.REL_FAILURE); - final MockFlowFile original = runner. - getFlowFilesForRelationship(TransformXml.REL_FAILURE). - get(0); + final MockFlowFile original = runner.getFlowFilesForRelationship(TransformXml.REL_FAILURE).get(0); final String originalContent = new String(original.toByteArray(), StandardCharsets.UTF_8); - System.out.println("originalContent:\n" + originalContent); original.assertContentEquals("not xml"); } @@ -72,32 +65,24 @@ public class TestTransformXml { public void testTransformMath() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new TransformXml()); runner.setProperty("header", "Test for mod"); - runner. - setProperty(TransformXml.XSLT_FILE_NAME, "src/test/resources/TestTransformXml/math.xsl"); + runner.setProperty(TransformXml.XSLT_FILE_NAME, "src/test/resources/TestTransformXml/math.xsl"); final Map<String, String> attributes = new HashMap<>(); - runner. - enqueue(Paths. - get("src/test/resources/TestTransformXml/math.xml"), attributes); + runner.enqueue(Paths.get("src/test/resources/TestTransformXml/math.xml"), attributes); runner.run(); runner.assertAllFlowFilesTransferred(TransformXml.REL_SUCCESS); - final MockFlowFile transformed = runner. - getFlowFilesForRelationship(TransformXml.REL_SUCCESS). - get(0); + final MockFlowFile transformed = runner.getFlowFilesForRelationship(TransformXml.REL_SUCCESS).get(0); final String transformedContent = new String(transformed.toByteArray(), StandardCharsets.UTF_8); - System.out.println("transformedContent:\n" + transformedContent); - transformed.assertContentEquals(Paths. - get("src/test/resources/TestTransformXml/math.html")); + transformed.assertContentEquals(Paths.get("src/test/resources/TestTransformXml/math.html")); } @Ignore("this test fails") @Test public void testTransformCsv() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new TransformXml()); - runner. - setProperty(TransformXml.XSLT_FILE_NAME, "src/test/resources/TestTransformXml/tokens.xsl"); + runner.setProperty(TransformXml.XSLT_FILE_NAME, "src/test/resources/TestTransformXml/tokens.xsl"); runner.setProperty("uuid_0", "${uuid_0}"); runner.setProperty("uuid_1", "${uuid_1}"); @@ -113,24 +98,18 @@ public class TestTransformXml { String line = null; while ((line = reader.readLine()) != null) { - builder.append(line). - append("\n"); + builder.append(line).append("\n"); } builder.append("</data>"); String data = builder.toString(); - System.out.println("Original content:\n" + data); runner.enqueue(data.getBytes(), attributes); runner.run(); runner.assertAllFlowFilesTransferred(TransformXml.REL_SUCCESS); - final MockFlowFile transformed = runner. - getFlowFilesForRelationship(TransformXml.REL_SUCCESS). - get(0); + final MockFlowFile transformed = runner.getFlowFilesForRelationship(TransformXml.REL_SUCCESS).get(0); final String transformedContent = new String(transformed.toByteArray(), StandardCharsets.ISO_8859_1); - System.out.println("transformedContent:\n" + transformedContent); - transformed.assertContentEquals(Paths. - get("src/test/resources/TestTransformXml/tokens.xml")); + transformed.assertContentEquals(Paths.get("src/test/resources/TestTransformXml/tokens.xml")); } } 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/TestUnpackContent.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUnpackContent.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUnpackContent.java index 6035e08..04fe05a 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUnpackContent.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUnpackContent.java @@ -16,8 +16,6 @@ */ package org.apache.nifi.processors.standard; -import org.apache.nifi.processors.standard.UnpackContent; -import org.apache.nifi.processors.standard.MergeContent; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -36,14 +34,12 @@ import org.junit.Test; public class TestUnpackContent { - private static final Path dataPath = Paths. - get("src/test/resources/TestUnpackContent"); + private static final Path dataPath = Paths.get("src/test/resources/TestUnpackContent"); @Test public void testTar() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new UnpackContent()); - runner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.TAR_FORMAT); + runner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.TAR_FORMAT); runner.enqueue(dataPath.resolve("data.tar")); runner.run(); @@ -52,15 +48,11 @@ public class TestUnpackContent { runner.assertTransferCount(UnpackContent.REL_ORIGINAL, 1); runner.assertTransferCount(UnpackContent.REL_FAILURE, 0); - final List<MockFlowFile> unpacked = runner. - getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); + final List<MockFlowFile> unpacked = runner.getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); for (final MockFlowFile flowFile : unpacked) { - final String filename = flowFile. - getAttribute(CoreAttributes.FILENAME.key()); - final String folder = flowFile.getAttribute(CoreAttributes.PATH. - key()); - final Path path = dataPath.resolve(folder). - resolve(filename); + final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key()); + final String folder = flowFile.getAttribute(CoreAttributes.PATH.key()); + final Path path = dataPath.resolve(folder).resolve(filename); assertTrue(Files.exists(path)); flowFile.assertContentEquals(path.toFile()); @@ -70,8 +62,7 @@ public class TestUnpackContent { @Test public void testZip() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new UnpackContent()); - runner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.ZIP_FORMAT); + runner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.ZIP_FORMAT); runner.enqueue(dataPath.resolve("data.zip")); runner.run(); @@ -80,15 +71,11 @@ public class TestUnpackContent { runner.assertTransferCount(UnpackContent.REL_ORIGINAL, 1); runner.assertTransferCount(UnpackContent.REL_FAILURE, 0); - final List<MockFlowFile> unpacked = runner. - getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); + final List<MockFlowFile> unpacked = runner.getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); for (final MockFlowFile flowFile : unpacked) { - final String filename = flowFile. - getAttribute(CoreAttributes.FILENAME.key()); - final String folder = flowFile.getAttribute(CoreAttributes.PATH. - key()); - final Path path = dataPath.resolve(folder). - resolve(filename); + final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key()); + final String folder = flowFile.getAttribute(CoreAttributes.PATH.key()); + final Path path = dataPath.resolve(folder).resolve(filename); assertTrue(Files.exists(path)); flowFile.assertContentEquals(path.toFile()); @@ -98,8 +85,7 @@ public class TestUnpackContent { @Test public void testFlowFileStreamV3() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new UnpackContent()); - runner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.FLOWFILE_STREAM_FORMAT_V3); + runner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.FLOWFILE_STREAM_FORMAT_V3); runner.enqueue(dataPath.resolve("data.flowfilev3")); runner.run(); @@ -108,15 +94,11 @@ public class TestUnpackContent { runner.assertTransferCount(UnpackContent.REL_ORIGINAL, 1); runner.assertTransferCount(UnpackContent.REL_FAILURE, 0); - final List<MockFlowFile> unpacked = runner. - getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); + final List<MockFlowFile> unpacked = runner.getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); for (final MockFlowFile flowFile : unpacked) { - final String filename = flowFile. - getAttribute(CoreAttributes.FILENAME.key()); - final String folder = flowFile.getAttribute(CoreAttributes.PATH. - key()); - final Path path = dataPath.resolve(folder). - resolve(filename); + final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key()); + final String folder = flowFile.getAttribute(CoreAttributes.PATH.key()); + final Path path = dataPath.resolve(folder).resolve(filename); assertTrue(Files.exists(path)); flowFile.assertContentEquals(path.toFile()); @@ -126,8 +108,7 @@ public class TestUnpackContent { @Test public void testFlowFileStreamV2() throws IOException { final TestRunner runner = TestRunners.newTestRunner(new UnpackContent()); - runner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.FLOWFILE_STREAM_FORMAT_V2); + runner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.FLOWFILE_STREAM_FORMAT_V2); runner.enqueue(dataPath.resolve("data.flowfilev2")); runner.run(); @@ -136,15 +117,11 @@ public class TestUnpackContent { runner.assertTransferCount(UnpackContent.REL_ORIGINAL, 1); runner.assertTransferCount(UnpackContent.REL_FAILURE, 0); - final List<MockFlowFile> unpacked = runner. - getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); + final List<MockFlowFile> unpacked = runner.getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); for (final MockFlowFile flowFile : unpacked) { - final String filename = flowFile. - getAttribute(CoreAttributes.FILENAME.key()); - final String folder = flowFile.getAttribute(CoreAttributes.PATH. - key()); - final Path path = dataPath.resolve(folder). - resolve(filename); + final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key()); + final String folder = flowFile.getAttribute(CoreAttributes.PATH.key()); + final Path path = dataPath.resolve(folder).resolve(filename); assertTrue(Files.exists(path)); flowFile.assertContentEquals(path.toFile()); @@ -153,10 +130,8 @@ public class TestUnpackContent { @Test public void testTarThenMerge() throws IOException { - final TestRunner unpackRunner = TestRunners. - newTestRunner(new UnpackContent()); - unpackRunner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.TAR_FORMAT); + final TestRunner unpackRunner = TestRunners.newTestRunner(new UnpackContent()); + unpackRunner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.TAR_FORMAT); unpackRunner.enqueue(dataPath.resolve("data.tar")); unpackRunner.run(); @@ -165,19 +140,14 @@ public class TestUnpackContent { unpackRunner.assertTransferCount(UnpackContent.REL_ORIGINAL, 1); unpackRunner.assertTransferCount(UnpackContent.REL_FAILURE, 0); - final List<MockFlowFile> unpacked = unpackRunner. - getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); + final List<MockFlowFile> unpacked = unpackRunner.getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); for (final MockFlowFile flowFile : unpacked) { - assertEquals(flowFile. - getAttribute(UnpackContent.SEGMENT_ORIGINAL_FILENAME), "data"); + assertEquals(flowFile.getAttribute(UnpackContent.SEGMENT_ORIGINAL_FILENAME), "data"); } - final TestRunner mergeRunner = TestRunners. - newTestRunner(new MergeContent()); - mergeRunner. - setProperty(MergeContent.MERGE_FORMAT, MergeContent.MERGE_FORMAT_TAR); - mergeRunner. - setProperty(MergeContent.MERGE_STRATEGY, MergeContent.MERGE_STRATEGY_DEFRAGMENT); + final TestRunner mergeRunner = TestRunners.newTestRunner(new MergeContent()); + mergeRunner.setProperty(MergeContent.MERGE_FORMAT, MergeContent.MERGE_FORMAT_TAR); + mergeRunner.setProperty(MergeContent.MERGE_STRATEGY, MergeContent.MERGE_STRATEGY_DEFRAGMENT); mergeRunner.setProperty(MergeContent.KEEP_PATH, "true"); mergeRunner.enqueue(unpacked.toArray(new MockFlowFile[0])); mergeRunner.run(); @@ -186,20 +156,16 @@ public class TestUnpackContent { mergeRunner.assertTransferCount(MergeContent.REL_ORIGINAL, 2); mergeRunner.assertTransferCount(MergeContent.REL_FAILURE, 0); - final List<MockFlowFile> packed = mergeRunner. - getFlowFilesForRelationship(MergeContent.REL_MERGED); + final List<MockFlowFile> packed = mergeRunner.getFlowFilesForRelationship(MergeContent.REL_MERGED); for (final MockFlowFile flowFile : packed) { - flowFile. - assertAttributeEquals(CoreAttributes.FILENAME.key(), "data.tar"); + flowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), "data.tar"); } } @Test public void testZipThenMerge() throws IOException { - final TestRunner unpackRunner = TestRunners. - newTestRunner(new UnpackContent()); - unpackRunner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.ZIP_FORMAT); + final TestRunner unpackRunner = TestRunners.newTestRunner(new UnpackContent()); + unpackRunner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.ZIP_FORMAT); unpackRunner.enqueue(dataPath.resolve("data.zip")); unpackRunner.run(); @@ -208,19 +174,14 @@ public class TestUnpackContent { unpackRunner.assertTransferCount(UnpackContent.REL_ORIGINAL, 1); unpackRunner.assertTransferCount(UnpackContent.REL_FAILURE, 0); - final List<MockFlowFile> unpacked = unpackRunner. - getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); + final List<MockFlowFile> unpacked = unpackRunner.getFlowFilesForRelationship(UnpackContent.REL_SUCCESS); for (final MockFlowFile flowFile : unpacked) { - assertEquals(flowFile. - getAttribute(UnpackContent.SEGMENT_ORIGINAL_FILENAME), "data"); + assertEquals(flowFile.getAttribute(UnpackContent.SEGMENT_ORIGINAL_FILENAME), "data"); } - final TestRunner mergeRunner = TestRunners. - newTestRunner(new MergeContent()); - mergeRunner. - setProperty(MergeContent.MERGE_FORMAT, MergeContent.MERGE_FORMAT_ZIP); - mergeRunner. - setProperty(MergeContent.MERGE_STRATEGY, MergeContent.MERGE_STRATEGY_DEFRAGMENT); + final TestRunner mergeRunner = TestRunners.newTestRunner(new MergeContent()); + mergeRunner.setProperty(MergeContent.MERGE_FORMAT, MergeContent.MERGE_FORMAT_ZIP); + mergeRunner.setProperty(MergeContent.MERGE_STRATEGY, MergeContent.MERGE_STRATEGY_DEFRAGMENT); mergeRunner.setProperty(MergeContent.KEEP_PATH, "true"); mergeRunner.enqueue(unpacked.toArray(new MockFlowFile[0])); mergeRunner.run(); @@ -229,20 +190,16 @@ public class TestUnpackContent { mergeRunner.assertTransferCount(MergeContent.REL_ORIGINAL, 2); mergeRunner.assertTransferCount(MergeContent.REL_FAILURE, 0); - final List<MockFlowFile> packed = mergeRunner. - getFlowFilesForRelationship(MergeContent.REL_MERGED); + final List<MockFlowFile> packed = mergeRunner.getFlowFilesForRelationship(MergeContent.REL_MERGED); for (final MockFlowFile flowFile : packed) { - flowFile. - assertAttributeEquals(CoreAttributes.FILENAME.key(), "data.zip"); + flowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), "data.zip"); } } @Test public void testZipHandlesBadData() throws IOException { - final TestRunner unpackRunner = TestRunners. - newTestRunner(new UnpackContent()); - unpackRunner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.ZIP_FORMAT); + final TestRunner unpackRunner = TestRunners.newTestRunner(new UnpackContent()); + unpackRunner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.ZIP_FORMAT); unpackRunner.enqueue(dataPath.resolve("data.tar")); unpackRunner.run(); @@ -254,10 +211,8 @@ public class TestUnpackContent { @Test public void testTarHandlesBadData() throws IOException { - final TestRunner unpackRunner = TestRunners. - newTestRunner(new UnpackContent()); - unpackRunner. - setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.TAR_FORMAT); + final TestRunner unpackRunner = TestRunners.newTestRunner(new UnpackContent()); + unpackRunner.setProperty(UnpackContent.PACKAGING_FORMAT, UnpackContent.TAR_FORMAT); unpackRunner.enqueue(dataPath.resolve("data.zip")); unpackRunner.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/TestValidateXml.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestValidateXml.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestValidateXml.java index d550183..7dfe5b6 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestValidateXml.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestValidateXml.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.processors.standard; -import org.apache.nifi.processors.standard.ValidateXml; import java.io.IOException; import java.nio.file.Paths; @@ -31,8 +30,7 @@ public class TestValidateXml { @Test public void testValid() throws IOException, SAXException { final TestRunner runner = TestRunners.newTestRunner(new ValidateXml()); - runner. - setProperty(ValidateXml.SCHEMA_FILE, "src/test/resources/TestXml/XmlBundle.xsd"); + runner.setProperty(ValidateXml.SCHEMA_FILE, "src/test/resources/TestXml/XmlBundle.xsd"); runner.enqueue(Paths.get("src/test/resources/TestXml/xml-snippet.xml")); 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/UserAgentTestingServlet.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/UserAgentTestingServlet.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/UserAgentTestingServlet.java index 347c338..e7fee65 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/UserAgentTestingServlet.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/UserAgentTestingServlet.java @@ -37,6 +37,5 @@ public class UserAgentTestingServlet extends HttpServlet { } else { response.setStatus(500); } - return; } }