|
|
|
@ -43,13 +43,14 @@ import static org.junit.Assert.assertThat; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Integration tests with server-side {@link WebSocketHandler}s. |
|
|
|
* Integration tests with server-side {@link WebSocketHandler}s. |
|
|
|
* |
|
|
|
|
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { |
|
|
|
public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(WebSocketIntegrationTests.class); |
|
|
|
private static final Log logger = LogFactory.getLog(WebSocketIntegrationTests.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Duration TIMEOUT = Duration.ofMillis(5000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Class<?> getWebConfigClass() { |
|
|
|
protected Class<?> getWebConfigClass() { |
|
|
|
@ -71,14 +72,12 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests |
|
|
|
.thenMany(session.receive().take(count).map(WebSocketMessage::getPayloadAsText)) |
|
|
|
.thenMany(session.receive().take(count).map(WebSocketMessage::getPayloadAsText)) |
|
|
|
.subscribeWith(output) |
|
|
|
.subscribeWith(output) |
|
|
|
.doOnNext(s -> logger.debug("inbound " + s)) |
|
|
|
.doOnNext(s -> logger.debug("inbound " + s)) |
|
|
|
.then() |
|
|
|
.then(); |
|
|
|
.doOnSuccessOrError((aVoid, ex) -> |
|
|
|
|
|
|
|
logger.debug("Done with " + (ex != null ? ex.getMessage() : "success"))); |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.block(Duration.ofMillis(5000)); |
|
|
|
.doOnSuccessOrError((aVoid, ex) -> logger.debug("Done: " + (ex != null ? ex.getMessage() : "success"))) |
|
|
|
|
|
|
|
.block(TIMEOUT); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(input.collectList().block(Duration.ofMillis(5000)), |
|
|
|
assertEquals(input.collectList().block(TIMEOUT), output.collectList().block(TIMEOUT)); |
|
|
|
output.collectList().block(Duration.ofMillis(5000))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -102,13 +101,13 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests |
|
|
|
.then(); |
|
|
|
.then(); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.block(Duration.ofMillis(5000)); |
|
|
|
.block(TIMEOUT); |
|
|
|
|
|
|
|
|
|
|
|
HandshakeInfo info = infoRef.get(); |
|
|
|
HandshakeInfo info = infoRef.get(); |
|
|
|
assertThat(info.getHeaders().getFirst("Upgrade"), Matchers.equalToIgnoringCase("websocket")); |
|
|
|
assertThat(info.getHeaders().getFirst("Upgrade"), Matchers.equalToIgnoringCase("websocket")); |
|
|
|
assertEquals(protocol, info.getHeaders().getFirst("Sec-WebSocket-Protocol")); |
|
|
|
assertEquals(protocol, info.getHeaders().getFirst("Sec-WebSocket-Protocol")); |
|
|
|
assertEquals("Wrong protocol accepted", protocol, info.getSubProtocol()); |
|
|
|
assertEquals("Wrong protocol accepted", protocol, info.getSubProtocol()); |
|
|
|
assertEquals("Wrong protocol detected on the server side", protocol, output.block(Duration.ofMillis(5000))); |
|
|
|
assertEquals("Wrong protocol detected on the server side", protocol, output.block(TIMEOUT)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -122,9 +121,9 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests |
|
|
|
.map(WebSocketMessage::getPayloadAsText) |
|
|
|
.map(WebSocketMessage::getPayloadAsText) |
|
|
|
.subscribeWith(output) |
|
|
|
.subscribeWith(output) |
|
|
|
.then()) |
|
|
|
.then()) |
|
|
|
.block(Duration.ofMillis(5000)); |
|
|
|
.block(TIMEOUT); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals("my-header:my-value", output.block(Duration.ofMillis(5000))); |
|
|
|
assertEquals("my-header:my-value", output.block(TIMEOUT)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -139,7 +138,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests |
|
|
|
logger.debug("Completed with: " + signalType); |
|
|
|
logger.debug("Completed with: " + signalType); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.block(Duration.ofMillis(5000)); |
|
|
|
.block(TIMEOUT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|