From 73ddb43f53e956d20248891354e800474bda32e0 Mon Sep 17 00:00:00 2001 From: exceptionfactory Date: Tue, 20 Jul 2021 09:13:17 -0500 Subject: [PATCH] NIFI-8929 Upgraded Apache POI to 5.0.0 - Upgraded version 4.0.1 to 5.0.0 in nifi-email-processors and nifi-poi-processors - Removed unnecessary commons-logging dependency in nifi-email-processors Signed-off-by: Pierre Villard This closes #5234. --- .../nifi-email-processors/pom.xml | 7 +------ .../email/TestExtractTNEFAttachments.java | 19 +++++++------------ .../nifi-poi-processors/pom.xml | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml index bfb6b09734..3b5d3861c5 100644 --- a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml +++ b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/pom.xml @@ -99,15 +99,10 @@ - - commons-logging - commons-logging - 1.2 - org.apache.poi poi-scratchpad - 4.0.1 + 5.0.0 org.apache.nifi diff --git a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/test/java/org/apache/nifi/processors/email/TestExtractTNEFAttachments.java b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/test/java/org/apache/nifi/processors/email/TestExtractTNEFAttachments.java index 57ace41821..6438d98267 100644 --- a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/test/java/org/apache/nifi/processors/email/TestExtractTNEFAttachments.java +++ b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/test/java/org/apache/nifi/processors/email/TestExtractTNEFAttachments.java @@ -27,8 +27,6 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Random; - public class TestExtractTNEFAttachments { @@ -36,7 +34,6 @@ public class TestExtractTNEFAttachments { public void testValidTNEFWithoutAttachment() throws Exception { final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); - runner.enqueue(Paths.get("src/test/resources/winmail-simple.dat")); runner.run(); @@ -45,12 +42,11 @@ public class TestExtractTNEFAttachments { runner.assertTransferCount(ExtractEmailAttachments.REL_ATTACHMENTS, 0); // Have a look at the attachments... final List splits = runner.getFlowFilesForRelationship(ExtractEmailAttachments.REL_ATTACHMENTS); - Assert.assertTrue(splits.size() == 0); + Assert.assertEquals(0, splits.size()); } @Test public void testValidTNEFWithMultipleAttachments() throws Exception { - Random rnd = new Random() ; final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); runner.enqueue(Paths.get("src/test/resources/winmail-with-attachments.dat")); @@ -63,8 +59,8 @@ public class TestExtractTNEFAttachments { final List splits = runner.getFlowFilesForRelationship(ExtractTNEFAttachments.REL_ATTACHMENTS); List filenames = new ArrayList<>(); - for (int a = 0 ; a < splits.size() ; a++ ) { - filenames.add(splits.get(a).getAttribute("filename").toString()); + for (final MockFlowFile flowFile : splits) { + filenames.add(flowFile.getAttribute("filename")); } Assert.assertTrue(filenames.containsAll(Arrays.asList("nifiDrop.svg", "MINIFI~1.PNG"))); @@ -72,7 +68,6 @@ public class TestExtractTNEFAttachments { @Test public void testValidTNEFWithAttachment() throws Exception { - Random rnd = new Random() ; final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); runner.enqueue(Paths.get("src/test/resources/winmail-with-attachment.dat")); @@ -85,15 +80,15 @@ public class TestExtractTNEFAttachments { final List splits = runner.getFlowFilesForRelationship(ExtractTNEFAttachments.REL_ATTACHMENTS); List filenames = new ArrayList<>(); - for (int a = 0 ; a < splits.size() ; a++ ) { - filenames.add(splits.get(a).getAttribute("filename").toString()); + for (final MockFlowFile flowFile : splits) { + filenames.add(flowFile.getAttribute("filename")); } - Assert.assertTrue(filenames.containsAll(Arrays.asList("nifiDrop.svg"))); + Assert.assertTrue(filenames.contains("nifiDrop.svg")); } @Test - public void testInvalidTNEF() throws Exception { + public void testInvalidTNEF() { final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); runner.enqueue("test test test chocolate".getBytes()); runner.run(); diff --git a/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/pom.xml b/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/pom.xml index 17feaf2f68..2e5a960759 100644 --- a/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/pom.xml +++ b/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/pom.xml @@ -17,7 +17,7 @@ 4.0.0 - 4.0.1 + 5.0.0