This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git
commit d9cc0ba51ac9b0dddc220d11e9f89362855b9d56 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Tue Mar 30 15:13:16 2021 +0200 Special handling of target location not needed anymore --- .../java/org/acme/filereader/FileSplitLogXmlTest.java | 16 +++------------- http-log/src/test/java/org/acme/http/HttpLogTest.java | 15 +++------------ .../src/test/java/org/acme/timer/TimerLogCdiTest.java | 15 +++------------ .../src/test/kotlin/org/acme/timer/TimerLogKotlin.kt | 8 +------- .../src/test/java/org/acme/timer/TimerLogSpringTest.java | 16 +++------------- .../src/test/java/org/acme/timer/TimerLogXmlTest.java | 15 +++------------ timer-log/src/test/java/org/acme/timer/TimerLogTest.java | 15 +++------------ 7 files changed, 19 insertions(+), 81 deletions(-) diff --git a/file-split-log-xml/src/test/java/org/acme/filereader/FileSplitLogXmlTest.java b/file-split-log-xml/src/test/java/org/acme/filereader/FileSplitLogXmlTest.java index d3a502c..a279e17 100644 --- a/file-split-log-xml/src/test/java/org/acme/filereader/FileSplitLogXmlTest.java +++ b/file-split-log-xml/src/test/java/org/acme/filereader/FileSplitLogXmlTest.java @@ -16,12 +16,12 @@ */ package org.acme.filereader; -import java.io.File; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.TimeUnit; import io.quarkus.test.junit.QuarkusTest; -import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; @@ -32,19 +32,9 @@ public class FileSplitLogXmlTest { @Test public void testFileSplitLogXml() { // Verify that all 1000 items were output to the log - File quarkusLogFile = getQuarkusLogFile(); await().atMost(10L, TimeUnit.SECONDS).pollDelay(1, TimeUnit.SECONDS).until(() -> { - String log = FileUtils.readFileToString(quarkusLogFile, StandardCharsets.UTF_8); + String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8); return log.contains("line 1000 contains: Anna,COOKE"); }); } - - private File getQuarkusLogFile() { - String pathPrefix = "target"; - String packageType = System.getProperty("quarkus.package.type"); - if (packageType != null && packageType.equals("native")) { - pathPrefix += "/target"; - } - return new File(pathPrefix + "/quarkus.log"); - } } diff --git a/http-log/src/test/java/org/acme/http/HttpLogTest.java b/http-log/src/test/java/org/acme/http/HttpLogTest.java index 624db1e..402ecef 100644 --- a/http-log/src/test/java/org/acme/http/HttpLogTest.java +++ b/http-log/src/test/java/org/acme/http/HttpLogTest.java @@ -16,13 +16,13 @@ */ package org.acme.http; -import java.io.File; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.TimeUnit; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; -import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; @@ -36,19 +36,10 @@ public class HttpLogTest { .then() .statusCode(200); - File quarkusLogFile = getQuarkusLogFile(); await().atMost(10L, TimeUnit.SECONDS).pollDelay(1, TimeUnit.SECONDS).until(() -> { - String log = FileUtils.readFileToString(quarkusLogFile, StandardCharsets.UTF_8); + String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8); return log.contains("Camel runs on"); }); } - private File getQuarkusLogFile() { - String pathPrefix = "target"; - String packageType = System.getProperty("quarkus.package.type"); - if (packageType != null && packageType.equals("native")) { - pathPrefix += "/target"; - } - return new File(pathPrefix + "/quarkus.log"); - } } diff --git a/timer-log-cdi/src/test/java/org/acme/timer/TimerLogCdiTest.java b/timer-log-cdi/src/test/java/org/acme/timer/TimerLogCdiTest.java index 9259c7c..d970201 100644 --- a/timer-log-cdi/src/test/java/org/acme/timer/TimerLogCdiTest.java +++ b/timer-log-cdi/src/test/java/org/acme/timer/TimerLogCdiTest.java @@ -16,12 +16,12 @@ */ package org.acme.timer; -import java.io.File; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.TimeUnit; import io.quarkus.test.junit.QuarkusTest; -import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; @@ -31,19 +31,10 @@ public class TimerLogCdiTest { @Test public void testTimerLog() { - File quarkusLogFile = getQuarkusLogFile(); await().atMost(10L, TimeUnit.SECONDS).pollDelay(1, TimeUnit.SECONDS).until(() -> { - String log = FileUtils.readFileToString(quarkusLogFile, StandardCharsets.UTF_8); + String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8); return log.contains("Incremented the counter"); }); } - private File getQuarkusLogFile() { - String pathPrefix = "target"; - String packageType = System.getProperty("quarkus.package.type"); - if (packageType != null && packageType.equals("native")) { - pathPrefix += "/target"; - } - return new File(pathPrefix + "/quarkus.log"); - } } diff --git a/timer-log-kotlin/src/test/kotlin/org/acme/timer/TimerLogKotlin.kt b/timer-log-kotlin/src/test/kotlin/org/acme/timer/TimerLogKotlin.kt index 07e0f22..56fc2e5 100644 --- a/timer-log-kotlin/src/test/kotlin/org/acme/timer/TimerLogKotlin.kt +++ b/timer-log-kotlin/src/test/kotlin/org/acme/timer/TimerLogKotlin.kt @@ -29,13 +29,7 @@ open class TimerLogKotlinTest { @Test fun testTimerLogKotlin() { - val packageType = System.getProperty("quarkus.package.type") - var pathPrefix = "target" - if (packageType != null && packageType == "native") { - pathPrefix += "/target" - } - - val quarkusLogFile = File("$pathPrefix/quarkus.log") + val quarkusLogFile = File("target/quarkus.log") await().atMost(10L, TimeUnit.SECONDS).pollDelay(1, TimeUnit.SECONDS).until { quarkusLogFile.readText(StandardCharsets.UTF_8).contains("Hello from Kotlin!") diff --git a/timer-log-spring/src/test/java/org/acme/timer/TimerLogSpringTest.java b/timer-log-spring/src/test/java/org/acme/timer/TimerLogSpringTest.java index 1691d95..8fe810e 100644 --- a/timer-log-spring/src/test/java/org/acme/timer/TimerLogSpringTest.java +++ b/timer-log-spring/src/test/java/org/acme/timer/TimerLogSpringTest.java @@ -16,12 +16,12 @@ */ package org.acme.timer; -import java.io.File; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.TimeUnit; import io.quarkus.test.junit.QuarkusTest; -import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; @@ -31,19 +31,9 @@ public class TimerLogSpringTest { @Test public void testTimerLogSpring() { - File quarkusLogFile = getQuarkusLogFile(); await().atMost(10L, TimeUnit.SECONDS).pollDelay(1, TimeUnit.SECONDS).until(() -> { - String log = FileUtils.readFileToString(quarkusLogFile, StandardCharsets.UTF_8); + String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8); return log.contains("Incremented the counter"); }); } - - private File getQuarkusLogFile() { - String pathPrefix = "target"; - String packageType = System.getProperty("quarkus.package.type"); - if (packageType != null && packageType.equals("native")) { - pathPrefix += "/target"; - } - return new File(pathPrefix + "/quarkus.log"); - } } diff --git a/timer-log-xml/src/test/java/org/acme/timer/TimerLogXmlTest.java b/timer-log-xml/src/test/java/org/acme/timer/TimerLogXmlTest.java index 823dc14..56aed74 100644 --- a/timer-log-xml/src/test/java/org/acme/timer/TimerLogXmlTest.java +++ b/timer-log-xml/src/test/java/org/acme/timer/TimerLogXmlTest.java @@ -16,12 +16,12 @@ */ package org.acme.timer; -import java.io.File; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.TimeUnit; import io.quarkus.test.junit.QuarkusTest; -import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; @@ -31,19 +31,10 @@ public class TimerLogXmlTest { @Test public void testTimerLogXml() { - File quarkusLogFile = getQuarkusLogFile(); await().atMost(10L, TimeUnit.SECONDS).pollDelay(1, TimeUnit.SECONDS).until(() -> { - String log = FileUtils.readFileToString(quarkusLogFile, StandardCharsets.UTF_8); + String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8); return log.contains("Hello XML!"); }); } - private File getQuarkusLogFile() { - String pathPrefix = "target"; - String packageType = System.getProperty("quarkus.package.type"); - if (packageType != null && packageType.equals("native")) { - pathPrefix += "/target"; - } - return new File(pathPrefix + "/quarkus.log"); - } } diff --git a/timer-log/src/test/java/org/acme/timer/TimerLogTest.java b/timer-log/src/test/java/org/acme/timer/TimerLogTest.java index dd6898d..e5b6286 100644 --- a/timer-log/src/test/java/org/acme/timer/TimerLogTest.java +++ b/timer-log/src/test/java/org/acme/timer/TimerLogTest.java @@ -16,12 +16,12 @@ */ package org.acme.timer; -import java.io.File; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.TimeUnit; import io.quarkus.test.junit.QuarkusTest; -import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; @@ -31,19 +31,10 @@ public class TimerLogTest { @Test public void testTimerLog() { - File quarkusLogFile = getQuarkusLogFile(); await().atMost(10L, TimeUnit.SECONDS).pollDelay(1, TimeUnit.SECONDS).until(() -> { - String log = FileUtils.readFileToString(quarkusLogFile, StandardCharsets.UTF_8); + String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8); return log.contains("Hello World"); }); } - private File getQuarkusLogFile() { - String pathPrefix = "target"; - String packageType = System.getProperty("quarkus.package.type"); - if (packageType != null && packageType.equals("native")) { - pathPrefix += "/target"; - } - return new File(pathPrefix + "/quarkus.log"); - } }