ppalaga commented on code in PR #4125:
URL: https://github.com/apache/camel-quarkus/pull/4125#discussion_r982384924


##########
integration-tests/rest-openapi/src/test/java/org/apache/camel/quarkus/component/rest/openapi/it/RestOpenapiTest.java:
##########
@@ -16,21 +16,71 @@
  */
 package org.apache.camel.quarkus.component.rest.openapi.it;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.Matchers.containsInAnyOrder;
 
 @QuarkusTest
 class RestOpenapiTest {
 
+    private static final String OUTPUT_DIRECTORY = "target";
+    private static final String OPENAPI_FILE = "openapi.json";
+
+    @BeforeAll
+    public static void createOpenApiJsonFile() throws Exception {
+        RestOpenApiBean bean = new RestOpenApiBean();
+        String openApiContents = bean.getOpenApiJson();
+        Files.createDirectories(Paths.get(OUTPUT_DIRECTORY));
+        FileWriter writer = new FileWriter(new File(OUTPUT_DIRECTORY, 
OPENAPI_FILE));
+        writer.write(openApiContents);
+        writer.close();

Review Comment:
   Auto-close the stream even if write() throws an exception
   ```suggestion
           try (FileWriter writer = new FileWriter(new File(OUTPUT_DIRECTORY, 
OPENAPI_FILE))) {
               writer.write(openApiContents);
           }
   ```
   
   OR even simpler
   ```suggestion
                   Files.writeString(Paths.get("target/openapi.json"), 
openApiContents, StandardCharsets.UTF_8);
   ```



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

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

Reply via email to