GH-171: Fix WebSocket tests for upstream changes
Related to: https://github.com/spring-cloud/stream-applications/issues/171
This commit is contained in:
@@ -20,7 +20,6 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -46,7 +45,7 @@ import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
properties = "websocket.supplier.path=/some_websocket_path")
|
||||
properties = "websocket.supplier.path=some_websocket_path")
|
||||
@DirtiesContext
|
||||
public class WebsocketSourceTests {
|
||||
|
||||
@@ -66,11 +65,10 @@ public class WebsocketSourceTests {
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testWebsocketSource() throws IOException {
|
||||
StandardWebSocketClient webSocketClient = new StandardWebSocketClient();
|
||||
ClientWebSocketContainer clientWebSocketContainer =
|
||||
new ClientWebSocketContainer(webSocketClient, "ws://localhost:{port}{path}",
|
||||
new ClientWebSocketContainer(webSocketClient, "ws://localhost:{port}/{path}",
|
||||
this.port,
|
||||
this.properties.getPath());
|
||||
|
||||
@@ -85,7 +83,7 @@ public class WebsocketSourceTests {
|
||||
session.sendMessage(new TextMessage("foo"));
|
||||
session.close();
|
||||
|
||||
Message<byte[]> sourceMessage = output.receive(10000);
|
||||
Message<byte[]> sourceMessage = output.receive(10000, "websocketSupplier-out-0");
|
||||
final String actual = new String(sourceMessage.getPayload());
|
||||
assertThat(actual).isEqualTo("foo");
|
||||
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
package org.springframework.cloud.fn.supplier.websocket;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -39,8 +40,6 @@ import org.springframework.web.socket.TextMessage;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
properties = "websocket.supplier.path=some_websocket_path")
|
||||
@DirtiesContext
|
||||
@@ -62,19 +61,17 @@ public class WebsocketSupplierTests {
|
||||
|
||||
@Test
|
||||
public void checkCmdlineArgs() {
|
||||
assertThat(this.properties.getPath()).isEqualTo("/some_websocket_path");
|
||||
assertThat(this.properties.getPath()).isEqualTo("some_websocket_path");
|
||||
assertThat(this.properties.getAllowedOrigins()).isEqualTo("*");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testBasicFlow() throws IOException {
|
||||
final Flux<Message<?>> messageFlux = websocketSupplier.get();
|
||||
final StepVerifier stepVerifier = StepVerifier.create(messageFlux)
|
||||
.assertNext((message) -> {
|
||||
assertThat(message.getPayload())
|
||||
.isEqualTo(messageString);
|
||||
}
|
||||
.assertNext((message) ->
|
||||
assertThat(message.getPayload())
|
||||
.isEqualTo(messageString)
|
||||
)
|
||||
.thenCancel()
|
||||
.verifyLater();
|
||||
@@ -100,5 +97,7 @@ public class WebsocketSupplierTests {
|
||||
|
||||
@SpringBootApplication
|
||||
static class WebsocketSupplierTestApplication {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user