JiriOndrusek commented on a change in pull request #2548:
URL: https://github.com/apache/camel-quarkus/pull/2548#discussion_r625545757



##########
File path: 
integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java
##########
@@ -17,48 +17,150 @@
 package org.apache.camel.quarkus.component.file.it;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import io.restassured.path.json.JsonPath;
 import io.restassured.response.ValidatableResponse;
+import org.hamcrest.Matcher;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 
+import static 
org.apache.camel.quarkus.component.file.it.FileResource.CONSUME_BATCH;
+import static 
org.apache.camel.quarkus.component.file.it.FileResource.SEPARATOR;
+import static org.apache.camel.quarkus.component.file.it.FileResource.SORT_BY;
 import static org.awaitility.Awaitility.await;
 import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNot.not;
 
 @QuarkusTest
 class FileTest {
 
     private static final String FILE_BODY = "Hello Camel Quarkus";
+    private static final String FILE_CONTENT_01 = "Hello1";
+    private static final String FILE_CONTENT_02 = "Hello2";
+    private static final String FILE_CONTENT_03 = "Hello3";
+    private static final String FILE_BODY_UTF8 = "Hello World \u4f60\u597d";
+
+    private List<Path> pathsToDelete = new LinkedList<>();
+
+    @AfterEach
+    public void afterEach() {
+        pathsToDelete.stream().forEach(p -> {
+            try {
+                Files.delete(p);
+            } catch (IOException e) {
+                //ignore
+            }
+        });
+
+        pathsToDelete.clear();
+    }
 
     @Test
     public void file() {
         // Create a new file
-        String fileName = RestAssured.given()
-                .contentType(ContentType.TEXT)
-                .body(FILE_BODY)
-                .post("/file/create/in")
-                .then()
-                .statusCode(201)
-                .extract()
-                .body()
-                .asString();
+        String fileName = createFile(FILE_BODY, "/file/create/in");
 
         // Read the file
         RestAssured
-                .get("/file/get/in/" + Paths.get(fileName).getFileName())
+                .post("/file/get/in/" + Paths.get(fileName).getFileName())
                 .then()
                 .statusCode(200)
                 .body(equalTo(FILE_BODY));
     }
 
+    @Test
+    public void consumerCharset() throws UnsupportedEncodingException {
+        // Create a new file
+        createFile(FILE_BODY_UTF8, "/file/create/charsetUTF8", "UTF-8", null);
+        createFile(FILE_BODY_UTF8, "/file/create/charsetISO", "UTF-8", null);
+
+        await().atMost(10, TimeUnit.SECONDS).until(() -> 
getFromMock("charsetUTF8", equalTo(FILE_BODY_UTF8)));
+
+        await().atMost(10, TimeUnit.SECONDS).until(() -> {
+            // File content read as ISO-8859-1 has to have different content 
(because file contains some unknown characters)
+            return getFromMock("charsetISO", not(equalTo(FILE_BODY_UTF8)));

Review comment:
       I'll refactor it




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to