You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/10/24 10:26:33 UTC

[camel] branch main updated: CAMEL-18608: Fix the test FromFileToFtpSplitParallelIT.testSplit

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

nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 167e7fea6fe CAMEL-18608: Fix the test FromFileToFtpSplitParallelIT.testSplit
167e7fea6fe is described below

commit 167e7fea6fee04fbb0b81b547d01d1de6ece5f57
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Mon Oct 24 12:26:06 2022 +0200

    CAMEL-18608: Fix the test FromFileToFtpSplitParallelIT.testSplit
---
 .../integration/FromFileToFtpSplitParallelIT.java  | 30 ++++++++++------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java
index 6588617987a..867eceb567b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFileToFtpSplitParallelIT.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.file.remote.integration;
 
 import java.io.FileOutputStream;
+import java.io.PrintWriter;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
 import java.util.concurrent.TimeUnit;
@@ -25,13 +26,12 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.builder.ThreadPoolProfileBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spi.ThreadPoolProfile;
-import org.apache.camel.util.IOHelper;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
-public class FromFileToFtpSplitParallelIT extends FtpServerTestSupport {
+class FromFileToFtpSplitParallelIT extends FtpServerTestSupport {
 
-    private static final int SIZE = 5000;
+    private static final int SIZE = 5_000;
 
     @TempDir
     Path testDirectory;
@@ -41,24 +41,22 @@ public class FromFileToFtpSplitParallelIT extends FtpServerTestSupport {
     }
 
     @Test
-    public void testSplit() throws Exception {
+    void testSplit() throws Exception {
         // create big file
-        FileOutputStream fos = new FileOutputStream(testDirectory.toString() + "/bigdata.txt");
-        for (int i = 0; i < SIZE; i++) {
-            String line = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-" + i + "\n";
-            fos.write(line.getBytes(StandardCharsets.UTF_8));
+        try (PrintWriter writer = new PrintWriter(
+                new FileOutputStream(testDirectory.toString() + "/bigdata.txt"), true, StandardCharsets.UTF_8)) {
+            for (int i = 0; i < SIZE; i++) {
+                writer.printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ%d%n", i);
+            }
         }
-        IOHelper.close(fos);
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
         context.getRouteController().startAllRoutes();
 
-        MockEndpoint.assertIsSatisfied(context, 1, TimeUnit.MINUTES);
-
-        // use memory profiler
-        // Thread.sleep(99999999);
+        mock.setResultWaitTime(TimeUnit.MINUTES.toMillis(5));
+        mock.assertIsSatisfied();
     }
 
     @Override
@@ -66,12 +64,12 @@ public class FromFileToFtpSplitParallelIT extends FtpServerTestSupport {
         return new RouteBuilder() {
             public void configure() {
                 ThreadPoolProfile tpp
-                        = new ThreadPoolProfileBuilder("ftp-pool").poolSize(5).maxPoolSize(10).maxQueueSize(1000).build();
+                        = new ThreadPoolProfileBuilder("ftp-pool").poolSize(5).maxPoolSize(10).maxQueueSize(1_000).build();
                 context.getExecutorServiceManager().registerThreadPoolProfile(tpp);
 
-                onException().maximumRedeliveries(5).redeliveryDelay(1000);
+                onException().maximumRedeliveries(5).redeliveryDelay(1_000);
 
-                from(fileUri(testDirectory)).noAutoStartup().routeId("foo")
+                from(String.format("file:%s", testDirectory)).noAutoStartup().routeId("foo")
                     .split(body().tokenize("\n")).executorService("ftp-pool")
                         .to(getFtpUrl())
                         .to("log:line?groupSize=100")