This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new db95ab842b96 CAMEL-27158: camel-cxf - fix flaky WSAddressingTest
(#30388)
db95ab842b96 is described below
commit db95ab842b965a5307829a4a12a71bfc42cd7302
Author: Torsten Mielke <[email protected]>
AuthorDate: Thu Nov 19 14:50:14 2026 +0100
CAMEL-27158: camel-cxf - fix flaky WSAddressingTest (#30388)
Add @DirtiesContext(AFTER_CLASS) so Spring doesn't reuse a stale
ApplicationContext, and its already-bound CXF listener, across a
Surefire rerun. The ContextCache key doesn't include the ports
@BeforeAll republishes each run, so a rerun's client previously
connected using the rerun's fresh ports while the actual CXF listener
was still bound to the first attempt's stale ones, producing a
ConnectException instead of a clean retry.
Declaring it on the base class is enough: Spring resolves
@DirtiesContext per concrete test class, so WSAddressingPAYLOADTest
and WSAddressingCXFMSGTest inherit it without changes of their own.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
---
.../java/org/apache/camel/component/cxf/wsa/WSAddressingTest.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git
a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/wsa/WSAddressingTest.java
b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/wsa/WSAddressingTest.java
index 155b88e8d56b..7c81faa8e5a7 100644
---
a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/wsa/WSAddressingTest.java
+++
b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/wsa/WSAddressingTest.java
@@ -40,6 +40,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -48,6 +50,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
@ExtendWith(SpringExtension.class)
@ContextConfiguration
+// Prevents Spring from reusing a stale ApplicationContext (and its bound CXF
listener) across a rerun.
+// Resolved per concrete test class, so WSAddressingPAYLOADTest/CXFMSGTest
inherit it without redeclaring it.
+@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class WSAddressingTest {
private static AvailablePortFinder.Port PORT1;