You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zb...@apache.org on 2023/06/13 11:59:50 UTC

[camel-quarkus] branch main updated: Add test coverage for MDC logging

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

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


The following commit(s) were added to refs/heads/main by this push:
     new c9ea1c17ee Add test coverage for MDC logging
c9ea1c17ee is described below

commit c9ea1c17eebb85fc5657b13c1e236becff262f42
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Jun 7 10:08:32 2023 +0100

    Add test coverage for MDC logging
    
    Fixes #4947
---
 integration-test-groups/foundation/log/pom.xml     |  21 ++++
 .../quarkus/component/log/it/LogResource.java      |  46 ++++++--
 .../camel/quarkus/component/log/it/LogRoutes.java} |  25 +----
 .../camel/quarkus/component/log/it/LogUtils.java}  |  36 +++---
 .../quarkus/component/log/it/MdcLogRoutes.java}    |  32 +++---
 .../log/src/main/resources/application.properties  |   3 +
 .../camel/quarkus/component/log/it/LogTest.java    |  20 +++-
 .../log/it/{LogTest.java => MdcLogIT.java}         |  23 +---
 .../camel/quarkus/component/log/it/MdcLogTest.java | 125 +++++++++++++++++++++
 .../{LogTest.java => MdcLoggingTestProfile.java}   |  31 +++--
 10 files changed, 261 insertions(+), 101 deletions(-)

diff --git a/integration-test-groups/foundation/log/pom.xml b/integration-test-groups/foundation/log/pom.xml
index acb2e7dfd4..93cbdbb425 100644
--- a/integration-test-groups/foundation/log/pom.xml
+++ b/integration-test-groups/foundation/log/pom.xml
@@ -30,10 +30,18 @@
     <name>Camel Quarkus :: Integration Tests :: Log :: Tests</name>
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-log</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy</artifactId>
+        </dependency>
 
         <!-- test dependencies -->
         <dependency>
@@ -90,6 +98,19 @@
             </activation>
             <dependencies>
                 <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+                <dependency>
+                    <groupId>org.apache.camel.quarkus</groupId>
+                    <artifactId>camel-quarkus-direct-deployment</artifactId>
+                    <version>${project.version}</version>
+                    <type>pom</type>
+                    <scope>test</scope>
+                    <exclusions>
+                        <exclusion>
+                            <groupId>*</groupId>
+                            <artifactId>*</artifactId>
+                        </exclusion>
+                    </exclusions>
+                </dependency>
                 <dependency>
                     <groupId>org.apache.camel.quarkus</groupId>
                     <artifactId>camel-quarkus-log-deployment</artifactId>
diff --git a/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogResource.java b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogResource.java
index 6609d18039..877ac140b7 100644
--- a/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogResource.java
+++ b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogResource.java
@@ -16,19 +16,29 @@
  */
 package org.apache.camel.quarkus.component.log.it;
 
+import java.io.IOException;
+import java.nio.file.Files;
 import java.util.Optional;
 
 import jakarta.enterprise.context.ApplicationScoped;
 import jakarta.enterprise.event.Observes;
 import jakarta.inject.Inject;
+import jakarta.inject.Named;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.MediaType;
+import org.apache.camel.Exchange;
 import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.log.LogComponent;
 import org.apache.camel.quarkus.main.events.AfterStart;
 import org.eclipse.microprofile.config.inject.ConfigProperty;
 
 @ApplicationScoped
+@Path("/log")
 public class LogResource {
-
-    public static final String LOG_MESSAGE = "Lets's fool io.quarkus.test.common.LauncherUtil.CaptureListeningDataReader: Listening on: http://0.0.0.0:";
     @Inject
     ProducerTemplate producerTemplate;
 
@@ -38,13 +48,35 @@ public class LogResource {
     Optional<Integer> httpPort;
 
     private int getEffectivePort() {
-        final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
-        Optional<Integer> portSource = isNativeMode ? httpPort : httpTestPort;
-        return portSource.isPresent() ? portSource.get().intValue() : 0;
+        Optional<Integer> portSource = LogUtils.isNativeMode() ? httpPort : httpTestPort;
+        return portSource.orElse(0);
+    }
+
+    public void afterApplicationStartup(@Observes AfterStart event) {
+        try {
+            Files.writeString(LogUtils.resolveQuarkusLogPath(),
+                    "Listening on: http://0.0.0.0:" + getEffectivePort() + System.lineSeparator());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
-    public void info(@Observes AfterStart event) {
-        producerTemplate.sendBody("log:foo-topic", LOG_MESSAGE + getEffectivePort());
+    @jakarta.enterprise.inject.Produces
+    @Named("mdcLog")
+    LogComponent logComponent() {
+        // Use a new LogComponent instance because when we run tests 'grouped',
+        // integration-test-customized-log-component introduces a custom exchangeFormatter
+        // which messes up the log output expected by the MDC tests
+        LogComponent logComponent = new LogComponent();
+        logComponent.setCamelContext(producerTemplate.getCamelContext());
+        return logComponent;
     }
 
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String logMessage(@QueryParam("endpointUri") String endpointUri, String message) {
+        Exchange result = producerTemplate.request(endpointUri, exchange -> exchange.getMessage().setBody(message));
+        return result.getExchangeId();
+    }
 }
diff --git a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogRoutes.java
similarity index 57%
copy from integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
copy to integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogRoutes.java
index bbe10bc07b..6fd95f96fc 100644
--- a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
+++ b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogRoutes.java
@@ -16,25 +16,12 @@
  */
 package org.apache.camel.quarkus.component.log.it;
 
-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.junit.jupiter.api.Test;
-
-import static org.awaitility.Awaitility.await;
-
-@QuarkusTest
-public class LogTest {
-
-    @Test
-    public void info() {
-        await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
-            String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8);
-            return log.contains("[foo-topic]") && log.contains(LogResource.LOG_MESSAGE);
-        });
+import org.apache.camel.builder.RouteBuilder;
 
+public class LogRoutes extends RouteBuilder {
+    @Override
+    public void configure() {
+        from("direct:log")
+                .to("log:foo-topic");
     }
 }
diff --git a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogUtils.java
similarity index 53%
copy from integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
copy to integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogUtils.java
index bbe10bc07b..0738529acf 100644
--- a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
+++ b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/LogUtils.java
@@ -16,25 +16,31 @@
  */
 package org.apache.camel.quarkus.component.log.it;
 
-import java.nio.charset.StandardCharsets;
+import java.io.IOException;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.concurrent.TimeUnit;
 
-import io.quarkus.test.junit.QuarkusTest;
-import org.junit.jupiter.api.Test;
-
-import static org.awaitility.Awaitility.await;
-
-@QuarkusTest
-public class LogTest {
+public class LogUtils {
+    private LogUtils() {
+        // Utility class
+    }
 
-    @Test
-    public void info() {
-        await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
-            String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8);
-            return log.contains("[foo-topic]") && log.contains(LogResource.LOG_MESSAGE);
-        });
+    public static boolean isNativeMode() {
+        return "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
+    }
 
+    public static Path resolveQuarkusLogPath() {
+        Path logDir = Paths.get(".", "target");
+        Path quarkusLog = isNativeMode() ? logDir.resolve("target/quarkus.log") : logDir.resolve("quarkus.log");
+        if (!Files.exists(quarkusLog)) {
+            try {
+                Files.createDirectories(quarkusLog.getParent());
+                Files.createFile(quarkusLog);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return quarkusLog;
     }
 }
diff --git a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/MdcLogRoutes.java
similarity index 57%
copy from integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
copy to integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/MdcLogRoutes.java
index bbe10bc07b..1c5a922639 100644
--- a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
+++ b/integration-test-groups/foundation/log/src/main/java/org/apache/camel/quarkus/component/log/it/MdcLogRoutes.java
@@ -16,25 +16,23 @@
  */
 package org.apache.camel.quarkus.component.log.it;
 
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.concurrent.TimeUnit;
+import org.apache.camel.builder.RouteBuilder;
+import org.jboss.logging.Logger;
 
-import io.quarkus.test.junit.QuarkusTest;
-import org.junit.jupiter.api.Test;
+public class MdcLogRoutes extends RouteBuilder {
+    @Override
+    public void configure() {
+        onException(Exception.class)
+                .handled(exchange -> {
+                    Logger LOG = Logger.getLogger(MdcLogRoutes.class);
+                    LOG.error("Caught exception");
+                    return true;
+                });
 
-import static org.awaitility.Awaitility.await;
-
-@QuarkusTest
-public class LogTest {
-
-    @Test
-    public void info() {
-        await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
-            String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8);
-            return log.contains("[foo-topic]") && log.contains(LogResource.LOG_MESSAGE);
-        });
+        from("direct:mdcLog").routeId("mdc-log")
+                .to("mdcLog:mdc");
 
+        from("direct:mdcLogFromException").routeId("mdc-log-from-exception")
+                .throwException(new Exception("Forced"));
     }
 }
diff --git a/integration-test-groups/foundation/log/src/main/resources/application.properties b/integration-test-groups/foundation/log/src/main/resources/application.properties
index b6ff2229d0..a7b671e43c 100644
--- a/integration-test-groups/foundation/log/src/main/resources/application.properties
+++ b/integration-test-groups/foundation/log/src/main/resources/application.properties
@@ -16,3 +16,6 @@
 ## ---------------------------------------------------------------------------
 quarkus.log.file.enable = true
 quarkus.log.file.path = target/quarkus.log
+
+# Do not start MDC routes by default to avoid interference with logs produced in other routes
+camel.main.javaRoutesExcludePattern=**/MdcLogRoutes
diff --git a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
index bbe10bc07b..8426a58d5e 100644
--- a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
+++ b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
@@ -16,12 +16,12 @@
  */
 package org.apache.camel.quarkus.component.log.it;
 
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.concurrent.TimeUnit;
 
 import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
 import org.junit.jupiter.api.Test;
 
 import static org.awaitility.Awaitility.await;
@@ -30,11 +30,19 @@ import static org.awaitility.Awaitility.await;
 public class LogTest {
 
     @Test
-    public void info() {
+    public void logMessage() {
+        Path quarkusLog = LogUtils.resolveQuarkusLogPath();
+        String message = "Hello Camel Quarkus Log";
+        RestAssured.given()
+                .queryParam("endpointUri", "direct:log")
+                .body(message)
+                .post("/log")
+                .then()
+                .statusCode(200);
+
         await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
-            String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8);
-            return log.contains("[foo-topic]") && log.contains(LogResource.LOG_MESSAGE);
+            String log = Files.readString(quarkusLog);
+            return log.contains("[foo-topic]") && log.contains(message);
         });
-
     }
 }
diff --git a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLogIT.java
similarity index 56%
copy from integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
copy to integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLogIT.java
index bbe10bc07b..37804406e9 100644
--- a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
+++ b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLogIT.java
@@ -16,25 +16,8 @@
  */
 package org.apache.camel.quarkus.component.log.it;
 
-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.QuarkusIntegrationTest;
 
-import io.quarkus.test.junit.QuarkusTest;
-import org.junit.jupiter.api.Test;
-
-import static org.awaitility.Awaitility.await;
-
-@QuarkusTest
-public class LogTest {
-
-    @Test
-    public void info() {
-        await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
-            String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8);
-            return log.contains("[foo-topic]") && log.contains(LogResource.LOG_MESSAGE);
-        });
-
-    }
+@QuarkusIntegrationTest
+public class MdcLogIT extends MdcLogTest {
 }
diff --git a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLogTest.java b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLogTest.java
new file mode 100644
index 0000000000..8e618173fa
--- /dev/null
+++ b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLogTest.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.log.it;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.TestProfile;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.quarkus.component.log.it.MdcLoggingTestProfile.CONTEXT_NAME;
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+@TestProfile(MdcLoggingTestProfile.class)
+public class MdcLogTest {
+    private static final Pattern MDC_LOG_PATTERN = Pattern.compile("^MDC\\[\\{(.*)},(.*)]");
+
+    @Test
+    void mdcLogging() {
+        Path quarkusLog = LogUtils.resolveQuarkusLogPath();
+        String message = "Hello Camel Quarkus MDC Logging";
+
+        String id = RestAssured.given()
+                .queryParam("endpointUri", "direct:mdcLog")
+                .body(message)
+                .post("/log")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
+            Map<String, String> mdc = parseMdcLogEntries(quarkusLog);
+            if (mdc.isEmpty()) {
+                return false;
+            }
+
+            assertEquals(id, mdc.get("camel.breadcrumbId"));
+            assertEquals(CONTEXT_NAME, mdc.get("camel.contextId"));
+            assertEquals(id, mdc.get("camel.exchangeId"));
+            assertEquals(id, mdc.get("camel.messageId"));
+            assertTrue(mdc.get("message").contains(message));
+            assertEquals("mdc-log", mdc.get("camel.routeId"));
+
+            return true;
+        });
+    }
+
+    @Test
+    void mdcLoggingFromExceptionHandler() {
+        Path quarkusLog = LogUtils.resolveQuarkusLogPath();
+        String id = RestAssured.given()
+                .queryParam("endpointUri", "direct:mdcLogFromException")
+                .body("Ignored message body")
+                .post("/log")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
+            Map<String, String> mdc = parseMdcLogEntries(quarkusLog);
+            if (mdc.isEmpty()) {
+                return false;
+            }
+
+            assertEquals(id, mdc.get("camel.breadcrumbId"));
+            assertEquals(CONTEXT_NAME, mdc.get("camel.contextId"));
+            assertEquals(id, mdc.get("camel.exchangeId"));
+            assertEquals(id, mdc.get("camel.messageId"));
+            assertTrue(mdc.get("message").contains("Caught exception"));
+            assertEquals("mdc-log-from-exception", mdc.get("camel.routeId"));
+
+            return true;
+        });
+    }
+
+    private Map<String, String> parseMdcLogEntries(Path quarkusLog) throws IOException {
+        Map<String, String> mdc = new HashMap<>();
+        Files.readAllLines(quarkusLog)
+                .stream()
+                .forEach(line -> {
+                    Matcher matcher = MDC_LOG_PATTERN.matcher(line);
+                    if (matcher.matches()) {
+                        String mdcElements = matcher.group(1);
+                        for (String element : mdcElements.split(",")) {
+                            String[] mdcKeyValue = element.split("=");
+                            if (mdcKeyValue.length == 2) {
+                                mdc.put(mdcKeyValue[0].trim(), mdcKeyValue[1].trim());
+                            }
+                        }
+
+                        mdc.put("message", matcher.group(2));
+                    }
+                });
+        return mdc;
+    }
+}
diff --git a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLoggingTestProfile.java
similarity index 54%
copy from integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
copy to integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLoggingTestProfile.java
index bbe10bc07b..3143ac1fd0 100644
--- a/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/LogTest.java
+++ b/integration-test-groups/foundation/log/src/test/java/org/apache/camel/quarkus/component/log/it/MdcLoggingTestProfile.java
@@ -16,25 +16,22 @@
  */
 package org.apache.camel.quarkus.component.log.it;
 
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.concurrent.TimeUnit;
+import java.util.Map;
 
-import io.quarkus.test.junit.QuarkusTest;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.QuarkusTestProfile;
 
-import static org.awaitility.Awaitility.await;
-
-@QuarkusTest
-public class LogTest {
-
-    @Test
-    public void info() {
-        await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
-            String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8);
-            return log.contains("[foo-topic]") && log.contains(LogResource.LOG_MESSAGE);
-        });
+public class MdcLoggingTestProfile implements QuarkusTestProfile {
+    public static final String CONTEXT_NAME = "mdc-logging";
 
+    @Override
+    public Map<String, String> getConfigOverrides() {
+        return Map.of(
+                "quarkus.log.file.path", "target/quarkus.log",
+                "quarkus.log.file.format", "MDC[%X,%m]%n",
+                "camel.main.javaRoutesExcludePattern", "**/LogRoutes",
+                "camel.main.routeFilterIncludePattern", "direct:mdcLog*",
+                "camel.context.name", CONTEXT_NAME,
+                "camel.main.useMdcLogging", "true",
+                "camel.main.useBreadcrumb", "true");
     }
 }