You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2022/04/19 16:25:13 UTC

[nifi] 01/09: NIFI-9924 Corrected text encoding in PutEmail filenames and TestFTP

This is an automated email from the ASF dual-hosted git repository.

joewitt pushed a commit to branch support/nifi-1.16
in repository https://gitbox.apache.org/repos/asf/nifi.git

commit f50b615a1243f8ed93446bec70cf8645abf8da8a
Author: Paul Grey <gr...@yahoo.com>
AuthorDate: Thu Apr 14 11:53:50 2022 -0400

    NIFI-9924 Corrected text encoding in PutEmail filenames and TestFTP
    
    This closes #5967
    
    Signed-off-by: David Handermann <ex...@apache.org>
---
 .../apache/nifi/processors/standard/PutEmail.java  |  2 +-
 .../apache/nifi/processors/standard/TestFTP.java   | 23 ++++++++++++----------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java
index f03da5b737..c083f26abe 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java
@@ -382,7 +382,7 @@ public class PutEmail extends AbstractProcessor {
                     }
                 });
 
-                mimeFile.setFileName(MimeUtility.encodeText(flowFile.getAttribute(CoreAttributes.FILENAME.key())));
+                mimeFile.setFileName(MimeUtility.encodeText(flowFile.getAttribute(CoreAttributes.FILENAME.key()), CONTENT_CHARSET.name(), null));
                 final MimeMultipart multipart = new MimeMultipart();
                 multipart.addBodyPart(mimeText);
                 multipart.addBodyPart(mimeFile);
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFTP.java
index 5809ea4359..1993aad6ea 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFTP.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFTP.java
@@ -35,10 +35,11 @@ import org.apache.nifi.util.MockFlowFile;
 import org.apache.nifi.util.MockProcessContext;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
 import org.mockftpserver.fake.FakeFtpServer;
 import org.mockftpserver.fake.UserAccount;
 import org.mockftpserver.fake.filesystem.DirectoryEntry;
@@ -53,7 +54,7 @@ public class TestFTP {
     final String password = "Test test test chocolate";
     int ftpPort;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         fakeFtpServer.setServerControlPort(0);
         fakeFtpServer.addUserAccount(new UserAccount(username, password, "c:\\data"));
@@ -67,7 +68,7 @@ public class TestFTP {
         ftpPort = fakeFtpServer.getServerControlPort();
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         fakeFtpServer.stop();
     }
@@ -142,7 +143,7 @@ public class TestFTP {
         FileSystem results = fakeFtpServer.getFileSystem();
 
         // Check file was uploaded
-        Assert.assertTrue(results.exists("c:\\data\\randombytes-1"));
+        Assertions.assertTrue(results.exists("c:\\data\\randombytes-1"));
     }
 
     @Test
@@ -205,7 +206,7 @@ public class TestFTP {
         results.add(sampleFile);
 
         // Check file exists
-        Assert.assertTrue(results.exists("c:\\data\\randombytes-2"));
+        Assertions.assertTrue(results.exists("c:\\data\\randombytes-2"));
 
         TestRunner runner = TestRunners.newTestRunner(GetFTP.class);
         runner.setProperty(FTPTransfer.HOSTNAME, "localhost");
@@ -229,7 +230,7 @@ public class TestFTP {
         results.add(sampleFile);
 
         // Check file exists
-        Assert.assertTrue(results.exists("c:\\data\\randombytes-2"));
+        Assertions.assertTrue(results.exists("c:\\data\\randombytes-2"));
 
         TestRunner runner = TestRunners.newTestRunner(FetchFTP.class);
         runner.setProperty(FetchFTP.HOSTNAME, "${host}");
@@ -254,6 +255,8 @@ public class TestFTP {
     }
 
     @Test
+    @EnabledIfSystemProperty(named = "file.encoding", matches = "UTF-8",
+            disabledReason = "org.mockftpserver does not support specification of charset")
     public void basicFileFetchWithUTF8FileName() throws IOException {
         FileSystem fs = fakeFtpServer.getFileSystem();
 
@@ -289,7 +292,7 @@ public class TestFTP {
         results.add(sampleFile);
 
         // Check file exists
-        Assert.assertTrue(results.exists("c:\\data\\randombytes-2"));
+        Assertions.assertTrue(results.exists("c:\\data\\randombytes-2"));
 
         TestRunner runner = TestRunners.newTestRunner(ListFTP.class);
         runner.setProperty(ListFTP.HOSTNAME, "localhost");