From 5f9f323b12a5b3cf9135f209c10aa2392c98f5d5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 6 Jul 2017 15:07:41 +0200 Subject: [PATCH] Add logging to randomly failing websocket test --- .../socket/WebSocketIntegrationTests.java | 27 ++++++++++++++----- .../src/test/resources/log4j2-test.xml | 6 ++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java index 3526bcb467..6fbb5732e6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java @@ -22,7 +22,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Level; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hamcrest.Matchers; import org.junit.Test; import org.reactivestreams.Publisher; @@ -30,6 +33,8 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.MonoProcessor; import reactor.core.publisher.ReplayProcessor; +import reactor.core.publisher.SignalType; +import sun.util.logging.PlatformLogger; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -46,6 +51,9 @@ import static org.junit.Assert.*; */ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { + private static final Log logger = LogFactory.getLog(WebSocketIntegrationTests.class); + + @Override protected Class getWebConfigClass() { return WebConfig.class; @@ -59,14 +67,21 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests ReplayProcessor output = ReplayProcessor.create(count); client.execute(getUrl("/echo"), - session -> session - .send(input.map(session::textMessage)) - .thenMany(session.receive().take(count).map(WebSocketMessage::getPayloadAsText)) - .subscribeWith(output) - .then()) + session -> { + logger.debug("Starting to send messages"); + return session + .send(input.doOnNext(s -> logger.debug("outbound " + s)).map(session::textMessage)) + .thenMany(session.receive().take(count).map(WebSocketMessage::getPayloadAsText)) + .subscribeWith(output) + .doOnNext(s -> logger.debug("inbound " + s)) + .then() + .doOnTerminate((aVoid, ex) -> + logger.debug("Done with " + (ex != null ? ex.getMessage() : "success"))); + }) .block(Duration.ofMillis(5000)); - assertEquals(input.collectList().block(Duration.ofMillis(5000)), output.collectList().block(Duration.ofMillis(5000))); + assertEquals(input.collectList().block(Duration.ofMillis(5000)), + output.collectList().block(Duration.ofMillis(5000))); } @Test diff --git a/spring-webflux/src/test/resources/log4j2-test.xml b/spring-webflux/src/test/resources/log4j2-test.xml index 4c57ce9651..bb4a13f804 100644 --- a/spring-webflux/src/test/resources/log4j2-test.xml +++ b/spring-webflux/src/test/resources/log4j2-test.xml @@ -8,9 +8,13 @@ + + + + - +