From ff9ba15762e2d6ca1b7b2a1292c3048f414899da Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:20:43 +0100 Subject: [PATCH] Extract test logging into extension --- ...tractStompBrokerRelayIntegrationTests.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/AbstractStompBrokerRelayIntegrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/AbstractStompBrokerRelayIntegrationTests.java index 985ce165b5c..9c665698f07 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/AbstractStompBrokerRelayIntegrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/AbstractStompBrokerRelayIntegrationTests.java @@ -34,6 +34,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.BeforeTestExecutionCallback; +import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; @@ -75,6 +77,11 @@ public abstract class AbstractStompBrokerRelayIntegrationTests { // initial value of zero implies that a random ephemeral port should be used private int port = 0; + @RegisterExtension + BeforeTestExecutionCallback loggingExtension = + context -> logger.debug("Starting test %s()".formatted(context.getRequiredTestMethod().getName())); + + @BeforeEach void setup(TestInfo testInfo) throws Exception { @@ -156,8 +163,6 @@ public abstract class AbstractStompBrokerRelayIntegrationTests { @Test void publishSubscribe() throws Exception { - logger.debug("Starting test publishSubscribe()"); - String sess1 = "sess1"; String sess2 = "sess2"; String subs1 = "subs1"; @@ -180,8 +185,6 @@ public abstract class AbstractStompBrokerRelayIntegrationTests { @Test void messageDeliveryExceptionIfSystemSessionForwardFails() throws Exception { - logger.debug("Starting test messageDeliveryExceptionIfSystemSessionForwardFails()"); - stopActiveMqBrokerAndAwait(); this.eventPublisher.expectBrokerAvailabilityEvent(false); @@ -192,8 +195,6 @@ public abstract class AbstractStompBrokerRelayIntegrationTests { @Test void brokerBecomingUnavailableTriggersErrorFrame() throws Exception { - logger.debug("Starting test brokerBecomingUnavailableTriggersErrorFrame()"); - String sess1 = "sess1"; MessageExchange connect = MessageExchangeBuilder.connect(sess1).build(); this.relay.handleMessage(connect.message); @@ -207,16 +208,12 @@ public abstract class AbstractStompBrokerRelayIntegrationTests { @Test void brokerAvailabilityEventWhenStopped() throws Exception { - logger.debug("Starting test brokerAvailabilityEventWhenStopped()"); - stopActiveMqBrokerAndAwait(); this.eventPublisher.expectBrokerAvailabilityEvent(false); } @Test void relayReconnectsIfBrokerComesBackUp() throws Exception { - logger.debug("Starting test relayReconnectsIfBrokerComesBackUp()"); - String sess1 = "sess1"; MessageExchange conn1 = MessageExchangeBuilder.connect(sess1).build(); this.relay.handleMessage(conn1.message); @@ -241,8 +238,6 @@ public abstract class AbstractStompBrokerRelayIntegrationTests { @Test void disconnectWithReceipt() throws Exception { - logger.debug("Starting test disconnectWithReceipt()"); - MessageExchange connect = MessageExchangeBuilder.connect("sess1").build(); this.relay.handleMessage(connect.message); this.responseHandler.expectMessages(connect);