You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/07/08 20:06:40 UTC

[camel] branch main updated: (chores) camel-core: FileProducerCharsetUTFOptimizedTest cleanup

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

orpiske 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 f419760f66c (chores) camel-core: FileProducerCharsetUTFOptimizedTest cleanup
f419760f66c is described below

commit f419760f66c45dcb63a8a6ebc72b5408cf61f6ae
Author: Otavio R. Piske <an...@gmail.com>
AuthorDate: Sat Jul 8 21:11:57 2023 +0200

    (chores) camel-core: FileProducerCharsetUTFOptimizedTest cleanup
    
    - separate test setup from execution
    - add data cleanup after execution
    
    Signed-off-by: Otavio R. Piske <an...@gmail.com>
---
 .../file/FileProducerCharsetUTFOptimizedTest.java         | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFOptimizedTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFOptimizedTest.java
index 8302559f5bc..198d4aeebab 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFOptimizedTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFOptimizedTest.java
@@ -16,12 +16,15 @@
  */
 package org.apache.camel.component.file;
 
+import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@@ -35,8 +38,8 @@ public class FileProducerCharsetUTFOptimizedTest extends ContextTestSupport {
     // use utf-8 as original payload with 00e6 which is a danish ae letter
     private byte[] utf = "ABC\u00e6D\uD867\uDE3DE\uD83C\uDFF3".getBytes(StandardCharsets.UTF_8);
 
-    @Test
-    public void testFileProducerCharsetUTFOptimized() throws Exception {
+    @BeforeEach
+    public void createData() throws IOException {
         testDirectory("input", true);
 
         log.debug("utf: {}", new String(utf, StandardCharsets.UTF_8));
@@ -47,7 +50,10 @@ public class FileProducerCharsetUTFOptimizedTest extends ContextTestSupport {
         try (OutputStream fos = Files.newOutputStream(testFile("input/input.txt"))) {
             fos.write(utf);
         }
+    }
 
+    @Test
+    public void testFileProducerCharsetUTFOptimized() throws Exception {
         oneExchangeDone.matchesWaitTime();
 
         assertTrue(Files.exists(testFile("output.txt")), "File should exist");
@@ -56,6 +62,11 @@ public class FileProducerCharsetUTFOptimizedTest extends ContextTestSupport {
         assertArrayEquals(utf, data);
     }
 
+    @AfterEach
+    public void deleteData() {
+        deleteDirectory(testDirectory().toFile());
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {