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 <pierre.villard.fr@gmail.com>

This closes #5234.
This commit is contained in:
exceptionfactory 2021-07-20 09:13:17 -05:00 committed by Pierre Villard
parent cb020072f7
commit 73ddb43f53
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
3 changed files with 9 additions and 19 deletions

View File

@ -99,15 +99,10 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId> <artifactId>poi-scratchpad</artifactId>
<version>4.0.1</version> <version>5.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.nifi</groupId> <groupId>org.apache.nifi</groupId>

View File

@ -27,8 +27,6 @@ import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random;
public class TestExtractTNEFAttachments { public class TestExtractTNEFAttachments {
@ -36,7 +34,6 @@ public class TestExtractTNEFAttachments {
public void testValidTNEFWithoutAttachment() throws Exception { public void testValidTNEFWithoutAttachment() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments());
runner.enqueue(Paths.get("src/test/resources/winmail-simple.dat")); runner.enqueue(Paths.get("src/test/resources/winmail-simple.dat"));
runner.run(); runner.run();
@ -45,12 +42,11 @@ public class TestExtractTNEFAttachments {
runner.assertTransferCount(ExtractEmailAttachments.REL_ATTACHMENTS, 0); runner.assertTransferCount(ExtractEmailAttachments.REL_ATTACHMENTS, 0);
// Have a look at the attachments... // Have a look at the attachments...
final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(ExtractEmailAttachments.REL_ATTACHMENTS); final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(ExtractEmailAttachments.REL_ATTACHMENTS);
Assert.assertTrue(splits.size() == 0); Assert.assertEquals(0, splits.size());
} }
@Test @Test
public void testValidTNEFWithMultipleAttachments() throws Exception { public void testValidTNEFWithMultipleAttachments() throws Exception {
Random rnd = new Random() ;
final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments());
runner.enqueue(Paths.get("src/test/resources/winmail-with-attachments.dat")); runner.enqueue(Paths.get("src/test/resources/winmail-with-attachments.dat"));
@ -63,8 +59,8 @@ public class TestExtractTNEFAttachments {
final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(ExtractTNEFAttachments.REL_ATTACHMENTS); final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(ExtractTNEFAttachments.REL_ATTACHMENTS);
List<String> filenames = new ArrayList<>(); List<String> filenames = new ArrayList<>();
for (int a = 0 ; a < splits.size() ; a++ ) { for (final MockFlowFile flowFile : splits) {
filenames.add(splits.get(a).getAttribute("filename").toString()); filenames.add(flowFile.getAttribute("filename"));
} }
Assert.assertTrue(filenames.containsAll(Arrays.asList("nifiDrop.svg", "MINIFI~1.PNG"))); Assert.assertTrue(filenames.containsAll(Arrays.asList("nifiDrop.svg", "MINIFI~1.PNG")));
@ -72,7 +68,6 @@ public class TestExtractTNEFAttachments {
@Test @Test
public void testValidTNEFWithAttachment() throws Exception { public void testValidTNEFWithAttachment() throws Exception {
Random rnd = new Random() ;
final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments());
runner.enqueue(Paths.get("src/test/resources/winmail-with-attachment.dat")); runner.enqueue(Paths.get("src/test/resources/winmail-with-attachment.dat"));
@ -85,15 +80,15 @@ public class TestExtractTNEFAttachments {
final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(ExtractTNEFAttachments.REL_ATTACHMENTS); final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(ExtractTNEFAttachments.REL_ATTACHMENTS);
List<String> filenames = new ArrayList<>(); List<String> filenames = new ArrayList<>();
for (int a = 0 ; a < splits.size() ; a++ ) { for (final MockFlowFile flowFile : splits) {
filenames.add(splits.get(a).getAttribute("filename").toString()); filenames.add(flowFile.getAttribute("filename"));
} }
Assert.assertTrue(filenames.containsAll(Arrays.asList("nifiDrop.svg"))); Assert.assertTrue(filenames.contains("nifiDrop.svg"));
} }
@Test @Test
public void testInvalidTNEF() throws Exception { public void testInvalidTNEF() {
final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments()); final TestRunner runner = TestRunners.newTestRunner(new ExtractTNEFAttachments());
runner.enqueue("test test test chocolate".getBytes()); runner.enqueue("test test test chocolate".getBytes());
runner.run(); runner.run();

View File

@ -17,7 +17,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<properties> <properties>
<poi.version>4.0.1</poi.version> <poi.version>5.0.0</poi.version>
</properties> </properties>
<parent> <parent>