You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "JinyuChen97 (via GitHub)" <gi...@apache.org> on 2026/07/06 14:42:25 UTC

[PR] Add integration tests covering camel-mdc supported features [camel-quarkus]

JinyuChen97 opened a new pull request, #8830:
URL: https://github.com/apache/camel-quarkus/pull/8830

   Verifies that camel-quarkus correctly supports the camel-mdc extension across the full feature set defined in apache/camel MDCService:
   
   - Default MDC fields: camel.exchangeId, camel.messageId, camel.routeId, camel.contextId, camel.threadId are populated on every exchange
   - Backward-compat fields: camel.correlationId and camel.breadcrumbId are populated when the corresponding property / header is present
   - Custom exchange header by exact name (custom-exchange-headers=myHeader)
   - All exchange headers (custom-exchange-headers=*)
   - Wildcard exchange headers (custom-exchange-headers=prefix*)
   - Selected exchange properties by explicit names (custom-exchange-properties=p1,p2)
   - All exchange properties (custom-exchange-properties=*)
   - Wildcard exchange properties (custom-exchange-properties=prefix*)
   - Multi-pattern comma+glob properties (custom-exchange-properties=test_*,more*)
   - Async thread propagation via .threads(): MDC values survive the thread boundary and the async thread-id differs from the calling thread-id
   - Async wiretap propagation: MDC values are carried into the wiretap thread and the wiretap runs on a distinct thread
   - Processor MDC propagation: custom header and all default MDC fields are visible inside a processor invoked on the route
   
   All tests pass in both JVM and native mode.
   
   Co-authored-by: Bob <bo...@ibm.com>


-- 
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-unsubscribe@camel.apache.org

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


Re: [PR] Add integration tests covering camel-mdc supported features [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #8830:
URL: https://github.com/apache/camel-quarkus/pull/8830#discussion_r3535531620


##########
integration-tests/mdc/src/test/java/org/apache/camel/quarkus/component/mdc/it/MdcAsyncTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.mdc.it;
+
+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.assertj.core.api.Assertions.assertThat;
+
+@QuarkusTest
+@TestProfile(MdcAsyncTestProfile.class)
+class MdcAsyncTest {
+
+    @Test
+    public void testAsyncProcessingWithMdcPropagation() {
+        String response = RestAssured.get("/mdc/async")
+                .then()
+                .statusCode(200)
+                .extract().asString();
+
+        assertThat(response).contains("asyncHeader:asyncValue");
+        assertThat(response).contains("asyncProp:asyncPropValue");
+        assertThat(response).contains("threadId:").doesNotContain("threadId:null");
+        // MDC threadId on the async thread must differ from the calling thread
+        String threadId = extractValue(response, "threadId");
+        String callingThread = extractValue(response, "callingThread");
+        assertThat(threadId).isNotEqualTo(callingThread);

Review Comment:
   You typically don't need to extract the response and feed it into assertions.
   
   RestAssured already gives you the capability to do assertions on the response:
   
   https://github.com/rest-assured/rest-assured/wiki/usage
   
   So if you agree that it makes sense, we could remove assertj and rely on RestAssured.



##########
integration-tests/mdc/src/test/java/org/apache/camel/quarkus/component/mdc/it/MdcAsyncTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.mdc.it;
+
+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.assertj.core.api.Assertions.assertThat;
+
+@QuarkusTest
+@TestProfile(MdcAsyncTestProfile.class)
+class MdcAsyncTest {
+
+    @Test
+    public void testAsyncProcessingWithMdcPropagation() {

Review Comment:
   Nitpick (same for other tests)
   
   ```suggestion
      void testAsyncProcessingWithMdcPropagation() {
   ```



-- 
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-unsubscribe@camel.apache.org

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


Re: [PR] Add integration tests covering camel-mdc supported features [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton merged PR #8830:
URL: https://github.com/apache/camel-quarkus/pull/8830


-- 
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-unsubscribe@camel.apache.org

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