From 454e93cd6b3c430e6eba9d70292d70719881ed59 Mon Sep 17 00:00:00 2001 From: Jay Bryant Date: Fri, 20 Oct 2023 09:42:59 -0500 Subject: [PATCH] Use the @LocalServerPort annotation. --- .../messagingstompwebsocket/GreetingIntegrationTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/complete/src/test/java/com/example/messagingstompwebsocket/GreetingIntegrationTests.java b/complete/src/test/java/com/example/messagingstompwebsocket/GreetingIntegrationTests.java index 7cdd45f..4c73f46 100644 --- a/complete/src/test/java/com/example/messagingstompwebsocket/GreetingIntegrationTests.java +++ b/complete/src/test/java/com/example/messagingstompwebsocket/GreetingIntegrationTests.java @@ -22,12 +22,13 @@ import org.springframework.web.socket.client.WebSocketClient; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.messaging.WebSocketStompClient; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.web.server.LocalServerPort; + @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class GreetingIntegrationTests { - @Value(value="${local.server.port}") + @LocalServerPort private int port; private WebSocketStompClient stompClient;