Migrate rest of test suite from JUnit 4 to JUnit Jupiter
This commit migrates the rest of Spring's test suite to JUnit Jupiter, except spring-test which will be migrated in a separate commit. See gh-23451
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.http.server.ServerHttpAsyncRequestControl;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
@@ -44,7 +44,7 @@ public abstract class AbstractHttpRequestTests {
|
||||
protected ServerHttpAsyncRequestControl asyncControl;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
resetRequestAndResponse();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,16 +16,19 @@
|
||||
|
||||
package org.springframework.web.socket;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -56,23 +59,28 @@ public abstract class AbstractWebSocketIntegrationTests {
|
||||
}
|
||||
|
||||
|
||||
@Rule
|
||||
public final TestName testName = new TestName();
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@ParameterizedTest(name = "server [{0}], client [{1}]")
|
||||
@MethodSource("arguments")
|
||||
protected @interface ParameterizedWebSocketTest {
|
||||
}
|
||||
|
||||
@Parameter(0)
|
||||
public WebSocketTestServer server;
|
||||
|
||||
@Parameter(1)
|
||||
public WebSocketClient webSocketClient;
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
protected WebSocketTestServer server;
|
||||
|
||||
protected WebSocketClient webSocketClient;
|
||||
|
||||
protected AnnotationConfigWebApplicationContext wac;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
logger.debug("Setting up '" + this.testName.getMethodName() + "', client=" +
|
||||
protected void setup(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
this.server = server;
|
||||
this.webSocketClient = webSocketClient;
|
||||
|
||||
logger.debug("Setting up '" + testInfo.getTestMethod().get().getName() + "', client=" +
|
||||
this.webSocketClient.getClass().getSimpleName() + ", server=" +
|
||||
this.server.getClass().getSimpleName());
|
||||
|
||||
@@ -94,8 +102,8 @@ public abstract class AbstractWebSocketIntegrationTests {
|
||||
|
||||
protected abstract Class<?>[] getAnnotatedConfigClasses();
|
||||
|
||||
@After
|
||||
public void teardown() throws Exception {
|
||||
@AfterEach
|
||||
void teardown() throws Exception {
|
||||
try {
|
||||
if (this.webSocketClient instanceof Lifecycle) {
|
||||
((Lifecycle) this.webSocketClient).stop();
|
||||
@@ -147,6 +155,7 @@ public abstract class AbstractWebSocketIntegrationTests {
|
||||
@Configuration
|
||||
static class JettyUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public RequestUpgradeStrategy requestUpgradeStrategy() {
|
||||
return new JettyRequestUpgradeStrategy();
|
||||
@@ -157,6 +166,7 @@ public abstract class AbstractWebSocketIntegrationTests {
|
||||
@Configuration
|
||||
static class TomcatUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public RequestUpgradeStrategy requestUpgradeStrategy() {
|
||||
return new TomcatRequestUpgradeStrategy();
|
||||
@@ -167,6 +177,7 @@ public abstract class AbstractWebSocketIntegrationTests {
|
||||
@Configuration
|
||||
static class UndertowUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public RequestUpgradeStrategy requestUpgradeStrategy() {
|
||||
return new UndertowRequestUpgradeStrategy();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.socket;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -23,14 +23,12 @@ import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.client.WebSocketClient;
|
||||
import org.springframework.web.socket.client.jetty.JettyWebSocketClient;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||
@@ -47,12 +45,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests {
|
||||
class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests {
|
||||
|
||||
@Parameters(name = "server [{0}], client [{1}]")
|
||||
public static Iterable<Object[]> arguments() {
|
||||
static Iterable<Object[]> arguments() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{new JettyWebSocketTestServer(), new JettyWebSocketClient()},
|
||||
{new TomcatWebSocketTestServer(), new StandardWebSocketClient()},
|
||||
@@ -66,8 +63,11 @@ public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests {
|
||||
return new Class<?>[] {TestConfig.class};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subProtocolNegotiation() throws Exception {
|
||||
|
||||
@ParameterizedWebSocketTest
|
||||
void subProtocolNegotiation(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
|
||||
headers.setSecWebSocketProtocol("foo");
|
||||
URI url = new URI(getWsBaseUrl() + "/ws");
|
||||
@@ -76,8 +76,10 @@ public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests {
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test // SPR-12727
|
||||
public void unsolicitedPongWithEmptyPayload() throws Exception {
|
||||
@ParameterizedWebSocketTest // SPR-12727
|
||||
void unsolicitedPongWithEmptyPayload(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
String url = getWsBaseUrl() + "/ws";
|
||||
WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get();
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.web.socket.adapter.jetty;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
@@ -46,7 +46,7 @@ public class JettyWebSocketHandlerAdapterTests {
|
||||
private Session session;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.session = mock(Session.class);
|
||||
given(this.session.getUpgradeRequest()).willReturn(Mockito.mock(UpgradeRequest.class));
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.web.socket.handler.TestPrincipal;
|
||||
|
||||
@@ -22,9 +22,9 @@ import javax.websocket.Decoder;
|
||||
import javax.websocket.EncodeException;
|
||||
import javax.websocket.Encoder;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -62,12 +62,12 @@ public class ConvertingEncoderDecoderSupportTests {
|
||||
private MyType myType = new MyType("test");
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
setup(Config.class);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() {
|
||||
ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import javax.websocket.CloseReason.CloseCodes;
|
||||
import javax.websocket.MessageHandler;
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
@@ -51,7 +51,7 @@ public class StandardWebSocketHandlerAdapterTests {
|
||||
private Session session;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.session = mock(Session.class);
|
||||
this.webSocketHandler = mock(WebSocketHandler.class);
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
@@ -25,9 +25,9 @@ import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
|
||||
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -55,7 +55,7 @@ public class JettyWebSocketClientTests {
|
||||
private WebSocketSession wsSession;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
|
||||
this.server = new TestJettyWebSocketServer(new TextWebSocketHandler());
|
||||
@@ -67,7 +67,7 @@ public class JettyWebSocketClientTests {
|
||||
this.wsUrl = "ws://localhost:" + this.server.getPort() + "/test";
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() throws Exception {
|
||||
this.wsSession.close();
|
||||
this.client.stop();
|
||||
|
||||
@@ -25,8 +25,8 @@ import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.Endpoint;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
@@ -57,7 +57,7 @@ public class StandardWebSocketClientTests {
|
||||
private WebSocketHttpHeaders headers;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.headers = new WebSocketHttpHeaders();
|
||||
this.wsHandler = new AbstractWebSocketHandler() {
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.socket.config.annotation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
@@ -46,7 +46,7 @@ public class WebMvcStompEndpointRegistryTests {
|
||||
private SubProtocolWebSocketHandler webSocketHandler;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
SubscribableChannel inChannel = mock(SubscribableChannel.class);
|
||||
SubscribableChannel outChannel = mock(SubscribableChannel.class);
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
@@ -55,7 +55,7 @@ public class WebMvcStompWebSocketEndpointRegistrationTests {
|
||||
private TaskScheduler scheduler;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.handler = new SubProtocolWebSocketHandler(mock(MessageChannel.class), mock(SubscribableChannel.class));
|
||||
this.scheduler = mock(TaskScheduler.class);
|
||||
|
||||
@@ -20,10 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -33,6 +30,8 @@ import org.springframework.web.socket.JettyWebSocketTestServer;
|
||||
import org.springframework.web.socket.TomcatWebSocketTestServer;
|
||||
import org.springframework.web.socket.UndertowTestServer;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.WebSocketTestServer;
|
||||
import org.springframework.web.socket.client.WebSocketClient;
|
||||
import org.springframework.web.socket.client.jetty.JettyWebSocketClient;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
|
||||
@@ -45,12 +44,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Integration tests for WebSocket Java server-side configuration.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTests {
|
||||
class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTests {
|
||||
|
||||
@Parameters(name = "server [{0}], client [{1}]")
|
||||
public static Iterable<Object[]> arguments() {
|
||||
static Iterable<Object[]> arguments() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{new JettyWebSocketTestServer(), new JettyWebSocketClient()},
|
||||
{new TomcatWebSocketTestServer(), new StandardWebSocketClient()},
|
||||
@@ -64,8 +62,11 @@ public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTes
|
||||
return new Class<?>[] {TestConfig.class};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerWebSocketHandler() throws Exception {
|
||||
|
||||
@ParameterizedWebSocketTest
|
||||
void registerWebSocketHandler(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
WebSocketSession session = this.webSocketClient.doHandshake(
|
||||
new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/ws").get();
|
||||
|
||||
@@ -75,8 +76,10 @@ public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTes
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerWebSocketHandlerWithSockJS() throws Exception {
|
||||
@ParameterizedWebSocketTest
|
||||
void registerWebSocketHandlerWithSockJS(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
WebSocketSession session = this.webSocketClient.doHandshake(
|
||||
new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/sockjs/websocket").get();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.web.socket.config.annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.handler;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.BeanInstantiationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.web.socket.handler;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
@@ -41,7 +41,7 @@ public class ExceptionWebSocketHandlerDecoratorTests {
|
||||
private WebSocketHandler delegate;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
|
||||
this.delegate = mock(WebSocketHandler.class);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.handler;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.handler;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.web.socket.handler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.WebSocketExtension;
|
||||
import org.springframework.web.socket.WebSocketHttpHeaders;
|
||||
@@ -37,7 +37,7 @@ public class WebSocketHttpHeadersTests {
|
||||
|
||||
private WebSocketHttpHeaders headers;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
headers = new WebSocketHttpHeaders();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.web.socket.messaging;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
@@ -36,7 +36,7 @@ public class StompSubProtocolErrorHandlerTests {
|
||||
private StompSubProtocolErrorHandler handler;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.handler = new StompSubProtocolErrorHandler();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class StompSubProtocolHandlerTests {
|
||||
private ArgumentCaptor<Message> messageCaptor;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.protocolHandler = new StompSubProtocolHandler();
|
||||
this.channel = Mockito.mock(MessageChannel.class);
|
||||
|
||||
@@ -23,10 +23,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -49,6 +46,8 @@ import org.springframework.web.socket.TextMessage;
|
||||
import org.springframework.web.socket.TomcatWebSocketTestServer;
|
||||
import org.springframework.web.socket.UndertowTestServer;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.WebSocketTestServer;
|
||||
import org.springframework.web.socket.client.WebSocketClient;
|
||||
import org.springframework.web.socket.client.jetty.JettyWebSocketClient;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration;
|
||||
@@ -64,15 +63,13 @@ import static org.springframework.web.socket.messaging.StompTextMessageBuilder.c
|
||||
* Integration tests with annotated message-handling methods.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
|
||||
class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
|
||||
|
||||
private static final long TIMEOUT = 10;
|
||||
|
||||
|
||||
@Parameters(name = "server [{0}], client [{1}]")
|
||||
public static Object[][] arguments() {
|
||||
static Object[][] arguments() {
|
||||
return new Object[][] {
|
||||
{new JettyWebSocketTestServer(), new JettyWebSocketClient()},
|
||||
{new TomcatWebSocketTestServer(), new StandardWebSocketClient()},
|
||||
@@ -87,8 +84,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sendMessageToController() throws Exception {
|
||||
@ParameterizedWebSocketTest
|
||||
void sendMessageToController(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
TextMessage message = create(StompCommand.SEND).headers("destination:/app/simple").build();
|
||||
WebSocketSession session = doHandshake(new TestClientWebSocketHandler(0, message), "/ws").get();
|
||||
|
||||
@@ -101,8 +100,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendMessageToControllerAndReceiveReplyViaTopic() throws Exception {
|
||||
@ParameterizedWebSocketTest
|
||||
void sendMessageToControllerAndReceiveReplyViaTopic(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build();
|
||||
TextMessage m1 = create(StompCommand.SUBSCRIBE)
|
||||
.headers("id:subs1", "destination:/topic/increment").build();
|
||||
@@ -120,8 +121,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||
}
|
||||
}
|
||||
|
||||
@Test // SPR-10930
|
||||
public void sendMessageToBrokerAndReceiveReplyViaTopic() throws Exception {
|
||||
@ParameterizedWebSocketTest // SPR-10930
|
||||
void sendMessageToBrokerAndReceiveReplyViaTopic(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build();
|
||||
TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", "destination:/topic/foo").build();
|
||||
TextMessage m2 = create(StompCommand.SEND).headers("destination:/topic/foo").body("5").build();
|
||||
@@ -140,8 +143,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||
}
|
||||
}
|
||||
|
||||
@Test // SPR-11648
|
||||
public void sendSubscribeToControllerAndReceiveReply() throws Exception {
|
||||
@ParameterizedWebSocketTest // SPR-11648
|
||||
void sendSubscribeToControllerAndReceiveReply(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build();
|
||||
String destHeader = "destination:/app/number";
|
||||
TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", destHeader).build();
|
||||
@@ -160,8 +165,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleExceptionAndSendToUser() throws Exception {
|
||||
@ParameterizedWebSocketTest
|
||||
void handleExceptionAndSendToUser(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
String destHeader = "destination:/user/queue/error";
|
||||
TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build();
|
||||
TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", destHeader).build();
|
||||
@@ -182,8 +189,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void webSocketScope() throws Exception {
|
||||
@ParameterizedWebSocketTest
|
||||
void webSocketScope(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception {
|
||||
super.setup(server, webSocketClient, testInfo);
|
||||
|
||||
TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build();
|
||||
TextMessage m1 = create(StompCommand.SUBSCRIBE)
|
||||
.headers("id:subs1", "destination:/topic/scopedBeanValue").build();
|
||||
|
||||
@@ -19,11 +19,11 @@ package org.springframework.web.socket.messaging;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
public class SubProtocolWebSocketHandlerTests {
|
||||
|
||||
@Mock SubProtocolHandler stompHandler;
|
||||
@@ -66,7 +66,7 @@ public class SubProtocolWebSocketHandlerTests {
|
||||
private TestWebSocketSession session;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.webSocketHandler = new SubProtocolWebSocketHandler(this.inClientChannel, this.outClientChannel);
|
||||
given(stompHandler.getSupportedProtocols()).willReturn(Arrays.asList("v10.stomp", "v11.stomp", "v12.stomp"));
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.socket.messaging;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
@@ -48,7 +48,7 @@ public class WebSocketAnnotationMethodMessageHandlerTests {
|
||||
private StaticApplicationContext applicationContext;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.applicationContext = new StaticApplicationContext();
|
||||
this.applicationContext.registerSingleton("controller", TestController.class);
|
||||
|
||||
@@ -22,11 +22,10 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
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.springframework.context.annotation.Configuration;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -52,14 +51,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link WebSocketStompClient}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class WebSocketStompClientIntegrationTests {
|
||||
class WebSocketStompClientIntegrationTests {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(WebSocketStompClientIntegrationTests.class);
|
||||
|
||||
@Rule
|
||||
public final TestName testName = new TestName();
|
||||
|
||||
private WebSocketStompClient stompClient;
|
||||
|
||||
@@ -68,10 +67,9 @@ public class WebSocketStompClientIntegrationTests {
|
||||
private AnnotationConfigWebApplicationContext wac;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
|
||||
@BeforeEach
|
||||
void setUp(TestInfo testInfo) throws Exception {
|
||||
logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'");
|
||||
|
||||
this.wac = new AnnotationConfigWebApplicationContext();
|
||||
this.wac.register(TestConfig.class);
|
||||
@@ -87,8 +85,8 @@ public class WebSocketStompClientIntegrationTests {
|
||||
this.stompClient.setMessageConverter(new StringMessageConverter());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void tearDown() throws Exception {
|
||||
try {
|
||||
this.server.undeployConfig();
|
||||
}
|
||||
@@ -111,7 +109,7 @@ public class WebSocketStompClientIntegrationTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void publishSubscribe() throws Exception {
|
||||
void publishSubscribe() throws Exception {
|
||||
|
||||
String url = "ws://127.0.0.1:" + this.server.getPort() + "/stomp";
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.simp.stomp.ConnectionHandlingStompSession;
|
||||
@@ -64,7 +64,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
public class WebSocketStompClientTests {
|
||||
|
||||
@Mock
|
||||
@@ -83,7 +83,7 @@ public class WebSocketStompClientTests {
|
||||
private SettableListenableFuture<WebSocketSession> handshakeFuture;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
WebSocketClient webSocketClient = mock(WebSocketClient.class);
|
||||
this.stompClient = new TestWebSocketStompClient(webSocketClient);
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.socket.AbstractHttpRequestTests;
|
||||
|
||||
@@ -23,8 +23,8 @@ import javax.websocket.Session;
|
||||
import javax.websocket.server.ServerContainer;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -51,7 +51,7 @@ public class ServerEndpointExporterTests {
|
||||
private ServerEndpointExporter exporter;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.serverContainer = mock(ServerContainer.class);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.websocket.Endpoint;
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.web.socket.server.standard;
|
||||
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -44,7 +44,7 @@ public class SpringConfiguratorTests {
|
||||
private SpringConfigurator configurator;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.servletContext = new MockServletContext();
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SpringConfiguratorTests {
|
||||
this.configurator = new SpringConfigurator();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void destroy() {
|
||||
this.contextLoader.closeWebApplicationContext(this.servletContext);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.AbstractHttpRequestTests;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
@@ -53,7 +53,7 @@ public class HandshakeInterceptorChainTests extends AbstractHttpRequestTests {
|
||||
private Map<String, Object> attributes;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
super.setup();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.mock.web.test.MockHttpSession;
|
||||
import org.springframework.web.socket.AbstractHttpRequestTests;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
|
||||
@@ -39,12 +39,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -81,9 +81,6 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
*/
|
||||
public abstract class AbstractSockJsIntegrationTests {
|
||||
|
||||
@Rule
|
||||
public final TestName testName = new TestName();
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
||||
@@ -98,15 +95,16 @@ public abstract class AbstractSockJsIntegrationTests {
|
||||
private String baseUrl;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void performanceTestGroupAssumption() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
logger.debug("Setting up '" + this.testName.getMethodName() + "'");
|
||||
@BeforeEach
|
||||
public void setup(TestInfo testInfo) throws Exception {
|
||||
logger.debug("Setting up '" + testInfo.getTestMethod().get().getName() + "'");
|
||||
|
||||
this.testFilter = new TestFilter();
|
||||
|
||||
this.wac = new AnnotationConfigWebApplicationContext();
|
||||
@@ -123,7 +121,7 @@ public abstract class AbstractSockJsIntegrationTests {
|
||||
this.baseUrl = "http://localhost:" + this.server.getPort();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() throws Exception {
|
||||
try {
|
||||
this.sockJsClient.stop();
|
||||
@@ -249,7 +247,8 @@ public abstract class AbstractSockJsIntegrationTests {
|
||||
handler.awaitMessage(message, 5000);
|
||||
}
|
||||
|
||||
@Test(timeout = 5000)
|
||||
@Test
|
||||
@Timeout(5)
|
||||
public void fallbackAfterConnectTimeout() throws Exception {
|
||||
TestClientHandler clientHandler = new TestClientHandler();
|
||||
this.testFilter.sleepDelayMap.put("/xhr_streaming", 10000L);
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
@@ -59,7 +59,7 @@ public class ClientSockJsSessionTests {
|
||||
private SettableListenableFuture<WebSocketSession> connectFuture;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
SockJsUrlInfo urlInfo = new SockJsUrlInfo(new URI("https://example.com"));
|
||||
Transport transport = mock(Transport.class);
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -60,7 +60,7 @@ public class DefaultTransportRequestTests {
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
this.connectCallback = mock(ListenableFutureCallback.class);
|
||||
this.connectFuture = new SettableListenableFuture<>();
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.Queue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.SyncTaskExecutor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -65,7 +65,7 @@ public class SockJsClientTests {
|
||||
private ListenableFutureCallback<WebSocketSession> connectCallback;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setup() {
|
||||
this.infoReceiver = mock(InfoReceiver.class);
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.socket.sockjs.client;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.sockjs.transport.TransportType;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.socket.sockjs.client;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.sockjs.frame;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.Collections;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -57,7 +57,7 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
||||
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
super.setup();
|
||||
this.service = new TestSockJsService(new ThreadPoolTaskScheduler());
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.sockjs.transport;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
@@ -58,7 +58,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Ben Kiefer
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
|
||||
|
||||
private static final String sockJsPrefix = "/mysockjs";
|
||||
@@ -89,7 +89,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
|
||||
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
super.setup();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.sockjs.transport.handler;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.AbstractHttpRequestTests;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.web.socket.sockjs.transport.handler;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.web.socket.AbstractHttpRequestTests;
|
||||
@@ -50,7 +50,7 @@ public class HttpSendingTransportHandlerTests extends AbstractHttpRequestTests
|
||||
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
super.setup();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.socket.sockjs.transport.handler;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.sockjs.transport.session;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
@@ -40,7 +40,7 @@ public abstract class AbstractSockJsSessionTests<S extends AbstractSockJsSession
|
||||
protected S session;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.webSocketHandler = mock(WebSocketHandler.class);
|
||||
this.taskScheduler = mock(TaskScheduler.class);
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.web.socket.sockjs.transport.session;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
@@ -62,7 +62,7 @@ public class HttpSockJsSessionTests extends AbstractSockJsSessionTests<TestAbstr
|
||||
return new TestAbstractHttpSockJsSession(this.sockJsConfig, this.webSocketHandler, null);
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
|
||||
super.setUp();
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
@@ -51,7 +51,7 @@ public class WebSocketServerSockJsSessionTests extends AbstractSockJsSessionTest
|
||||
private TestWebSocketSession webSocketSession;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
super.setUp();
|
||||
this.webSocketSession = new TestWebSocketSession();
|
||||
|
||||
Reference in New Issue
Block a user