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:
@@ -19,7 +19,7 @@ package org.springframework.http;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.http;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.http;
|
||||
import java.util.LinkedHashMap;
|
||||
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 static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class HttpStatusTests {
|
||||
private Map<Integer, String> statusCodes = new LinkedHashMap<>();
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void createStatusCodes() {
|
||||
statusCodes.put(100, "CONTINUE");
|
||||
statusCodes.put(101, "SWITCHING_PROTOCOLS");
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.web.util.UriTemplate;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.http;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
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.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -41,12 +41,12 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractAsyncHttpRequestFactoryTestCase extends AbstractMockWebServerTestCase {
|
||||
public abstract class AbstractAsyncHttpRequestFactoryTests extends AbstractMockWebServerTests {
|
||||
|
||||
protected AsyncClientHttpRequestFactory factory;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public final void createFactory() throws Exception {
|
||||
this.factory = createRequestFactory();
|
||||
if (this.factory instanceof InitializingBean) {
|
||||
@@ -54,7 +54,7 @@ public abstract class AbstractAsyncHttpRequestFactoryTestCase extends AbstractMo
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public final void destroyFactory() throws Exception {
|
||||
if (this.factory instanceof DisposableBean) {
|
||||
((DisposableBean) this.factory).destroy();
|
||||
@@ -21,9 +21,9 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
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.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -40,12 +40,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public abstract class AbstractHttpRequestFactoryTestCase extends AbstractMockWebServerTestCase {
|
||||
public abstract class AbstractHttpRequestFactoryTests extends AbstractMockWebServerTests {
|
||||
|
||||
protected ClientHttpRequestFactory factory;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public final void createFactory() throws Exception {
|
||||
factory = createRequestFactory();
|
||||
if (factory instanceof InitializingBean) {
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractHttpRequestFactoryTestCase extends AbstractMockWeb
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public final void destroyFactory() throws Exception {
|
||||
if (factory instanceof DisposableBean) {
|
||||
((DisposableBean) factory).destroy();
|
||||
@@ -22,19 +22,18 @@ import okhttp3.mockwebserver.Dispatcher;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class AbstractMockWebServerTestCase {
|
||||
public abstract class AbstractMockWebServerTests {
|
||||
|
||||
private MockWebServer server;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class AbstractMockWebServerTestCase {
|
||||
protected static final MediaType textContentType =
|
||||
new MediaType("text", "plain", Collections.singletonMap("charset", "UTF-8"));
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
this.server.setDispatcher(new TestDispatcher());
|
||||
@@ -54,7 +53,7 @@ public class AbstractMockWebServerTestCase {
|
||||
this.baseUrl = "http://localhost:" + this.port;
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
this.server.shutdown();
|
||||
}
|
||||
@@ -18,13 +18,13 @@ package org.springframework.http.client;
|
||||
|
||||
import java.net.ProtocolException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
public class BufferedSimpleAsyncHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
|
||||
public class BufferedSimpleAsyncHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
||||
@@ -23,13 +23,13 @@ import java.net.HttpURLConnection;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class BufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.http.client;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -27,7 +27,7 @@ import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BufferingClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class BufferingClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HttpComponentsAsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
|
||||
public class HttpComponentsAsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected AsyncClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.withSettings;
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.http.client;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class InterceptingStreamingHttpComponentsTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class InterceptingStreamingHttpComponentsTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.http.client;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -18,26 +18,26 @@ package org.springframework.http.client;
|
||||
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Netty4AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
|
||||
public class Netty4AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests {
|
||||
|
||||
private static EventLoopGroup eventLoopGroup;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void createEventLoopGroup() {
|
||||
eventLoopGroup = new NioEventLoopGroup();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void shutdownEventLoopGroup() throws InterruptedException {
|
||||
eventLoopGroup.shutdownGracefully().sync();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -18,26 +18,26 @@ package org.springframework.http.client;
|
||||
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Netty4ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class Netty4ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
private static EventLoopGroup eventLoopGroup;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void createEventLoopGroup() {
|
||||
eventLoopGroup = new NioEventLoopGroup();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void shutdownEventLoopGroup() throws InterruptedException {
|
||||
eventLoopGroup.shutdownGracefully().sync();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.http.client;
|
||||
|
||||
|
||||
public class NoOutputStreamingBufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class NoOutputStreamingBufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.http.client;
|
||||
|
||||
|
||||
public class NoOutputStreamingStreamingSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class NoOutputStreamingStreamingSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.http.client;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
public class OkHttp3AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
|
||||
public class OkHttp3AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.http.client;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
public class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.http.client;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.http.client;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class StreamingHttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class StreamingHttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class StreamingSimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
|
||||
public class StreamingSimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
@@ -69,7 +69,7 @@ public class StreamingSimpleClientHttpRequestFactoryTests extends AbstractHttpRe
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void largeFileUpload() throws Exception {
|
||||
Random rnd = new Random();
|
||||
ClientHttpResponse response = null;
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.http.client.reactive;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.netty.http.HttpResources;
|
||||
import reactor.netty.resources.ConnectionProvider;
|
||||
import reactor.netty.resources.LoopResources;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.http.client.support;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.http.client.support;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.http.client.support;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
@@ -32,7 +32,7 @@ public class ProxyFactoryBeanTests {
|
||||
|
||||
ProxyFactoryBean factoryBean;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
factoryBean = new ProxyFactoryBean();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscription;
|
||||
import reactor.core.publisher.BaseSubscriber;
|
||||
@@ -56,7 +56,7 @@ public class CancelWithoutDemandCodecTests {
|
||||
private final LeakAwareDataBufferFactory bufferFactory = new LeakAwareDataBufferFactory();
|
||||
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
this.bufferFactory.checkForLeaks();
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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 reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -54,11 +54,12 @@ import static org.springframework.http.MediaType.TEXT_XML;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link EncoderHttpMessageWriter}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class EncoderHttpMessageWriterTests {
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
class EncoderHttpMessageWriterTests {
|
||||
|
||||
private static final Map<String, Object> NO_HINTS = Collections.emptyMap();
|
||||
|
||||
@@ -74,14 +75,14 @@ public class EncoderHttpMessageWriterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void getWritableMediaTypes() {
|
||||
void getWritableMediaTypes() {
|
||||
configureEncoder(MimeTypeUtils.TEXT_HTML, MimeTypeUtils.TEXT_XML);
|
||||
HttpMessageWriter<?> writer = new EncoderHttpMessageWriter<>(this.encoder);
|
||||
assertThat(writer.getWritableMediaTypes()).isEqualTo(Arrays.asList(TEXT_HTML, TEXT_XML));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
configureEncoder(MimeTypeUtils.TEXT_HTML);
|
||||
HttpMessageWriter<?> writer = new EncoderHttpMessageWriter<>(this.encoder);
|
||||
given(this.encoder.canEncode(forClass(String.class), TEXT_HTML)).willReturn(true);
|
||||
@@ -91,7 +92,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useNegotiatedMediaType() {
|
||||
void useNegotiatedMediaType() {
|
||||
configureEncoder(TEXT_PLAIN);
|
||||
HttpMessageWriter<String> writer = new EncoderHttpMessageWriter<>(this.encoder);
|
||||
writer.write(Flux.empty(), forClass(String.class), TEXT_PLAIN, this.response, NO_HINTS);
|
||||
@@ -101,7 +102,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useDefaultMediaType() {
|
||||
void useDefaultMediaType() {
|
||||
testDefaultMediaType(null);
|
||||
testDefaultMediaType(new MediaType("text", "*"));
|
||||
testDefaultMediaType(new MediaType("*", "*"));
|
||||
@@ -119,7 +120,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useDefaultMediaTypeCharset() {
|
||||
void useDefaultMediaTypeCharset() {
|
||||
configureEncoder(TEXT_PLAIN_UTF_8, TEXT_HTML);
|
||||
HttpMessageWriter<String> writer = new EncoderHttpMessageWriter<>(this.encoder);
|
||||
writer.write(Flux.empty(), forClass(String.class), TEXT_HTML, response, NO_HINTS);
|
||||
@@ -129,7 +130,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useNegotiatedMediaTypeCharset() {
|
||||
void useNegotiatedMediaTypeCharset() {
|
||||
MediaType negotiatedMediaType = new MediaType("text", "html", ISO_8859_1);
|
||||
configureEncoder(TEXT_PLAIN_UTF_8, TEXT_HTML);
|
||||
HttpMessageWriter<String> writer = new EncoderHttpMessageWriter<>(this.encoder);
|
||||
@@ -140,7 +141,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useHttpOutputMessageMediaType() {
|
||||
void useHttpOutputMessageMediaType() {
|
||||
MediaType outputMessageMediaType = MediaType.TEXT_HTML;
|
||||
this.response.getHeaders().setContentType(outputMessageMediaType);
|
||||
|
||||
@@ -153,7 +154,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setContentLengthForMonoBody() {
|
||||
void setContentLengthForMonoBody() {
|
||||
DefaultDataBufferFactory factory = new DefaultDataBufferFactory();
|
||||
DataBuffer buffer = factory.wrap("body".getBytes(StandardCharsets.UTF_8));
|
||||
configureEncoder(buffer, MimeTypeUtils.TEXT_PLAIN);
|
||||
@@ -164,7 +165,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test // gh-22952
|
||||
public void monoBodyDoesNotCancelEncodedFlux() {
|
||||
void monoBodyDoesNotCancelEncodedFlux() {
|
||||
Mono<String> inputStream = Mono.just("body")
|
||||
.doOnCancel(() -> {
|
||||
throw new AssertionError("Cancel signal not expected");
|
||||
@@ -175,7 +176,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test // SPR-17220
|
||||
public void emptyBodyWritten() {
|
||||
void emptyBodyWritten() {
|
||||
configureEncoder(MimeTypeUtils.TEXT_PLAIN);
|
||||
HttpMessageWriter<String> writer = new EncoderHttpMessageWriter<>(this.encoder);
|
||||
writer.write(Mono.empty(), forClass(String.class), TEXT_PLAIN, this.response, NO_HINTS).block();
|
||||
@@ -184,7 +185,7 @@ public class EncoderHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test // gh-22936
|
||||
public void isStreamingMediaType() throws InvocationTargetException, IllegalAccessException {
|
||||
void isStreamingMediaType() throws InvocationTargetException, IllegalAccessException {
|
||||
configureEncoder(TEXT_HTML);
|
||||
MediaType streamingMediaType = new MediaType(TEXT_PLAIN, Collections.singletonMap("streaming", "true"));
|
||||
given(this.encoder.getStreamingMediaTypes()).willReturn(Arrays.asList(streamingMediaType));
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
|
||||
@@ -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 reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.UncheckedIOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import com.fasterxml.jackson.core.TreeNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.util.TokenBuffer;
|
||||
import org.json.JSONException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.skyscreamer.jsonassert.JSONAssert;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -52,7 +52,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTestCase {
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void createParser() {
|
||||
this.jsonFactory = new JsonFactory();
|
||||
this.objectMapper = new ObjectMapper(this.jsonFactory);
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.publisher.UnicastProcessor;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.File;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.UncheckedIOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.google.protobuf.ExtensionRegistry;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.ByteArrayDecoder;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -42,7 +42,7 @@ public class BufferedImageHttpMessageConverterTests {
|
||||
|
||||
private BufferedImageHttpMessageConverter converter;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
converter = new BufferedImageHttpMessageConverter();
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.http.converter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.MockHttpInputMessage;
|
||||
@@ -32,7 +32,7 @@ public class ByteArrayHttpMessageConverterTests {
|
||||
|
||||
private ByteArrayHttpMessageConverter converter;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
converter = new ByteArrayHttpMessageConverter();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.apache.commons.fileupload.FileItemFactory;
|
||||
import org.apache.commons.fileupload.FileUpload;
|
||||
import org.apache.commons.fileupload.RequestContext;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.http.converter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
@@ -52,7 +52,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
private ServletServerHttpResponse response;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
ConversionService conversionService = new DefaultConversionService();
|
||||
this.converter = new ObjectToStringHttpMessageConverter(conversionService);
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.BDDMockito;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.http.converter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
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.MediaType;
|
||||
@@ -42,7 +42,7 @@ public class StringHttpMessageConverterTests {
|
||||
private MockHttpOutputMessage outputMessage;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.converter = new StringHttpMessageConverter();
|
||||
this.outputMessage = new MockHttpOutputMessage();
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.List;
|
||||
|
||||
import com.rometools.rome.feed.atom.Entry;
|
||||
import com.rometools.rome.feed.atom.Feed;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xmlunit.diff.DefaultNodeMatcher;
|
||||
import org.xmlunit.diff.ElementSelectors;
|
||||
@@ -47,7 +47,7 @@ public class AtomFeedHttpMessageConverterTests {
|
||||
private AtomFeedHttpMessageConverter converter;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
converter = new AtomFeedHttpMessageConverter();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.List;
|
||||
|
||||
import com.rometools.rome.feed.rss.Channel;
|
||||
import com.rometools.rome.feed.rss.Item;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -44,7 +44,7 @@ public class RssChannelHttpMessageConverterTests {
|
||||
private RssChannelHttpMessageConverter converter;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
converter = new RssChannelHttpMessageConverter();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.skyscreamer.jsonassert.JSONAssert;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
|
||||
@@ -78,7 +78,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import kotlin.ranges.IntRange;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -60,7 +60,7 @@ import com.fasterxml.jackson.dataformat.smile.SmileFactory;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.skyscreamer.jsonassert.JSONAssert;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ser.FilterProvider;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.skyscreamer.jsonassert.JSONAssert;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
|
||||
@@ -47,8 +47,8 @@ import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
|
||||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
|
||||
@@ -69,7 +69,7 @@ public class SpringHandlerInstantiatorTests {
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.nio.charset.Charset;
|
||||
import com.google.protobuf.ExtensionRegistry;
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.MockHttpInputMessage;
|
||||
@@ -57,7 +57,7 @@ public class ProtobufHttpMessageConverterTests {
|
||||
private Msg testMsg;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.registryInitializer = mock(ExtensionRegistryInitializer.class);
|
||||
this.extensionRegistry = mock(ExtensionRegistry.class);
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.IOException;
|
||||
import com.google.protobuf.ExtensionRegistry;
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.MockHttpInputMessage;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.MockHttpInputMessage;
|
||||
|
||||
@@ -26,8 +26,8 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -57,7 +57,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
||||
private Type typeSetType;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
converter = new Jaxb2CollectionHttpMessageConverter<Collection<Object>>();
|
||||
rootElementListType = new ParameterizedTypeReference<List<RootElement>>() {}.getType();
|
||||
|
||||
@@ -26,8 +26,8 @@ import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xmlunit.diff.DifferenceEvaluator;
|
||||
|
||||
import org.springframework.aop.framework.AdvisedSupport;
|
||||
@@ -64,7 +64,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
private RootElement rootElementCglib;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
converter = new Jaxb2RootElementHttpMessageConverter();
|
||||
rootElement = new RootElement();
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.http.converter.xml;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.TypeMismatchException;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -29,8 +29,8 @@ import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stax.StAXSource;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.InputSource;
|
||||
@@ -63,7 +63,7 @@ public class SourceHttpMessageConverterTests {
|
||||
private String bodyExternal;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
converter = new SourceHttpMessageConverter<>();
|
||||
Resource external = new ClassPathResource("external.txt", getClass());
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.server.PathContainer.PathSegment;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.http.server;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
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.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -44,7 +44,7 @@ public class ServletServerHttpRequestTests {
|
||||
private MockHttpServletRequest mockRequest;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void create() {
|
||||
mockRequest = new MockHttpServletRequest();
|
||||
request = new ServletServerHttpRequest(mockRequest);
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
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.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -43,7 +43,7 @@ public class ServletServerHttpResponseTests {
|
||||
private MockHttpServletResponse mockResponse;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void create() throws Exception {
|
||||
mockResponse = new MockHttpServletResponse();
|
||||
response = new ServletServerHttpResponse(mockResponse);
|
||||
|
||||
@@ -17,14 +17,20 @@
|
||||
package org.springframework.http.server.reactive;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.time.Duration;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.http.server.reactive.bootstrap.HttpServer;
|
||||
@@ -32,32 +38,49 @@ import org.springframework.http.server.reactive.bootstrap.JettyHttpServer;
|
||||
import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer;
|
||||
import org.springframework.http.server.reactive.bootstrap.TomcatHttpServer;
|
||||
import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.HttpServerErrorException;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public abstract class AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
/**
|
||||
* Custom JUnit Jupiter extension that handles exceptions thrown by test methods.
|
||||
*
|
||||
* <p>If the test method throws an {@link HttpServerErrorException}, this
|
||||
* extension will throw an {@link AssertionError} that wraps the
|
||||
* {@code HttpServerErrorException} using the
|
||||
* {@link HttpServerErrorException#getResponseBodyAsString() response body}
|
||||
* as the failure message.
|
||||
*
|
||||
* <p>This mechanism provides an actually meaningful failure message if the
|
||||
* test fails due to an {@code AssertionError} on the server.
|
||||
*/
|
||||
@RegisterExtension
|
||||
TestExecutionExceptionHandler serverErrorToAssertionErrorConverter = (context, throwable) -> {
|
||||
if (throwable instanceof HttpServerErrorException) {
|
||||
HttpServerErrorException ex = (HttpServerErrorException) throwable;
|
||||
String responseBody = ex.getResponseBodyAsString();
|
||||
if (StringUtils.hasText(responseBody)) {
|
||||
String prefix = AssertionError.class.getName() + ": ";
|
||||
if (responseBody.startsWith(prefix)) {
|
||||
responseBody = responseBody.substring(prefix.length());
|
||||
}
|
||||
throw new AssertionError(responseBody, ex);
|
||||
}
|
||||
}
|
||||
// Else throw as-is in order to comply with the contract of TestExecutionExceptionHandler.
|
||||
throw throwable;
|
||||
};
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
protected HttpServer server;
|
||||
|
||||
protected int port;
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
public HttpServer server;
|
||||
|
||||
|
||||
@Parameterized.Parameters(name = "server [{0}]")
|
||||
public static Object[][] arguments() {
|
||||
File base = new File(System.getProperty("java.io.tmpdir"));
|
||||
return new Object[][] {
|
||||
{new JettyHttpServer()},
|
||||
{new ReactorHttpServer()},
|
||||
{new TomcatHttpServer(base.getAbsolutePath())},
|
||||
{new UndertowHttpServer()}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
protected void startServer(HttpServer httpServer) throws Exception {
|
||||
this.server = httpServer;
|
||||
this.server.setHandler(createHttpHandler());
|
||||
this.server.afterPropertiesSet();
|
||||
this.server.start();
|
||||
@@ -66,8 +89,8 @@ public abstract class AbstractHttpHandlerIntegrationTests {
|
||||
this.port = this.server.getPort();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void stopServer() {
|
||||
this.server.stop();
|
||||
this.port = 0;
|
||||
}
|
||||
@@ -92,4 +115,23 @@ public abstract class AbstractHttpHandlerIntegrationTests {
|
||||
return Flux.interval(period).take(count).onBackpressureBuffer(count);
|
||||
}
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@MethodSource("org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests#httpServers()")
|
||||
// public for Kotlin
|
||||
public @interface ParameterizedHttpServerTest {
|
||||
}
|
||||
|
||||
static Stream<HttpServer> httpServers() {
|
||||
File base = new File(System.getProperty("java.io.tmpdir"));
|
||||
return Stream.of(
|
||||
new JettyHttpServer(),
|
||||
new ReactorHttpServer(),
|
||||
new TomcatHttpServer(base.getAbsolutePath()),
|
||||
new UndertowHttpServer()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ package org.springframework.http.server.reactive;
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Scheduler;
|
||||
@@ -30,16 +28,16 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.reactive.bootstrap.HttpServer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* @author Stephane Maldini
|
||||
* @since 5.0
|
||||
*/
|
||||
public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
private final Scheduler asyncGroup = Schedulers.parallel();
|
||||
|
||||
@@ -51,12 +49,12 @@ public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
return new AsyncHandler();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // TODO: fragile due to socket failures
|
||||
public void basicTest() throws Exception {
|
||||
@ParameterizedHttpServerTest
|
||||
void basicTest(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
URI url = new URI("http://localhost:" + port);
|
||||
ResponseEntity<String> response = new RestTemplate().exchange(
|
||||
RequestEntity.get(url).build(), String.class);
|
||||
ResponseEntity<String> response = new RestTemplate().exchange(RequestEntity.get(url).build(), String.class);
|
||||
|
||||
assertThat(response.getBody()).isEqualTo("hello");
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
@@ -46,13 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public class ChannelSendOperatorTests {
|
||||
|
||||
private OneByOneAsyncWriter writer;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.writer = new OneByOneAsyncWriter();
|
||||
}
|
||||
private final OneByOneAsyncWriter writer = new OneByOneAsyncWriter();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -21,15 +21,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.reactive.bootstrap.HttpServer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -37,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
private final CookieHandler cookieHandler = new CookieHandler();
|
||||
@@ -49,8 +46,10 @@ public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void basicTest() throws Exception {
|
||||
@ParameterizedHttpServerTest
|
||||
public void basicTest(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
URI url = new URI("http://localhost:" + port);
|
||||
String header = "SID=31d4d96e407aad42; lang=en-US";
|
||||
ResponseEntity<Void> response = new RestTemplate().exchange(
|
||||
|
||||
@@ -19,11 +19,11 @@ package org.springframework.http.server.reactive;
|
||||
import java.net.URI;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.reactive.bootstrap.HttpServer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -44,8 +44,10 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void echo() throws Exception {
|
||||
@ParameterizedHttpServerTest
|
||||
public void echo(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
byte[] body = randomBytes();
|
||||
@@ -72,4 +74,5 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT
|
||||
return response.writeWith(request.getBody());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ package org.springframework.http.server.reactive;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.http.server.reactive.bootstrap.HttpServer;
|
||||
import org.springframework.web.client.ResponseErrorHandler;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
private final ErrorHandler handler = new ErrorHandler();
|
||||
|
||||
@@ -43,8 +43,10 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void responseBodyError() throws Exception {
|
||||
@ParameterizedHttpServerTest
|
||||
void responseBodyError(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
|
||||
|
||||
@@ -54,8 +56,10 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlingError() throws Exception {
|
||||
@ParameterizedHttpServerTest
|
||||
void handlingError(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
|
||||
|
||||
@@ -65,8 +69,9 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Test // SPR-15560
|
||||
public void emptyPathSegments() throws Exception {
|
||||
@ParameterizedHttpServerTest // SPR-15560
|
||||
void emptyPathSegments(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
|
||||
|
||||
@@ -16,97 +16,99 @@
|
||||
|
||||
package org.springframework.http.server.reactive;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
import io.undertow.util.HeaderMap;
|
||||
import org.apache.tomcat.util.http.MimeHeaders;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
|
||||
/**
|
||||
* Unit tests for {@code HeadersAdapters} {@code MultiValueMap} implementations.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class HeadersAdaptersTests {
|
||||
class HeadersAdaptersTests {
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
public MultiValueMap<String, String> headers;
|
||||
|
||||
@Parameterized.Parameters(name = "headers [{0}]")
|
||||
public static Object[][] arguments() {
|
||||
return new Object[][] {
|
||||
{CollectionUtils.toMultiValueMap(
|
||||
new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))},
|
||||
{new NettyHeadersAdapter(new DefaultHttpHeaders())},
|
||||
{new TomcatHeadersAdapter(new MimeHeaders())},
|
||||
{new UndertowHeadersAdapter(new HeaderMap())},
|
||||
{new JettyHeadersAdapter(new HttpFields())}
|
||||
};
|
||||
@ParameterizedHeadersTest
|
||||
void getWithUnknownHeaderShouldReturnNull(String displayName, MultiValueMap<String, String> headers) {
|
||||
assertThat(headers.get("Unknown")).isNull();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
this.headers.clear();
|
||||
@ParameterizedHeadersTest
|
||||
void getFirstWithUnknownHeaderShouldReturnNull(String displayName, MultiValueMap<String, String> headers) {
|
||||
assertThat(headers.getFirst("Unknown")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithUnknownHeaderShouldReturnNull() {
|
||||
assertThat(this.headers.get("Unknown")).isNull();
|
||||
@ParameterizedHeadersTest
|
||||
void sizeWithMultipleValuesForHeaderShouldCountHeaders(String displayName, MultiValueMap<String, String> headers) {
|
||||
headers.add("TestHeader", "first");
|
||||
headers.add("TestHeader", "second");
|
||||
assertThat(headers.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFirstWithUnknownHeaderShouldReturnNull() {
|
||||
assertThat(this.headers.getFirst("Unknown")).isNull();
|
||||
@ParameterizedHeadersTest
|
||||
void keySetShouldNotDuplicateHeaderNames(String displayName, MultiValueMap<String, String> headers) {
|
||||
headers.add("TestHeader", "first");
|
||||
headers.add("OtherHeader", "test");
|
||||
headers.add("TestHeader", "second");
|
||||
assertThat(headers.keySet().size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sizeWithMultipleValuesForHeaderShouldCountHeaders() {
|
||||
this.headers.add("TestHeader", "first");
|
||||
this.headers.add("TestHeader", "second");
|
||||
assertThat(this.headers.size()).isEqualTo(1);
|
||||
@ParameterizedHeadersTest
|
||||
void containsKeyShouldBeCaseInsensitive(String displayName, MultiValueMap<String, String> headers) {
|
||||
headers.add("TestHeader", "first");
|
||||
assertThat(headers.containsKey("testheader")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keySetShouldNotDuplicateHeaderNames() {
|
||||
this.headers.add("TestHeader", "first");
|
||||
this.headers.add("OtherHeader", "test");
|
||||
this.headers.add("TestHeader", "second");
|
||||
assertThat(this.headers.keySet().size()).isEqualTo(2);
|
||||
@ParameterizedHeadersTest
|
||||
void addShouldKeepOrdering(String displayName, MultiValueMap<String, String> headers) {
|
||||
headers.add("TestHeader", "first");
|
||||
headers.add("TestHeader", "second");
|
||||
assertThat(headers.getFirst("TestHeader")).isEqualTo("first");
|
||||
assertThat(headers.get("TestHeader").get(0)).isEqualTo("first");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsKeyShouldBeCaseInsensitive() {
|
||||
this.headers.add("TestHeader", "first");
|
||||
assertThat(this.headers.containsKey("testheader")).isTrue();
|
||||
@ParameterizedHeadersTest
|
||||
void putShouldOverrideExisting(String displayName, MultiValueMap<String, String> headers) {
|
||||
headers.add("TestHeader", "first");
|
||||
headers.put("TestHeader", Arrays.asList("override"));
|
||||
assertThat(headers.getFirst("TestHeader")).isEqualTo("override");
|
||||
assertThat(headers.get("TestHeader").size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addShouldKeepOrdering() {
|
||||
this.headers.add("TestHeader", "first");
|
||||
this.headers.add("TestHeader", "second");
|
||||
assertThat(this.headers.getFirst("TestHeader")).isEqualTo("first");
|
||||
assertThat(this.headers.get("TestHeader").get(0)).isEqualTo("first");
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@MethodSource("headers")
|
||||
@interface ParameterizedHeadersTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void putShouldOverrideExisting() {
|
||||
this.headers.add("TestHeader", "first");
|
||||
this.headers.put("TestHeader", Arrays.asList("override"));
|
||||
assertThat(this.headers.getFirst("TestHeader")).isEqualTo("override");
|
||||
assertThat(this.headers.get("TestHeader").size()).isEqualTo(1);
|
||||
static Stream<Arguments> headers() {
|
||||
return Stream.of(
|
||||
arguments("Map", CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))),
|
||||
arguments("Netty", new NettyHeadersAdapter(new DefaultHttpHeaders())),
|
||||
arguments("Tomcat", new TomcatHeadersAdapter(new MimeHeaders())),
|
||||
arguments("Undertow", new UndertowHeadersAdapter(new HeaderMap())),
|
||||
arguments("Jetty", new JettyHeadersAdapter(new HttpFields()))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.http.server.reactive;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ListenerReadPublisherTests {
|
||||
private final TestSubscriber subscriber = new TestSubscriber();
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.publisher.subscribe(this.subscriber);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.io.IOException;
|
||||
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.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ListenerWriteProcessorTests {
|
||||
private final TestSubscription subscription = new TestSubscription();
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.processor.subscribe(this.resultSubscriber);
|
||||
this.processor.onSubscribe(this.subscription);
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.http.server.reactive;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -33,6 +32,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.codec.multipart.FilePart;
|
||||
import org.springframework.http.codec.multipart.FormFieldPart;
|
||||
import org.springframework.http.codec.multipart.Part;
|
||||
import org.springframework.http.server.reactive.bootstrap.HttpServer;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -45,15 +45,17 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected HttpHandler createHttpHandler() {
|
||||
return new HttpWebHandlerAdapter(new CheckRequestHandler());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFormParts() throws Exception {
|
||||
@ParameterizedHttpServerTest
|
||||
void getFormParts(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
RequestEntity<MultiValueMap<String, Object>> request = RequestEntity
|
||||
.post(new URI("http://localhost:" + port + "/form-parts"))
|
||||
@@ -76,7 +78,7 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes
|
||||
}
|
||||
|
||||
|
||||
public static class CheckRequestHandler implements WebHandler {
|
||||
static class CheckRequestHandler implements WebHandler {
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(ServerWebExchange exchange) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.http.server.reactive;
|
||||
import java.net.URI;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -29,6 +28,7 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.reactive.bootstrap.HttpServer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -36,11 +36,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
public static final int REQUEST_SIZE = 4096 * 3;
|
||||
private static final int REQUEST_SIZE = 4096 * 3;
|
||||
|
||||
public static final int RESPONSE_SIZE = 1024 * 4;
|
||||
private static final int RESPONSE_SIZE = 1024 * 4;
|
||||
|
||||
private final Random rnd = new Random();
|
||||
|
||||
@@ -55,8 +55,10 @@ public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegratio
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void random() throws Throwable {
|
||||
@ParameterizedHttpServerTest
|
||||
void random(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
// TODO: fix Reactor support
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
@@ -79,7 +81,7 @@ public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegratio
|
||||
|
||||
private class RandomHandler implements HttpHandler {
|
||||
|
||||
public static final int CHUNKS = 16;
|
||||
static final int CHUNKS = 16;
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user