Browse Source

Extract test logging into extension

pull/36325/head
Sam Brannen 1 month ago
parent
commit
ff9ba15762
  1. 19
      spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/AbstractStompBrokerRelayIntegrationTests.java

19
spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/AbstractStompBrokerRelayIntegrationTests.java

@ -34,6 +34,8 @@ import org.junit.jupiter.api.AfterEach; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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);

Loading…
Cancel
Save