Merge branch '5.3.x'
# Conflicts: # spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java # spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java # spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java # spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java # spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java # spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java # spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java # spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java
This commit is contained in:
commit
9764f0e59b
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||||
class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void byteCountsAndPositions(String displayName, DataBufferFactory bufferFactory) {
|
void byteCountsAndPositions(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(2);
|
DataBuffer buffer = createDataBuffer(2);
|
||||||
|
|
@ -78,7 +78,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readPositionSmallerThanZero(String displayName, DataBufferFactory bufferFactory) {
|
void readPositionSmallerThanZero(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -92,7 +92,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readPositionGreaterThanWritePosition(String displayName, DataBufferFactory bufferFactory) {
|
void readPositionGreaterThanWritePosition(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -106,7 +106,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writePositionSmallerThanReadPosition(String displayName, DataBufferFactory bufferFactory) {
|
void writePositionSmallerThanReadPosition(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(2);
|
DataBuffer buffer = createDataBuffer(2);
|
||||||
|
|
@ -122,7 +122,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writePositionGreaterThanCapacity(String displayName, DataBufferFactory bufferFactory) {
|
void writePositionGreaterThanCapacity(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -136,7 +136,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeAndRead(String displayName, DataBufferFactory bufferFactory) {
|
void writeAndRead(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(5);
|
DataBuffer buffer = createDataBuffer(5);
|
||||||
|
|
@ -157,7 +157,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeNullString(String displayName, DataBufferFactory bufferFactory) {
|
void writeNullString(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -171,7 +171,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeNullCharset(String displayName, DataBufferFactory bufferFactory) {
|
void writeNullCharset(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -185,7 +185,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeEmptyString(String displayName, DataBufferFactory bufferFactory) {
|
void writeEmptyString(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -197,7 +197,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeUtf8String(String displayName, DataBufferFactory bufferFactory) {
|
void writeUtf8String(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(6);
|
DataBuffer buffer = createDataBuffer(6);
|
||||||
|
|
@ -211,7 +211,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeUtf8StringOutGrowsCapacity(String displayName, DataBufferFactory bufferFactory) {
|
void writeUtf8StringOutGrowsCapacity(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(5);
|
DataBuffer buffer = createDataBuffer(5);
|
||||||
|
|
@ -225,7 +225,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeIsoString(String displayName, DataBufferFactory bufferFactory) {
|
void writeIsoString(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(3);
|
DataBuffer buffer = createDataBuffer(3);
|
||||||
|
|
@ -239,7 +239,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeMultipleUtf8String(String displayName, DataBufferFactory bufferFactory) {
|
void writeMultipleUtf8String(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -261,7 +261,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void toStringNullCharset(String displayName, DataBufferFactory bufferFactory) {
|
void toStringNullCharset(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -275,7 +275,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void toStringUtf8(String displayName, DataBufferFactory bufferFactory) {
|
void toStringUtf8(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
String spring = "Spring";
|
String spring = "Spring";
|
||||||
|
|
@ -290,7 +290,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void toStringSection(String displayName, DataBufferFactory bufferFactory) {
|
void toStringSection(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
String spring = "Spring";
|
String spring = "Spring";
|
||||||
|
|
@ -305,7 +305,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void inputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void inputStream(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(4);
|
DataBuffer buffer = createDataBuffer(4);
|
||||||
|
|
@ -339,7 +339,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void inputStreamReleaseOnClose(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void inputStreamReleaseOnClose(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(3);
|
DataBuffer buffer = createDataBuffer(3);
|
||||||
|
|
@ -357,7 +357,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void outputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void outputStream(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(4);
|
DataBuffer buffer = createDataBuffer(4);
|
||||||
|
|
@ -377,7 +377,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void expand(String displayName, DataBufferFactory bufferFactory) {
|
void expand(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -391,7 +391,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void increaseCapacity(String displayName, DataBufferFactory bufferFactory) {
|
void increaseCapacity(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -404,7 +404,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void decreaseCapacityLowReadPosition(String displayName, DataBufferFactory bufferFactory) {
|
void decreaseCapacityLowReadPosition(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(2);
|
DataBuffer buffer = createDataBuffer(2);
|
||||||
|
|
@ -416,7 +416,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void decreaseCapacityHighReadPosition(String displayName, DataBufferFactory bufferFactory) {
|
void decreaseCapacityHighReadPosition(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(2);
|
DataBuffer buffer = createDataBuffer(2);
|
||||||
|
|
@ -429,7 +429,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void capacityLessThanZero(String displayName, DataBufferFactory bufferFactory) {
|
void capacityLessThanZero(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -443,7 +443,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeByteBuffer(String displayName, DataBufferFactory bufferFactory) {
|
void writeByteBuffer(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer1 = createDataBuffer(1);
|
DataBuffer buffer1 = createDataBuffer(1);
|
||||||
|
|
@ -472,7 +472,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeDataBuffer(String displayName, DataBufferFactory bufferFactory) {
|
void writeDataBuffer(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer1 = createDataBuffer(1);
|
DataBuffer buffer1 = createDataBuffer(1);
|
||||||
|
|
@ -495,7 +495,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void asByteBuffer(String displayName, DataBufferFactory bufferFactory) {
|
void asByteBuffer(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(4);
|
DataBuffer buffer = createDataBuffer(4);
|
||||||
|
|
@ -516,7 +516,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void asByteBufferIndexLength(String displayName, DataBufferFactory bufferFactory) {
|
void asByteBufferIndexLength(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(3);
|
DataBuffer buffer = createDataBuffer(3);
|
||||||
|
|
@ -536,7 +536,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void byteBufferContainsDataBufferChanges(String displayName, DataBufferFactory bufferFactory) {
|
void byteBufferContainsDataBufferChanges(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer dataBuffer = createDataBuffer(1);
|
DataBuffer dataBuffer = createDataBuffer(1);
|
||||||
|
|
@ -552,7 +552,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void dataBufferContainsByteBufferChanges(String displayName, DataBufferFactory bufferFactory) {
|
void dataBufferContainsByteBufferChanges(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer dataBuffer = createDataBuffer(1);
|
DataBuffer dataBuffer = createDataBuffer(1);
|
||||||
|
|
@ -568,7 +568,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void emptyAsByteBuffer(String displayName, DataBufferFactory bufferFactory) {
|
void emptyAsByteBuffer(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(1);
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
|
@ -580,7 +580,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void indexOf(String displayName, DataBufferFactory bufferFactory) {
|
void indexOf(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(3);
|
DataBuffer buffer = createDataBuffer(3);
|
||||||
|
|
@ -602,7 +602,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void lastIndexOf(String displayName, DataBufferFactory bufferFactory) {
|
void lastIndexOf(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(3);
|
DataBuffer buffer = createDataBuffer(3);
|
||||||
|
|
@ -633,7 +633,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void slice(String displayName, DataBufferFactory bufferFactory) {
|
void slice(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(3);
|
DataBuffer buffer = createDataBuffer(3);
|
||||||
|
|
@ -662,7 +662,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void retainedSlice(String displayName, DataBufferFactory bufferFactory) {
|
void retainedSlice(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(3);
|
DataBuffer buffer = createDataBuffer(3);
|
||||||
|
|
@ -691,7 +691,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void spr16351(String displayName, DataBufferFactory bufferFactory) {
|
void spr16351(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = createDataBuffer(6);
|
DataBuffer buffer = createDataBuffer(6);
|
||||||
|
|
@ -711,7 +711,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void join(String displayName, DataBufferFactory bufferFactory) {
|
void join(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer composite = this.bufferFactory.join(Arrays.asList(stringBuffer("a"),
|
DataBuffer composite = this.bufferFactory.join(Arrays.asList(stringBuffer("a"),
|
||||||
|
|
@ -726,7 +726,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void getByte(String displayName, DataBufferFactory bufferFactory) {
|
void getByte(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = stringBuffer("abc");
|
DataBuffer buffer = stringBuffer("abc");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -76,7 +76,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
|
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readInputStream(String displayName, DataBufferFactory bufferFactory) {
|
void readInputStream(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> flux = DataBufferUtils.readInputStream(
|
Flux<DataBuffer> flux = DataBufferUtils.readInputStream(
|
||||||
|
|
@ -86,7 +86,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readByteChannel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
URI uri = this.resource.getURI();
|
URI uri = this.resource.getURI();
|
||||||
|
|
@ -98,7 +98,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readByteChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readByteChannelError(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
ReadableByteChannel channel = mock(ReadableByteChannel.class);
|
ReadableByteChannel channel = mock(ReadableByteChannel.class);
|
||||||
|
|
@ -121,7 +121,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readByteChannelCancel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
URI uri = this.resource.getURI();
|
URI uri = this.resource.getURI();
|
||||||
|
|
@ -136,7 +136,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readAsynchronousFileChannel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
URI uri = this.resource.getURI();
|
URI uri = this.resource.getURI();
|
||||||
|
|
@ -148,7 +148,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readAsynchronousFileChannelPosition(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readAsynchronousFileChannelPosition(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
URI uri = this.resource.getURI();
|
URI uri = this.resource.getURI();
|
||||||
|
|
@ -163,7 +163,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readAsynchronousFileChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readAsynchronousFileChannelError(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
AsynchronousFileChannel channel = mock(AsynchronousFileChannel.class);
|
AsynchronousFileChannel channel = mock(AsynchronousFileChannel.class);
|
||||||
|
|
@ -195,7 +195,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readAsynchronousFileChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readAsynchronousFileChannelCancel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
URI uri = this.resource.getURI();
|
URI uri = this.resource.getURI();
|
||||||
|
|
@ -210,7 +210,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest // gh-22107
|
@ParameterizedDataBufferAllocatingTest // gh-22107
|
||||||
void readAsynchronousFileChannelCancelWithoutDemand(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readAsynchronousFileChannelCancelWithoutDemand(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
URI uri = this.resource.getURI();
|
URI uri = this.resource.getURI();
|
||||||
|
|
@ -224,7 +224,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readPath(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readPath(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource.getFile().toPath(), super.bufferFactory, 3);
|
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource.getFile().toPath(), super.bufferFactory, 3);
|
||||||
|
|
@ -233,7 +233,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readResource(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readResource(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource, super.bufferFactory, 3);
|
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource, super.bufferFactory, 3);
|
||||||
|
|
@ -242,7 +242,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readResourcePosition(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readResourcePosition(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource, 9, super.bufferFactory, 3);
|
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource, 9, super.bufferFactory, 3);
|
||||||
|
|
@ -264,7 +264,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readResourcePositionAndTakeUntil(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Resource resource = new ClassPathResource("DataBufferUtilsTests.txt", getClass());
|
Resource resource = new ClassPathResource("DataBufferUtilsTests.txt", getClass());
|
||||||
|
|
@ -281,7 +281,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readByteArrayResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readByteArrayResourcePositionAndTakeUntil(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Resource resource = new ByteArrayResource("foobarbazqux" .getBytes());
|
Resource resource = new ByteArrayResource("foobarbazqux" .getBytes());
|
||||||
|
|
@ -298,7 +298,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeOutputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeOutputStream(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -315,7 +315,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeWritableByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeWritableByteChannel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -332,7 +332,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeWritableByteChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeWritableByteChannelErrorInFlux(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -355,7 +355,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeWritableByteChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeWritableByteChannelErrorInWrite(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -383,7 +383,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeWritableByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeWritableByteChannelCancel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -407,7 +407,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeAsynchronousFileChannel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -439,7 +439,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeAsynchronousFileChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeAsynchronousFileChannelErrorInFlux(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -465,7 +465,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
void writeAsynchronousFileChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeAsynchronousFileChannelErrorInWrite(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -506,7 +506,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeAsynchronousFileChannelCanceled(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writeAsynchronousFileChannelCanceled(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -531,7 +531,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writePath(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void writePath(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -548,7 +548,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readAndWriteByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readAndWriteByteChannel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Path source = Paths.get(
|
Path source = Paths.get(
|
||||||
|
|
@ -582,7 +582,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void readAndWriteAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void readAndWriteAsynchronousFileChannel(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Path source = Paths.get(
|
Path source = Paths.get(
|
||||||
|
|
@ -623,7 +623,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void takeUntilByteCount(String displayName, DataBufferFactory bufferFactory) {
|
void takeUntilByteCount(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> result = DataBufferUtils.takeUntilByteCount(
|
Flux<DataBuffer> result = DataBufferUtils.takeUntilByteCount(
|
||||||
|
|
@ -637,7 +637,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void takeUntilByteCountCanceled(String displayName, DataBufferFactory bufferFactory) {
|
void takeUntilByteCountCanceled(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> source = Flux.concat(
|
Flux<DataBuffer> source = Flux.concat(
|
||||||
|
|
@ -654,7 +654,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void takeUntilByteCountError(String displayName, DataBufferFactory bufferFactory) {
|
void takeUntilByteCountError(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> source = Flux.concat(
|
Flux<DataBuffer> source = Flux.concat(
|
||||||
|
|
@ -671,7 +671,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void takeUntilByteCountExact(String displayName, DataBufferFactory bufferFactory) {
|
void takeUntilByteCountExact(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> source = Flux.concat(
|
Flux<DataBuffer> source = Flux.concat(
|
||||||
|
|
@ -690,7 +690,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void skipUntilByteCount(String displayName, DataBufferFactory bufferFactory) {
|
void skipUntilByteCount(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> source = Flux.concat(
|
Flux<DataBuffer> source = Flux.concat(
|
||||||
|
|
@ -708,7 +708,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void skipUntilByteCountCancelled(String displayName, DataBufferFactory bufferFactory) {
|
void skipUntilByteCountCancelled(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> source = Flux.concat(
|
Flux<DataBuffer> source = Flux.concat(
|
||||||
|
|
@ -724,7 +724,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void skipUntilByteCountErrorInFlux(String displayName, DataBufferFactory bufferFactory) {
|
void skipUntilByteCountErrorInFlux(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -738,7 +738,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void skipUntilByteCountShouldSkipAll(String displayName, DataBufferFactory bufferFactory) {
|
void skipUntilByteCountShouldSkipAll(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -753,7 +753,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void releaseConsumer(String displayName, DataBufferFactory bufferFactory) {
|
void releaseConsumer(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -776,7 +776,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void SPR16070(String displayName, DataBufferFactory bufferFactory) throws Exception {
|
void SPR16070(DataBufferFactory bufferFactory) throws Exception {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
ReadableByteChannel channel = mock(ReadableByteChannel.class);
|
ReadableByteChannel channel = mock(ReadableByteChannel.class);
|
||||||
|
|
@ -807,7 +807,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void join(String displayName, DataBufferFactory bufferFactory) {
|
void join(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -825,7 +825,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void joinWithLimit(String displayName, DataBufferFactory bufferFactory) {
|
void joinWithLimit(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -855,7 +855,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void joinErrors(String displayName, DataBufferFactory bufferFactory) {
|
void joinErrors(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -869,7 +869,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void joinCanceled(String displayName, DataBufferFactory bufferFactory) {
|
void joinCanceled(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
Flux<DataBuffer> source = Flux.concat(
|
Flux<DataBuffer> source = Flux.concat(
|
||||||
|
|
@ -885,7 +885,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void matcher(String displayName, DataBufferFactory bufferFactory) {
|
void matcher(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foo");
|
DataBuffer foo = stringBuffer("foo");
|
||||||
|
|
@ -903,7 +903,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void matcher2(String displayName, DataBufferFactory bufferFactory) {
|
void matcher2(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foooobar");
|
DataBuffer foo = stringBuffer("foooobar");
|
||||||
|
|
@ -923,7 +923,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void matcher3(String displayName, DataBufferFactory bufferFactory) {
|
void matcher3(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer foo = stringBuffer("foooobar");
|
DataBuffer foo = stringBuffer("foooobar");
|
||||||
|
|
@ -943,7 +943,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void propagateContextByteChannel(String displayName, DataBufferFactory bufferFactory) throws IOException {
|
void propagateContextByteChannel(DataBufferFactory bufferFactory) throws IOException {
|
||||||
Path path = Paths.get(this.resource.getURI());
|
Path path = Paths.get(this.resource.getURI());
|
||||||
try (SeekableByteChannel out = Files.newByteChannel(this.tempFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
try (SeekableByteChannel out = Files.newByteChannel(this.tempFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
||||||
Flux<DataBuffer> result = DataBufferUtils.read(path, bufferFactory, 1024, StandardOpenOption.READ)
|
Flux<DataBuffer> result = DataBufferUtils.read(path, bufferFactory, 1024, StandardOpenOption.READ)
|
||||||
|
|
@ -967,7 +967,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void propagateContextAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws IOException {
|
void propagateContextAsynchronousFileChannel(DataBufferFactory bufferFactory) throws IOException {
|
||||||
Path path = Paths.get(this.resource.getURI());
|
Path path = Paths.get(this.resource.getURI());
|
||||||
try (AsynchronousFileChannel out = AsynchronousFileChannel.open(this.tempFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
try (AsynchronousFileChannel out = AsynchronousFileChannel.open(this.tempFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
||||||
Flux<DataBuffer> result = DataBufferUtils.read(path, bufferFactory, 1024, StandardOpenOption.READ)
|
Flux<DataBuffer> result = DataBufferUtils.read(path, bufferFactory, 1024, StandardOpenOption.READ)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
class DataBufferTestUtilsTests extends AbstractDataBufferAllocatingTests {
|
class DataBufferTestUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void dumpBytes(String displayName, DataBufferFactory bufferFactory) {
|
void dumpBytes(DataBufferFactory bufferFactory) {
|
||||||
this.bufferFactory = bufferFactory;
|
this.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = this.bufferFactory.allocateBuffer(4);
|
DataBuffer buffer = this.bufferFactory.allocateBuffer(4);
|
||||||
|
|
@ -47,7 +47,7 @@ class DataBufferTestUtilsTests extends AbstractDataBufferAllocatingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void dumpString(String displayName, DataBufferFactory bufferFactory) {
|
void dumpString(DataBufferFactory bufferFactory) {
|
||||||
this.bufferFactory = bufferFactory;
|
this.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
DataBuffer buffer = this.bufferFactory.allocateBuffer(4);
|
DataBuffer buffer = this.bufferFactory.allocateBuffer(4);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -49,6 +49,7 @@ import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -161,20 +162,20 @@ public abstract class AbstractDataBufferAllocatingTests {
|
||||||
@SuppressWarnings("deprecation") // PooledByteBufAllocator no longer supports tinyCacheSize.
|
@SuppressWarnings("deprecation") // PooledByteBufAllocator no longer supports tinyCacheSize.
|
||||||
public static Stream<Arguments> dataBufferFactories() {
|
public static Stream<Arguments> dataBufferFactories() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments("NettyDataBufferFactory - UnpooledByteBufAllocator - preferDirect = true",
|
arguments(named("NettyDataBufferFactory - UnpooledByteBufAllocator - preferDirect = true",
|
||||||
new NettyDataBufferFactory(new UnpooledByteBufAllocator(true))),
|
new NettyDataBufferFactory(new UnpooledByteBufAllocator(true)))),
|
||||||
arguments("NettyDataBufferFactory - UnpooledByteBufAllocator - preferDirect = false",
|
arguments(named("NettyDataBufferFactory - UnpooledByteBufAllocator - preferDirect = false",
|
||||||
new NettyDataBufferFactory(new UnpooledByteBufAllocator(false))),
|
new NettyDataBufferFactory(new UnpooledByteBufAllocator(false)))),
|
||||||
// 1) Disable caching for reliable leak detection, see https://github.com/netty/netty/issues/5275
|
// 1) Disable caching for reliable leak detection, see https://github.com/netty/netty/issues/5275
|
||||||
// 2) maxOrder is 4 (vs default 11) but can be increased if necessary
|
// 2) maxOrder is 4 (vs default 11) but can be increased if necessary
|
||||||
arguments("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = true",
|
arguments(named("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = true",
|
||||||
new NettyDataBufferFactory(new PooledByteBufAllocator(true, 1, 1, 4096, 4, 0, 0, 0, true))),
|
new NettyDataBufferFactory(new PooledByteBufAllocator(true, 1, 1, 4096, 4, 0, 0, 0, true)))),
|
||||||
arguments("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = false",
|
arguments(named("NettyDataBufferFactory - PooledByteBufAllocator - preferDirect = false",
|
||||||
new NettyDataBufferFactory(new PooledByteBufAllocator(false, 1, 1, 4096, 4, 0, 0, 0, true))),
|
new NettyDataBufferFactory(new PooledByteBufAllocator(false, 1, 1, 4096, 4, 0, 0, 0, true)))),
|
||||||
arguments("DefaultDataBufferFactory - preferDirect = true",
|
arguments(named("DefaultDataBufferFactory - preferDirect = true",
|
||||||
new DefaultDataBufferFactory(true)),
|
new DefaultDataBufferFactory(true))),
|
||||||
arguments("DefaultDataBufferFactory - preferDirect = false",
|
arguments(named("DefaultDataBufferFactory - preferDirect = false",
|
||||||
new DefaultDataBufferFactory(false))
|
new DefaultDataBufferFactory(false)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ package org.springframework.mock.http.server.reactive;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.function.Executable;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
|
|
@ -31,6 +31,8 @@ import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link MockServerHttpRequest}.
|
* Unit tests for {@link MockServerHttpRequest}.
|
||||||
|
|
@ -63,22 +65,23 @@ class MockServerHttpRequestTests {
|
||||||
assertThat(request.getURI().toString()).isEqualTo("/foo%20bar?a=b&name%20A=value%20A1&name%20A=value%20A2&name%20B=value%20B1");
|
assertThat(request.getURI().toString()).isEqualTo("/foo%20bar?a=b&name%20A=value%20A1&name%20A=value%20A2&name%20B=value%20B1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest(name = "[{index}] {0}")
|
||||||
@MethodSource
|
@MethodSource
|
||||||
void httpMethodNotNullOrEmpty(Executable executable) {
|
void httpMethodNotNullOrEmpty(ThrowingCallable callable) {
|
||||||
Exception ex = Assertions.assertThrows(IllegalArgumentException.class, executable);
|
assertThatIllegalArgumentException()
|
||||||
assertThat(ex.getMessage()).contains("HTTP method is required.");
|
.isThrownBy(callable)
|
||||||
|
.withMessageContaining("HTTP method is required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static Stream<Executable> httpMethodNotNullOrEmpty() {
|
static Stream<Named<ThrowingCallable>> httpMethodNotNullOrEmpty() {
|
||||||
String uriTemplate = "/foo bar?a=b";
|
String uriTemplate = "/foo bar?a=b";
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
() -> MockServerHttpRequest.method(null, UriComponentsBuilder.fromUriString(uriTemplate).build("")).build(),
|
named("null HttpMethod, URI", () -> MockServerHttpRequest.method(null, UriComponentsBuilder.fromUriString(uriTemplate).build("")).build()),
|
||||||
() -> MockServerHttpRequest.method((HttpMethod) null, uriTemplate).build(),
|
named("null HttpMethod, uriTemplate", () -> MockServerHttpRequest.method((HttpMethod) null, uriTemplate).build()),
|
||||||
() -> MockServerHttpRequest.method((String) null, uriTemplate).build(),
|
named("null String, uriTemplate", () -> MockServerHttpRequest.method((String) null, uriTemplate).build()),
|
||||||
() -> MockServerHttpRequest.method("", uriTemplate).build(),
|
named("empty String, uriTemplate", () -> MockServerHttpRequest.method("", uriTemplate).build()),
|
||||||
() -> MockServerHttpRequest.method(" ", uriTemplate).build()
|
named("blank String, uriTemplate", () -> MockServerHttpRequest.method(" ", uriTemplate).build())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ import org.springframework.test.context.web.WebTestContextBootstrapper;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper;
|
import static org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper;
|
||||||
|
|
@ -104,9 +105,9 @@ class BootstrapUtilsTests {
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
@ParameterizedTest(name = "{0}")
|
@ParameterizedTest(name = "[{index}] {0}")
|
||||||
@MethodSource
|
@MethodSource
|
||||||
void resolveTestContextBootstrapperInEnclosingClassHierarchy(String name, Class<?> testClass, Class<?> expectedBootstrapper) {
|
void resolveTestContextBootstrapperInEnclosingClassHierarchy(Class<?> testClass, Class<?> expectedBootstrapper) {
|
||||||
assertBootstrapper(testClass, expectedBootstrapper);
|
assertBootstrapper(testClass, expectedBootstrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,7 +130,7 @@ class BootstrapUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Arguments args(Class<?> testClass, Class<? extends TestContextBootstrapper> expectedBootstrapper) {
|
private static Arguments args(Class<?> testClass, Class<? extends TestContextBootstrapper> expectedBootstrapper) {
|
||||||
return arguments(testClass.getSimpleName(), testClass, expectedBootstrapper);
|
return arguments(named(testClass.getSimpleName(), testClass), expectedBootstrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,10 +27,10 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.ContextLoader;
|
import org.springframework.test.context.ContextLoader;
|
||||||
import org.springframework.util.ClassUtils;
|
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,13 +53,11 @@ class GenericXmlContextLoaderResourceLocationsTests {
|
||||||
|
|
||||||
@ParameterizedTest(name = "[{index}] {0}")
|
@ParameterizedTest(name = "[{index}] {0}")
|
||||||
@MethodSource("contextConfigurationLocationsData")
|
@MethodSource("contextConfigurationLocationsData")
|
||||||
void assertContextConfigurationLocations(String testClassName, String[] expectedLocations) throws Exception {
|
void assertContextConfigurationLocations(Class<?> testClass, String[] expectedLocations) throws Exception {
|
||||||
Class<?> testClass = ClassUtils.forName(getClass().getName() + "$" + testClassName, getClass().getClassLoader());
|
ContextConfiguration contextConfig = testClass.getAnnotation(ContextConfiguration.class);
|
||||||
|
ContextLoader contextLoader = new GenericXmlContextLoader();
|
||||||
final ContextConfiguration contextConfig = testClass.getAnnotation(ContextConfiguration.class);
|
String[] configuredLocations = (String[]) AnnotationUtils.getValue(contextConfig);
|
||||||
final ContextLoader contextLoader = new GenericXmlContextLoader();
|
String[] processedLocations = contextLoader.processLocations(testClass, configuredLocations);
|
||||||
final String[] configuredLocations = (String[]) AnnotationUtils.getValue(contextConfig);
|
|
||||||
final String[] processedLocations = contextLoader.processLocations(testClass, configuredLocations);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("----------------------------------------------------------------------");
|
logger.debug("----------------------------------------------------------------------");
|
||||||
|
|
@ -73,29 +71,32 @@ class GenericXmlContextLoaderResourceLocationsTests {
|
||||||
|
|
||||||
static Stream<Arguments> contextConfigurationLocationsData() {
|
static Stream<Arguments> contextConfigurationLocationsData() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments(ClasspathNonExistentDefaultLocationsTestCase.class.getSimpleName(), array()),
|
args(ClasspathNonExistentDefaultLocationsTestCase.class, array()),
|
||||||
|
|
||||||
arguments(ClasspathExistentDefaultLocationsTestCase.class.getSimpleName(), array(
|
args(ClasspathExistentDefaultLocationsTestCase.class, array(
|
||||||
"classpath:org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$ClasspathExistentDefaultLocationsTestCase-context.xml")),
|
"classpath:org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$ClasspathExistentDefaultLocationsTestCase-context.xml")),
|
||||||
|
|
||||||
arguments(ImplicitClasspathLocationsTestCase.class.getSimpleName(),
|
args(ImplicitClasspathLocationsTestCase.class,
|
||||||
array("classpath:/org/springframework/test/context/support/context1.xml",
|
array("classpath:/org/springframework/test/context/support/context1.xml",
|
||||||
"classpath:/org/springframework/test/context/support/context2.xml")),
|
"classpath:/org/springframework/test/context/support/context2.xml")),
|
||||||
|
|
||||||
arguments(ExplicitClasspathLocationsTestCase.class.getSimpleName(), array("classpath:context.xml")),
|
args(ExplicitClasspathLocationsTestCase.class, array("classpath:context.xml")),
|
||||||
|
|
||||||
arguments(ExplicitFileLocationsTestCase.class.getSimpleName(),
|
args(ExplicitFileLocationsTestCase.class, array("file:/testing/directory/context.xml")),
|
||||||
array("file:/testing/directory/context.xml")),
|
|
||||||
|
|
||||||
arguments(ExplicitUrlLocationsTestCase.class.getSimpleName(), array("https://example.com/context.xml")),
|
args(ExplicitUrlLocationsTestCase.class, array("https://example.com/context.xml")),
|
||||||
|
|
||||||
arguments(ExplicitMixedPathTypesLocationsTestCase.class.getSimpleName(),
|
args(ExplicitMixedPathTypesLocationsTestCase.class,
|
||||||
array("classpath:/org/springframework/test/context/support/context1.xml", "classpath:context2.xml",
|
array("classpath:/org/springframework/test/context/support/context1.xml", "classpath:context2.xml",
|
||||||
"classpath:/context3.xml", "file:/testing/directory/context.xml",
|
"classpath:/context3.xml", "file:/testing/directory/context.xml",
|
||||||
"https://example.com/context.xml"))
|
"https://example.com/context.xml"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Arguments args(Class<?> testClass, String[] expectedLocations) {
|
||||||
|
return arguments(named(testClass.getSimpleName(), testClass), expectedLocations);
|
||||||
|
}
|
||||||
|
|
||||||
private static String[] array(String... elements) {
|
private static String[] array(String... elements) {
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -37,6 +37,7 @@ import okhttp3.mockwebserver.RecordedRequest;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
@ -54,6 +55,7 @@ import org.springframework.lang.NonNull;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.fail;
|
import static org.assertj.core.api.Assertions.fail;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
|
|
@ -202,22 +204,22 @@ public class ClientHttpConnectorTests {
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
// Do not auto-close arguments since HttpComponentsClientHttpConnector implements
|
// Do not auto-close arguments since HttpComponentsClientHttpConnector implements
|
||||||
// AutoCloseable and is shared between parameterized test invocations.
|
// AutoCloseable and is shared between parameterized test invocations.
|
||||||
@ParameterizedTest(autoCloseArguments = false)
|
@ParameterizedTest(name = "{0}", autoCloseArguments = false)
|
||||||
@MethodSource("org.springframework.http.client.reactive.ClientHttpConnectorTests#connectors")
|
@MethodSource("org.springframework.http.client.reactive.ClientHttpConnectorTests#connectors")
|
||||||
public @interface ParameterizedConnectorTest {
|
public @interface ParameterizedConnectorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<ClientHttpConnector> connectors() {
|
static List<Named<ClientHttpConnector>> connectors() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new ReactorClientHttpConnector(),
|
named("Reactor Netty", new ReactorClientHttpConnector()),
|
||||||
new JettyClientHttpConnector(),
|
named("Jetty", new JettyClientHttpConnector()),
|
||||||
new HttpComponentsClientHttpConnector()
|
named("HttpComponents", new HttpComponentsClientHttpConnector())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<Arguments> methodsWithConnectors() {
|
static List<Arguments> methodsWithConnectors() {
|
||||||
List<Arguments> result = new ArrayList<>();
|
List<Arguments> result = new ArrayList<>();
|
||||||
for (ClientHttpConnector connector : connectors()) {
|
for (Named<ClientHttpConnector> connector : connectors()) {
|
||||||
for (HttpMethod method : HttpMethod.values()) {
|
for (HttpMethod method : HttpMethod.values()) {
|
||||||
result.add(Arguments.of(connector, method));
|
result.add(Arguments.of(connector, method));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -58,7 +58,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
|
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void canWrite(String displayName, DataBufferFactory bufferFactory) {
|
void canWrite(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
assertThat(this.messageWriter.canWrite(forClass(Object.class), null)).isTrue();
|
assertThat(this.messageWriter.canWrite(forClass(Object.class), null)).isTrue();
|
||||||
|
|
@ -73,7 +73,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeServerSentEvent(String displayName, DataBufferFactory bufferFactory) {
|
void writeServerSentEvent(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
ServerSentEvent<?> event = ServerSentEvent.builder().data("bar").id("c42").event("foo")
|
ServerSentEvent<?> event = ServerSentEvent.builder().data("bar").id("c42").event("foo")
|
||||||
|
|
@ -91,7 +91,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeString(String displayName, DataBufferFactory bufferFactory) {
|
void writeString(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||||
|
|
@ -106,7 +106,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writeMultiLineString(String displayName, DataBufferFactory bufferFactory) {
|
void writeMultiLineString(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||||
|
|
@ -121,7 +121,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest // SPR-16516
|
@ParameterizedDataBufferAllocatingTest // SPR-16516
|
||||||
void writeStringWithCustomCharset(String displayName, DataBufferFactory bufferFactory) {
|
void writeStringWithCustomCharset(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||||
|
|
@ -142,7 +142,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void writePojo(String displayName, DataBufferFactory bufferFactory) {
|
void writePojo(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||||
|
|
@ -161,7 +161,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest // SPR-14899
|
@ParameterizedDataBufferAllocatingTest // SPR-14899
|
||||||
void writePojoWithPrettyPrint(String displayName, DataBufferFactory bufferFactory) {
|
void writePojoWithPrettyPrint(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().indentOutput(true).build();
|
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().indentOutput(true).build();
|
||||||
|
|
@ -187,7 +187,7 @@ class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocating
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest // SPR-16516, SPR-16539
|
@ParameterizedDataBufferAllocatingTest // SPR-16516, SPR-16539
|
||||||
void writePojoWithCustomEncoding(String displayName, DataBufferFactory bufferFactory) {
|
void writePojoWithCustomEncoding(DataBufferFactory bufferFactory) {
|
||||||
super.bufferFactory = bufferFactory;
|
super.bufferFactory = bufferFactory;
|
||||||
|
|
||||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -55,6 +55,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
import static org.springframework.core.ResolvableType.forClass;
|
import static org.springframework.core.ResolvableType.forClass;
|
||||||
import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
||||||
|
|
@ -62,7 +63,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
public class DefaultPartHttpMessageReaderTests {
|
class DefaultPartHttpMessageReaderTests {
|
||||||
|
|
||||||
private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer iaculis metus id vestibulum nullam.";
|
private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer iaculis metus id vestibulum nullam.";
|
||||||
|
|
||||||
|
|
@ -73,12 +74,12 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
private static final DataBufferFactory bufferFactory = new NettyDataBufferFactory(new PooledByteBufAllocator());
|
private static final DataBufferFactory bufferFactory = new NettyDataBufferFactory(new PooledByteBufAllocator());
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void canRead(String displayName, DefaultPartHttpMessageReader reader) {
|
void canRead(DefaultPartHttpMessageReader reader) {
|
||||||
assertThat(reader.canRead(forClass(Part.class), MediaType.MULTIPART_FORM_DATA)).isTrue();
|
assertThat(reader.canRead(forClass(Part.class), MediaType.MULTIPART_FORM_DATA)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void simple(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
|
void simple(DefaultPartHttpMessageReader reader) throws InterruptedException {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
||||||
|
|
||||||
|
|
@ -96,7 +97,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void noHeaders(String displayName, DefaultPartHttpMessageReader reader) {
|
void noHeaders(DefaultPartHttpMessageReader reader) {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("no-header.multipart", getClass()), "boundary");
|
new ClassPathResource("no-header.multipart", getClass()), "boundary");
|
||||||
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
||||||
|
|
@ -110,7 +111,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void noEndBoundary(String displayName, DefaultPartHttpMessageReader reader) {
|
void noEndBoundary(DefaultPartHttpMessageReader reader) {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("no-end-boundary.multipart", getClass()), "boundary");
|
new ClassPathResource("no-end-boundary.multipart", getClass()), "boundary");
|
||||||
|
|
||||||
|
|
@ -122,7 +123,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void garbage(String displayName, DefaultPartHttpMessageReader reader) {
|
void garbage(DefaultPartHttpMessageReader reader) {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("garbage-1.multipart", getClass()), "boundary");
|
new ClassPathResource("garbage-1.multipart", getClass()), "boundary");
|
||||||
|
|
||||||
|
|
@ -134,7 +135,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void noEndHeader(String displayName, DefaultPartHttpMessageReader reader) {
|
void noEndHeader(DefaultPartHttpMessageReader reader) {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("no-end-header.multipart", getClass()), "boundary");
|
new ClassPathResource("no-end-header.multipart", getClass()), "boundary");
|
||||||
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
||||||
|
|
@ -145,7 +146,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void noEndBody(String displayName, DefaultPartHttpMessageReader reader) {
|
void noEndBody(DefaultPartHttpMessageReader reader) {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("no-end-body.multipart", getClass()), "boundary");
|
new ClassPathResource("no-end-body.multipart", getClass()), "boundary");
|
||||||
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
||||||
|
|
@ -156,7 +157,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void cancelPart(String displayName, DefaultPartHttpMessageReader reader) {
|
void cancelPart(DefaultPartHttpMessageReader reader) {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
||||||
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
||||||
|
|
@ -168,7 +169,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void cancelBody(String displayName, DefaultPartHttpMessageReader reader) throws Exception {
|
void cancelBody(DefaultPartHttpMessageReader reader) throws Exception {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
||||||
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
||||||
|
|
@ -185,7 +186,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void cancelBodyThenPart(String displayName, DefaultPartHttpMessageReader reader) {
|
void cancelBodyThenPart(DefaultPartHttpMessageReader reader) {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
||||||
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
||||||
|
|
@ -197,25 +198,25 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void firefox(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
|
void firefox(DefaultPartHttpMessageReader reader) throws InterruptedException {
|
||||||
testBrowser(reader, new ClassPathResource("firefox.multipart", getClass()),
|
testBrowser(reader, new ClassPathResource("firefox.multipart", getClass()),
|
||||||
"---------------------------18399284482060392383840973206");
|
"---------------------------18399284482060392383840973206");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void chrome(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
|
void chrome(DefaultPartHttpMessageReader reader) throws InterruptedException {
|
||||||
testBrowser(reader, new ClassPathResource("chrome.multipart", getClass()),
|
testBrowser(reader, new ClassPathResource("chrome.multipart", getClass()),
|
||||||
"----WebKitFormBoundaryEveBLvRT65n21fwU");
|
"----WebKitFormBoundaryEveBLvRT65n21fwU");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void safari(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
|
void safari(DefaultPartHttpMessageReader reader) throws InterruptedException {
|
||||||
testBrowser(reader, new ClassPathResource("safari.multipart", getClass()),
|
testBrowser(reader, new ClassPathResource("safari.multipart", getClass()),
|
||||||
"----WebKitFormBoundaryG8fJ50opQOML0oGD");
|
"----WebKitFormBoundaryG8fJ50opQOML0oGD");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tooManyParts() throws InterruptedException {
|
void tooManyParts() throws InterruptedException {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
||||||
|
|
||||||
|
|
@ -235,7 +236,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void quotedBoundary(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
|
void quotedBoundary(DefaultPartHttpMessageReader reader) throws InterruptedException {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("simple.multipart", getClass()), "\"simple-boundary\"");
|
new ClassPathResource("simple.multipart", getClass()), "\"simple-boundary\"");
|
||||||
|
|
||||||
|
|
@ -253,7 +254,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||||
public void utf8Headers(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
|
void utf8Headers(DefaultPartHttpMessageReader reader) throws InterruptedException {
|
||||||
MockServerHttpRequest request = createRequest(
|
MockServerHttpRequest request = createRequest(
|
||||||
new ClassPathResource("utf8.multipart", getClass()), "\"simple-boundary\"");
|
new ClassPathResource("utf8.multipart", getClass()), "\"simple-boundary\"");
|
||||||
|
|
||||||
|
|
@ -272,7 +273,7 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
|
|
||||||
// gh-27612
|
// gh-27612
|
||||||
@Test
|
@Test
|
||||||
public void exceedHeaderLimit() throws InterruptedException {
|
void exceedHeaderLimit() throws InterruptedException {
|
||||||
Flux<DataBuffer> body = DataBufferUtils
|
Flux<DataBuffer> body = DataBufferUtils
|
||||||
.readByteChannel((new ClassPathResource("files.multipart", getClass()))::readableChannel, bufferFactory, 282);
|
.readByteChannel((new ClassPathResource("files.multipart", getClass()))::readableChannel, bufferFactory, 282);
|
||||||
|
|
||||||
|
|
@ -410,10 +411,10 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@ParameterizedTest(name = "[{index}] {0}")
|
@ParameterizedTest(name = "[{index}] {0}")
|
||||||
@MethodSource("org.springframework.http.codec.multipart.DefaultPartHttpMessageReaderTests#messageReaders()")
|
@MethodSource("org.springframework.http.codec.multipart.DefaultPartHttpMessageReaderTests#messageReaders()")
|
||||||
public @interface ParameterizedDefaultPartHttpMessageReaderTest {
|
@interface ParameterizedDefaultPartHttpMessageReaderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Arguments> messageReaders() {
|
static Stream<Arguments> messageReaders() {
|
||||||
DefaultPartHttpMessageReader streaming = new DefaultPartHttpMessageReader();
|
DefaultPartHttpMessageReader streaming = new DefaultPartHttpMessageReader();
|
||||||
streaming.setStreaming(true);
|
streaming.setStreaming(true);
|
||||||
|
|
||||||
|
|
@ -426,11 +427,9 @@ public class DefaultPartHttpMessageReaderTests {
|
||||||
onDisk.setMaxInMemorySize(100);
|
onDisk.setMaxInMemorySize(100);
|
||||||
|
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments("streaming", streaming),
|
arguments(named("streaming", streaming)),
|
||||||
arguments("in-memory", inMemory),
|
arguments(named("in-memory", inMemory)),
|
||||||
arguments("on-disk", onDisk)
|
arguments(named("on-disk", onDisk)));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -39,6 +39,7 @@ import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,24 +51,24 @@ import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
class HeadersAdaptersTests {
|
class HeadersAdaptersTests {
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void getWithUnknownHeaderShouldReturnNull(String displayName, MultiValueMap<String, String> headers) {
|
void getWithUnknownHeaderShouldReturnNull(MultiValueMap<String, String> headers) {
|
||||||
assertThat(headers.get("Unknown")).isNull();
|
assertThat(headers.get("Unknown")).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void getFirstWithUnknownHeaderShouldReturnNull(String displayName, MultiValueMap<String, String> headers) {
|
void getFirstWithUnknownHeaderShouldReturnNull(MultiValueMap<String, String> headers) {
|
||||||
assertThat(headers.getFirst("Unknown")).isNull();
|
assertThat(headers.getFirst("Unknown")).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void sizeWithMultipleValuesForHeaderShouldCountHeaders(String displayName, MultiValueMap<String, String> headers) {
|
void sizeWithMultipleValuesForHeaderShouldCountHeaders(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", "first");
|
headers.add("TestHeader", "first");
|
||||||
headers.add("TestHeader", "second");
|
headers.add("TestHeader", "second");
|
||||||
assertThat(headers.size()).isEqualTo(1);
|
assertThat(headers.size()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void keySetShouldNotDuplicateHeaderNames(String displayName, MultiValueMap<String, String> headers) {
|
void keySetShouldNotDuplicateHeaderNames(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", "first");
|
headers.add("TestHeader", "first");
|
||||||
headers.add("OtherHeader", "test");
|
headers.add("OtherHeader", "test");
|
||||||
headers.add("TestHeader", "second");
|
headers.add("TestHeader", "second");
|
||||||
|
|
@ -75,13 +76,13 @@ class HeadersAdaptersTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void containsKeyShouldBeCaseInsensitive(String displayName, MultiValueMap<String, String> headers) {
|
void containsKeyShouldBeCaseInsensitive(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", "first");
|
headers.add("TestHeader", "first");
|
||||||
assertThat(headers.containsKey("testheader")).isTrue();
|
assertThat(headers.containsKey("testheader")).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void addShouldKeepOrdering(String displayName, MultiValueMap<String, String> headers) {
|
void addShouldKeepOrdering(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", "first");
|
headers.add("TestHeader", "first");
|
||||||
headers.add("TestHeader", "second");
|
headers.add("TestHeader", "second");
|
||||||
assertThat(headers.getFirst("TestHeader")).isEqualTo("first");
|
assertThat(headers.getFirst("TestHeader")).isEqualTo("first");
|
||||||
|
|
@ -89,7 +90,7 @@ class HeadersAdaptersTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void putShouldOverrideExisting(String displayName, MultiValueMap<String, String> headers) {
|
void putShouldOverrideExisting(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", "first");
|
headers.add("TestHeader", "first");
|
||||||
headers.put("TestHeader", Arrays.asList("override"));
|
headers.put("TestHeader", Arrays.asList("override"));
|
||||||
assertThat(headers.getFirst("TestHeader")).isEqualTo("override");
|
assertThat(headers.getFirst("TestHeader")).isEqualTo("override");
|
||||||
|
|
@ -97,7 +98,7 @@ class HeadersAdaptersTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void nullValuesShouldNotFail(String displayName, MultiValueMap<String, String> headers) {
|
void nullValuesShouldNotFail(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", null);
|
headers.add("TestHeader", null);
|
||||||
assertThat(headers.getFirst("TestHeader")).isNull();
|
assertThat(headers.getFirst("TestHeader")).isNull();
|
||||||
headers.set("TestHeader", null);
|
headers.set("TestHeader", null);
|
||||||
|
|
@ -105,7 +106,7 @@ class HeadersAdaptersTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void shouldReflectChangesOnKeyset(String displayName, MultiValueMap<String, String> headers) {
|
void shouldReflectChangesOnKeyset(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", "first");
|
headers.add("TestHeader", "first");
|
||||||
assertThat(headers.keySet()).hasSize(1);
|
assertThat(headers.keySet()).hasSize(1);
|
||||||
headers.keySet().removeIf("TestHeader"::equals);
|
headers.keySet().removeIf("TestHeader"::equals);
|
||||||
|
|
@ -113,7 +114,7 @@ class HeadersAdaptersTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedHeadersTest
|
@ParameterizedHeadersTest
|
||||||
void shouldFailIfHeaderRemovedFromKeyset(String displayName, MultiValueMap<String, String> headers) {
|
void shouldFailIfHeaderRemovedFromKeyset(MultiValueMap<String, String> headers) {
|
||||||
headers.add("TestHeader", "first");
|
headers.add("TestHeader", "first");
|
||||||
assertThat(headers.keySet()).hasSize(1);
|
assertThat(headers.keySet()).hasSize(1);
|
||||||
Iterator<String> names = headers.keySet().iterator();
|
Iterator<String> names = headers.keySet().iterator();
|
||||||
|
|
@ -132,11 +133,11 @@ class HeadersAdaptersTests {
|
||||||
|
|
||||||
static Stream<Arguments> headers() {
|
static Stream<Arguments> headers() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments("Map", CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))),
|
arguments(named("Map", CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH)))),
|
||||||
arguments("Netty", new NettyHeadersAdapter(new DefaultHttpHeaders())),
|
arguments(named("Netty", new NettyHeadersAdapter(new DefaultHttpHeaders()))),
|
||||||
arguments("Tomcat", new TomcatHeadersAdapter(new MimeHeaders())),
|
arguments(named("Tomcat", new TomcatHeadersAdapter(new MimeHeaders()))),
|
||||||
arguments("Undertow", new UndertowHeadersAdapter(new HeaderMap())),
|
arguments(named("Undertow", new UndertowHeadersAdapter(new HeaderMap()))),
|
||||||
arguments("Jetty", new JettyHeadersAdapter(HttpFields.build()))
|
arguments(named("Jetty", new JettyHeadersAdapter(HttpFields.build())))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -16,8 +16,11 @@
|
||||||
|
|
||||||
package org.springframework.web.client;
|
package org.springframework.web.client;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
|
@ -27,6 +30,8 @@ import org.springframework.http.client.ClientHttpResponse;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.springframework.http.HttpStatus.BAD_GATEWAY;
|
import static org.springframework.http.HttpStatus.BAD_GATEWAY;
|
||||||
|
|
@ -65,7 +70,7 @@ class DefaultResponseErrorHandlerHttpStatusTests {
|
||||||
assertThat(this.handler.hasError(this.response)).isTrue();
|
assertThat(this.handler.hasError(this.response)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest(name = "[{index}] error: [{0}], exception: [{1}]")
|
@ParameterizedTest(name = "[{index}] error: {0}, exception: {1}")
|
||||||
@DisplayName("handleError() throws an exception")
|
@DisplayName("handleError() throws an exception")
|
||||||
@MethodSource("errorCodes")
|
@MethodSource("errorCodes")
|
||||||
void handleErrorException(HttpStatus httpStatus, Class<? extends Throwable> expectedExceptionClass) throws Exception {
|
void handleErrorException(HttpStatus httpStatus, Class<? extends Throwable> expectedExceptionClass) throws Exception {
|
||||||
|
|
@ -78,27 +83,33 @@ class DefaultResponseErrorHandlerHttpStatusTests {
|
||||||
assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> this.handler.handleError(this.response));
|
assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> this.handler.handleError(this.response));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Object[][] errorCodes() {
|
static Stream<Arguments> errorCodes() {
|
||||||
return new Object[][]{
|
return Stream.of(
|
||||||
// 4xx
|
// 4xx
|
||||||
{BAD_REQUEST, HttpClientErrorException.BadRequest.class},
|
args(BAD_REQUEST, HttpClientErrorException.BadRequest.class),
|
||||||
{UNAUTHORIZED, HttpClientErrorException.Unauthorized.class},
|
args(UNAUTHORIZED, HttpClientErrorException.Unauthorized.class),
|
||||||
{FORBIDDEN, HttpClientErrorException.Forbidden.class},
|
args(FORBIDDEN, HttpClientErrorException.Forbidden.class),
|
||||||
{NOT_FOUND, HttpClientErrorException.NotFound.class},
|
args(NOT_FOUND, HttpClientErrorException.NotFound.class),
|
||||||
{METHOD_NOT_ALLOWED, HttpClientErrorException.MethodNotAllowed.class},
|
args(METHOD_NOT_ALLOWED, HttpClientErrorException.MethodNotAllowed.class),
|
||||||
{NOT_ACCEPTABLE, HttpClientErrorException.NotAcceptable.class},
|
args(NOT_ACCEPTABLE, HttpClientErrorException.NotAcceptable.class),
|
||||||
{CONFLICT, HttpClientErrorException.Conflict.class},
|
args(CONFLICT, HttpClientErrorException.Conflict.class),
|
||||||
{TOO_MANY_REQUESTS, HttpClientErrorException.TooManyRequests.class},
|
args(TOO_MANY_REQUESTS, HttpClientErrorException.TooManyRequests.class),
|
||||||
{UNPROCESSABLE_ENTITY, HttpClientErrorException.UnprocessableEntity.class},
|
args(UNPROCESSABLE_ENTITY, HttpClientErrorException.UnprocessableEntity.class),
|
||||||
{I_AM_A_TEAPOT, HttpClientErrorException.class},
|
args(I_AM_A_TEAPOT, HttpClientErrorException.class),
|
||||||
// 5xx
|
// 5xx
|
||||||
{INTERNAL_SERVER_ERROR, HttpServerErrorException.InternalServerError.class},
|
args(INTERNAL_SERVER_ERROR, HttpServerErrorException.InternalServerError.class),
|
||||||
{NOT_IMPLEMENTED, HttpServerErrorException.NotImplemented.class},
|
args(NOT_IMPLEMENTED, HttpServerErrorException.NotImplemented.class),
|
||||||
{BAD_GATEWAY, HttpServerErrorException.BadGateway.class},
|
args(BAD_GATEWAY, HttpServerErrorException.BadGateway.class),
|
||||||
{SERVICE_UNAVAILABLE, HttpServerErrorException.ServiceUnavailable.class},
|
args(SERVICE_UNAVAILABLE, HttpServerErrorException.ServiceUnavailable.class),
|
||||||
{GATEWAY_TIMEOUT, HttpServerErrorException.GatewayTimeout.class},
|
args(GATEWAY_TIMEOUT, HttpServerErrorException.GatewayTimeout.class),
|
||||||
{HTTP_VERSION_NOT_SUPPORTED, HttpServerErrorException.class}
|
args(HTTP_VERSION_NOT_SUPPORTED, HttpServerErrorException.class)
|
||||||
};
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Arguments args(HttpStatus httpStatus, Class<? extends Throwable> exceptionType) {
|
||||||
|
return arguments(
|
||||||
|
named(String.valueOf(httpStatus.value()), httpStatus),
|
||||||
|
named(exceptionType.getSimpleName(), exceptionType));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -30,6 +30,7 @@ import java.util.stream.Stream;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
|
@ -57,6 +58,7 @@ import org.springframework.util.MultiValueMap;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.springframework.http.HttpMethod.POST;
|
import static org.springframework.http.HttpMethod.POST;
|
||||||
import static org.springframework.http.MediaType.MULTIPART_MIXED;
|
import static org.springframework.http.MediaType.MULTIPART_MIXED;
|
||||||
|
|
||||||
|
|
@ -87,11 +89,11 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static Stream<ClientHttpRequestFactory> clientHttpRequestFactories() {
|
static Stream<Named<ClientHttpRequestFactory>> clientHttpRequestFactories() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
new SimpleClientHttpRequestFactory(),
|
named("JDK", new SimpleClientHttpRequestFactory()),
|
||||||
new HttpComponentsClientHttpRequestFactory(),
|
named("HttpComponents", new HttpComponentsClientHttpRequestFactory()),
|
||||||
new OkHttp3ClientHttpRequestFactory()
|
named("OkHttp", new OkHttp3ClientHttpRequestFactory())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -23,6 +23,7 @@ import java.lang.annotation.Target;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
@ -34,6 +35,7 @@ import org.springframework.web.util.UrlPathHelper;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link UrlBasedCorsConfigurationSource}.
|
* Unit tests for {@link UrlBasedCorsConfigurationSource}.
|
||||||
|
|
@ -42,62 +44,35 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||||
*/
|
*/
|
||||||
class UrlBasedCorsConfigurationSourceTests {
|
class UrlBasedCorsConfigurationSourceTests {
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
private final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource("pathPatternsArguments")
|
|
||||||
@interface PathPatternsParameterizedTest {
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static Stream<Function<String, MockHttpServletRequest>> pathPatternsArguments() {
|
|
||||||
return Stream.of(
|
|
||||||
requestUri -> {
|
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri);
|
|
||||||
ServletRequestPathUtils.parseAndCache(request);
|
|
||||||
return request;
|
|
||||||
},
|
|
||||||
requestUri -> {
|
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri);
|
|
||||||
UrlPathHelper.defaultInstance.getLookupPathForRequest(request);
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void empty(Function<String, MockHttpServletRequest> requestFactory) {
|
void empty(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
CorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
||||||
assertThat(source.getCorsConfiguration(requestFactory.apply("/bar/test.html"))).isNull();
|
assertThat(source.getCorsConfiguration(requestFactory.apply("/bar/test.html"))).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void registerAndMatch(Function<String, MockHttpServletRequest> requestFactory) {
|
void registerAndMatch(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
|
source.registerCorsConfiguration("/bar/**", config);
|
||||||
configSource.registerCorsConfiguration("/bar/**", config);
|
|
||||||
|
|
||||||
MockHttpServletRequest request = requestFactory.apply("/foo/test.html");
|
MockHttpServletRequest request = requestFactory.apply("/foo/test.html");
|
||||||
assertThat(configSource.getCorsConfiguration(request)).isNull();
|
assertThat(source.getCorsConfiguration(request)).isNull();
|
||||||
|
|
||||||
request = requestFactory.apply("/bar/test.html");
|
request = requestFactory.apply("/bar/test.html");
|
||||||
assertThat(configSource.getCorsConfiguration(request)).isEqualTo(config);
|
assertThat(source.getCorsConfiguration(request)).isEqualTo(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void unmodifiableConfigurationsMap() {
|
void unmodifiableConfigurationsMap() {
|
||||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||||
.isThrownBy(() -> {
|
.isThrownBy(() -> source.getCorsConfigurations().put("/**", new CorsConfiguration()));
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
||||||
source.getCorsConfigurations().put("/**", new CorsConfiguration());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void allowInitLookupPath() {
|
void allowInitLookupPath() {
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
||||||
source.registerCorsConfiguration("/**", config);
|
source.registerCorsConfiguration("/**", config);
|
||||||
|
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
|
||||||
|
|
@ -108,4 +83,29 @@ class UrlBasedCorsConfigurationSourceTests {
|
||||||
source.setAllowInitLookupPath(false);
|
source.setAllowInitLookupPath(false);
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> source.getCorsConfiguration(request));
|
assertThatIllegalArgumentException().isThrownBy(() -> source.getCorsConfiguration(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@ParameterizedTest(name = "[{index}] {0}")
|
||||||
|
@MethodSource("pathPatternsArguments")
|
||||||
|
private @interface PathPatternsParameterizedTest {
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private static Stream<Named<Function<String, MockHttpServletRequest>>> pathPatternsArguments() {
|
||||||
|
return Stream.of(
|
||||||
|
named("ServletRequestPathUtils", requestUri -> {
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri);
|
||||||
|
ServletRequestPathUtils.parseAndCache(request);
|
||||||
|
return request;
|
||||||
|
}),
|
||||||
|
named("UrlPathHelper", requestUri -> {
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri);
|
||||||
|
UrlPathHelper.defaultInstance.getLookupPathForRequest(request);
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -26,6 +26,7 @@ import java.util.stream.Stream;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
|
@ -36,6 +37,8 @@ import org.springframework.http.server.reactive.HttpHandler;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.client.HttpServerErrorException;
|
import org.springframework.web.client.HttpServerErrorException;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
|
||||||
public abstract class AbstractHttpHandlerIntegrationTests {
|
public abstract class AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -120,12 +123,12 @@ public abstract class AbstractHttpHandlerIntegrationTests {
|
||||||
public @interface ParameterizedHttpServerTest {
|
public @interface ParameterizedHttpServerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Stream<HttpServer> httpServers() {
|
static Stream<Named<HttpServer>> httpServers() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
new JettyHttpServer(),
|
named("Jetty", new JettyHttpServer()),
|
||||||
new ReactorHttpServer(),
|
named("Reactor Netty", new ReactorHttpServer()),
|
||||||
new TomcatHttpServer(),
|
named("Tomcat", new TomcatHttpServer()),
|
||||||
new UndertowHttpServer()
|
named("Undertow", new UndertowHttpServer())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -45,7 +45,7 @@ import org.springframework.web.util.UriUtils;
|
||||||
* values from the model or with URI variables from the current request.
|
* values from the model or with URI variables from the current request.
|
||||||
*
|
*
|
||||||
* <p>By default {@link HttpStatus#SEE_OTHER} is used but alternate status codes
|
* <p>By default {@link HttpStatus#SEE_OTHER} is used but alternate status codes
|
||||||
* may be via constructor or setters arguments.
|
* may be supplied via constructor or setters arguments.
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
|
|
@ -74,7 +74,7 @@ public class RedirectView extends AbstractUrlBasedView {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code RedirectView} with the given redirect URL.
|
* Create a new {@code RedirectView} with the given redirect URL.
|
||||||
* Status code {@link HttpStatus#SEE_OTHER} is used by default.
|
* <p>Status code {@link HttpStatus#SEE_OTHER} is used by default.
|
||||||
*/
|
*/
|
||||||
public RedirectView(String redirectUrl) {
|
public RedirectView(String redirectUrl) {
|
||||||
super(redirectUrl);
|
super(redirectUrl);
|
||||||
|
|
@ -109,9 +109,9 @@ public class RedirectView extends AbstractUrlBasedView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to interpret a given redirect URLs that starts with a slash ("/")
|
* Whether to interpret a given redirect URL that starts with a slash ("/")
|
||||||
* as relative to the current context path ({@code true}, the default) or to
|
* as relative to the current context path ({@code true}, the default) or
|
||||||
* the web server root ({@code false}).
|
* relative to the web server root ({@code false}).
|
||||||
*/
|
*/
|
||||||
public void setContextRelative(boolean contextRelative) {
|
public void setContextRelative(boolean contextRelative) {
|
||||||
this.contextRelative = contextRelative;
|
this.contextRelative = contextRelative;
|
||||||
|
|
@ -141,7 +141,7 @@ public class RedirectView extends AbstractUrlBasedView {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure one or more hosts associated with the application.
|
* Configure one or more hosts associated with the application.
|
||||||
* All other hosts will be considered external hosts.
|
* <p>All other hosts will be considered external hosts.
|
||||||
* <p>In effect this provides a way turn off encoding for URLs that
|
* <p>In effect this provides a way turn off encoding for URLs that
|
||||||
* have a host and that host is not listed as a known host.
|
* have a host and that host is not listed as a known host.
|
||||||
* <p>If not set (the default) all redirect URLs are encoded.
|
* <p>If not set (the default) all redirect URLs are encoded.
|
||||||
|
|
@ -301,7 +301,7 @@ public class RedirectView extends AbstractUrlBasedView {
|
||||||
* property is configured and the target URL has a host that does not match.
|
* property is configured and the target URL has a host that does not match.
|
||||||
* @param targetUrl the target redirect URL
|
* @param targetUrl the target redirect URL
|
||||||
* @return {@code true} the target URL has a remote host, {@code false} if it
|
* @return {@code true} the target URL has a remote host, {@code false} if it
|
||||||
* the URL does not have a host or the "host" property is not configured.
|
* the URL does not have a host or the "host" property is not configured
|
||||||
*/
|
*/
|
||||||
protected boolean isRemoteHost(String targetUrl) {
|
protected boolean isRemoteHost(String targetUrl) {
|
||||||
if (ObjectUtils.isEmpty(this.hosts)) {
|
if (ObjectUtils.isEmpty(this.hosts)) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -34,7 +34,7 @@ import org.springframework.ui.Model;
|
||||||
* Or controllers may return model attribute(s) and rely on a default view name
|
* Or controllers may return model attribute(s) and rely on a default view name
|
||||||
* being selected based on the request path.
|
* being selected based on the request path.
|
||||||
*
|
*
|
||||||
* <p>{@link Rendering} can be used to combine a view name with model attributes,
|
* <p>{@code Rendering} can be used to combine a view name with model attributes,
|
||||||
* set the HTTP status or headers, and for other more advanced options around
|
* set the HTTP status or headers, and for other more advanced options around
|
||||||
* redirect scenarios.
|
* redirect scenarios.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -96,7 +96,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
|
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void bodyToMonoVoid(String displayName, DataBufferFactory bufferFactory) {
|
void bodyToMonoVoid(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
this.server.enqueue(new MockResponse()
|
this.server.enqueue(new MockResponse()
|
||||||
|
|
@ -114,7 +114,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest // SPR-17482
|
@ParameterizedDataBufferAllocatingTest // SPR-17482
|
||||||
void bodyToMonoVoidWithoutContentType(String displayName, DataBufferFactory bufferFactory) {
|
void bodyToMonoVoidWithoutContentType(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
this.server.enqueue(new MockResponse()
|
this.server.enqueue(new MockResponse()
|
||||||
|
|
@ -131,7 +131,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void onStatusWithBodyNotConsumed(String displayName, DataBufferFactory bufferFactory) {
|
void onStatusWithBodyNotConsumed(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
RuntimeException ex = new RuntimeException("response error");
|
RuntimeException ex = new RuntimeException("response error");
|
||||||
|
|
@ -139,7 +139,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void onStatusWithBodyConsumed(String displayName, DataBufferFactory bufferFactory) {
|
void onStatusWithBodyConsumed(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
RuntimeException ex = new RuntimeException("response error");
|
RuntimeException ex = new RuntimeException("response error");
|
||||||
|
|
@ -147,7 +147,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest // SPR-17473
|
@ParameterizedDataBufferAllocatingTest // SPR-17473
|
||||||
void onStatusWithMonoErrorAndBodyNotConsumed(String displayName, DataBufferFactory bufferFactory) {
|
void onStatusWithMonoErrorAndBodyNotConsumed(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
RuntimeException ex = new RuntimeException("response error");
|
RuntimeException ex = new RuntimeException("response error");
|
||||||
|
|
@ -155,7 +155,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void onStatusWithMonoErrorAndBodyConsumed(String displayName, DataBufferFactory bufferFactory) {
|
void onStatusWithMonoErrorAndBodyConsumed(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
RuntimeException ex = new RuntimeException("response error");
|
RuntimeException ex = new RuntimeException("response error");
|
||||||
|
|
@ -163,7 +163,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest // gh-23230
|
@ParameterizedDataBufferAllocatingTest // gh-23230
|
||||||
void onStatusWithImmediateErrorAndBodyNotConsumed(String displayName, DataBufferFactory bufferFactory) {
|
void onStatusWithImmediateErrorAndBodyNotConsumed(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
RuntimeException ex = new RuntimeException("response error");
|
RuntimeException ex = new RuntimeException("response error");
|
||||||
|
|
@ -173,7 +173,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void releaseBody(String displayName, DataBufferFactory bufferFactory) {
|
void releaseBody(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
this.server.enqueue(new MockResponse()
|
this.server.enqueue(new MockResponse()
|
||||||
|
|
@ -190,7 +190,7 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedDataBufferAllocatingTest
|
@ParameterizedDataBufferAllocatingTest
|
||||||
void exchangeToBodilessEntity(String displayName, DataBufferFactory bufferFactory) {
|
void exchangeToBodilessEntity(DataBufferFactory bufferFactory) {
|
||||||
setUp(bufferFactory);
|
setUp(bufferFactory);
|
||||||
|
|
||||||
this.server.enqueue(new MockResponse()
|
this.server.enqueue(new MockResponse()
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import okhttp3.mockwebserver.MockResponse;
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
import okhttp3.mockwebserver.RecordedRequest;
|
import okhttp3.mockwebserver.RecordedRequest;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
@ -76,6 +77,7 @@ import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
|
||||||
import org.springframework.web.testfixture.xml.Pojo;
|
import org.springframework.web.testfixture.xml.Pojo;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests using an {@link ExchangeFunction} through {@link WebClient}.
|
* Integration tests using an {@link ExchangeFunction} through {@link WebClient}.
|
||||||
|
|
@ -91,17 +93,17 @@ class WebClientIntegrationTests {
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@ParameterizedTest(name = "[{index}] {displayName} [{0}]")
|
@ParameterizedTest(name = "[{index}] {0}")
|
||||||
@MethodSource("arguments")
|
@MethodSource("arguments")
|
||||||
@interface ParameterizedWebClientTest {
|
@interface ParameterizedWebClientTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Stream<ClientHttpConnector> arguments() {
|
static Stream<Named<ClientHttpConnector>> arguments() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
new ReactorClientHttpConnector(),
|
named("Reactor Netty", new ReactorClientHttpConnector()),
|
||||||
new JdkClientHttpConnector(),
|
named("JDK", new JdkClientHttpConnector()),
|
||||||
new JettyClientHttpConnector(),
|
named("Jetty", new JettyClientHttpConnector()),
|
||||||
new HttpComponentsClientHttpConnector()
|
named("HttpComponents", new HttpComponentsClientHttpConnector())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,9 +21,11 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
@ -36,7 +38,6 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||||
import org.springframework.http.client.reactive.HttpComponentsClientHttpConnector;
|
import org.springframework.http.client.reactive.HttpComponentsClientHttpConnector;
|
||||||
import org.springframework.http.client.reactive.JdkClientHttpConnector;
|
|
||||||
import org.springframework.http.client.reactive.JettyClientHttpConnector;
|
import org.springframework.http.client.reactive.JettyClientHttpConnector;
|
||||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||||
import org.springframework.http.codec.ServerSentEvent;
|
import org.springframework.http.codec.ServerSentEvent;
|
||||||
|
|
@ -57,6 +58,7 @@ import org.springframework.web.testfixture.http.server.reactive.bootstrap.Undert
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -65,35 +67,6 @@ import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
||||||
*/
|
*/
|
||||||
class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@ParameterizedTest(name = "[{index}] server [{0}], webClient [{1}]")
|
|
||||||
@MethodSource("arguments")
|
|
||||||
protected @interface ParameterizedSseTest {
|
|
||||||
}
|
|
||||||
|
|
||||||
static Object[][] arguments() {
|
|
||||||
return new Object[][] {
|
|
||||||
{new JettyHttpServer(), new ReactorClientHttpConnector()},
|
|
||||||
{new JettyHttpServer(), new JdkClientHttpConnector()},
|
|
||||||
{new JettyHttpServer(), new JettyClientHttpConnector()},
|
|
||||||
{new JettyHttpServer(), new HttpComponentsClientHttpConnector()},
|
|
||||||
{new ReactorHttpServer(), new ReactorClientHttpConnector()},
|
|
||||||
{new ReactorHttpServer(), new JdkClientHttpConnector()},
|
|
||||||
{new ReactorHttpServer(), new JettyClientHttpConnector()},
|
|
||||||
{new ReactorHttpServer(), new HttpComponentsClientHttpConnector()},
|
|
||||||
{new TomcatHttpServer(), new ReactorClientHttpConnector()},
|
|
||||||
{new TomcatHttpServer(), new JdkClientHttpConnector()},
|
|
||||||
{new TomcatHttpServer(), new JettyClientHttpConnector()},
|
|
||||||
{new TomcatHttpServer(), new HttpComponentsClientHttpConnector()},
|
|
||||||
{new UndertowHttpServer(), new ReactorClientHttpConnector()},
|
|
||||||
{new UndertowHttpServer(), new JdkClientHttpConnector()},
|
|
||||||
{new UndertowHttpServer(), new JettyClientHttpConnector()},
|
|
||||||
{new UndertowHttpServer(), new HttpComponentsClientHttpConnector()},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private AnnotationConfigApplicationContext wac;
|
private AnnotationConfigApplicationContext wac;
|
||||||
|
|
||||||
private WebClient webClient;
|
private WebClient webClient;
|
||||||
|
|
@ -317,4 +290,35 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@ParameterizedTest(name = "[{index}] server = {0}, webClient = {1}")
|
||||||
|
@MethodSource("arguments")
|
||||||
|
private @interface ParameterizedSseTest {
|
||||||
|
}
|
||||||
|
|
||||||
|
static Stream<Arguments> arguments() {
|
||||||
|
return Stream.of(
|
||||||
|
args(new JettyHttpServer(), new ReactorClientHttpConnector()),
|
||||||
|
args(new JettyHttpServer(), new JettyClientHttpConnector()),
|
||||||
|
args(new JettyHttpServer(), new HttpComponentsClientHttpConnector()),
|
||||||
|
args(new ReactorHttpServer(), new ReactorClientHttpConnector()),
|
||||||
|
args(new ReactorHttpServer(), new JettyClientHttpConnector()),
|
||||||
|
args(new ReactorHttpServer(), new HttpComponentsClientHttpConnector()),
|
||||||
|
args(new TomcatHttpServer(), new ReactorClientHttpConnector()),
|
||||||
|
args(new TomcatHttpServer(), new JettyClientHttpConnector()),
|
||||||
|
args(new TomcatHttpServer(), new HttpComponentsClientHttpConnector()),
|
||||||
|
args(new UndertowHttpServer(), new ReactorClientHttpConnector()),
|
||||||
|
args(new UndertowHttpServer(), new JettyClientHttpConnector()),
|
||||||
|
args(new UndertowHttpServer(), new HttpComponentsClientHttpConnector())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Arguments args(HttpServer httpServer, ClientHttpConnector connector) {
|
||||||
|
return Arguments.of(
|
||||||
|
named(httpServer.getClass().getSimpleName(), httpServer),
|
||||||
|
named(connector.getClass().getSimpleName(), connector));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -16,9 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.web.servlet.handler;
|
package org.springframework.web.servlet.handler;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
@ -31,6 +29,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,19 +42,12 @@ class HandlerMappingTests {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Stream<Arguments> pathPatternsArguments() {
|
private static Stream<Arguments> pathPatternsArguments() {
|
||||||
List<Function<String, MockHttpServletRequest>> factories =
|
return PathPatternsTestUtils.requestArguments().map(function -> arguments(function, new TestHandlerMapping()));
|
||||||
PathPatternsTestUtils.requestArguments().collect(Collectors.toList());
|
|
||||||
return Stream.of(
|
|
||||||
Arguments.arguments(new TestHandlerMapping(), factories.get(0)),
|
|
||||||
Arguments.arguments(new TestHandlerMapping(), factories.get(1))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void orderedInterceptors(
|
void orderedInterceptors(Function<String, MockHttpServletRequest> requestFactory, TestHandlerMapping mapping) throws Exception {
|
||||||
TestHandlerMapping mapping, Function<String, MockHttpServletRequest> requestFactory)
|
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
MappedInterceptor i1 = new MappedInterceptor(new String[] {"/**"}, mock(HandlerInterceptor.class));
|
MappedInterceptor i1 = new MappedInterceptor(new String[] {"/**"}, mock(HandlerInterceptor.class));
|
||||||
HandlerInterceptor i2 = mock(HandlerInterceptor.class);
|
HandlerInterceptor i2 = mock(HandlerInterceptor.class);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -23,6 +23,7 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.util.PathMatcher;
|
import org.springframework.util.PathMatcher;
|
||||||
|
|
@ -46,7 +47,7 @@ class MappedInterceptorTests {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Stream<Function<String, MockHttpServletRequest>> pathPatternsArguments() {
|
private static Stream<Named<Function<String, MockHttpServletRequest>>> pathPatternsArguments() {
|
||||||
return PathPatternsTestUtils.requestArguments();
|
return PathPatternsTestUtils.requestArguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,6 +21,9 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation for tests parameterized to use either
|
* Annotation for tests parameterized to use either
|
||||||
* {@link org.springframework.web.util.pattern.PathPatternParser} or
|
* {@link org.springframework.web.util.pattern.PathPatternParser} or
|
||||||
|
|
@ -33,7 +36,7 @@ import java.lang.annotation.Target;
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
// Do not auto-close arguments since ConfigurableWebApplicationContext implements
|
// Do not auto-close arguments since ConfigurableWebApplicationContext implements
|
||||||
// AutoCloseable and is shared between parameterized test invocations.
|
// AutoCloseable and is shared between parameterized test invocations.
|
||||||
@org.junit.jupiter.params.ParameterizedTest(autoCloseArguments = false)
|
@ParameterizedTest(name = "[{index}] {0}", autoCloseArguments = false)
|
||||||
@org.junit.jupiter.params.provider.MethodSource("pathPatternsArguments")
|
@MethodSource("pathPatternsArguments")
|
||||||
public @interface PathPatternsParameterizedTest {
|
public @interface PathPatternsParameterizedTest {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -20,11 +20,15 @@ import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||||
import org.springframework.web.util.ServletRequestPathUtils;
|
import org.springframework.web.util.ServletRequestPathUtils;
|
||||||
import org.springframework.web.util.UrlPathHelper;
|
import org.springframework.web.util.UrlPathHelper;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods to help with parameterized tests for URL pattern matching
|
* Utility methods to help with parameterized tests for URL pattern matching
|
||||||
* via pre-parsed {@code PathPattern}s or String pattern matching with
|
* via pre-parsed {@code PathPattern}s or String pattern matching with
|
||||||
|
|
@ -35,22 +39,22 @@ import org.springframework.web.util.UrlPathHelper;
|
||||||
*/
|
*/
|
||||||
public abstract class PathPatternsTestUtils {
|
public abstract class PathPatternsTestUtils {
|
||||||
|
|
||||||
public static Stream<Function<String, MockHttpServletRequest>> requestArguments() {
|
public static Stream<Named<Function<String, MockHttpServletRequest>>> requestArguments() {
|
||||||
return requestArguments(null);
|
return requestArguments(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Function<String, MockHttpServletRequest>> requestArguments(@Nullable String contextPath) {
|
public static Stream<Named<Function<String, MockHttpServletRequest>>> requestArguments(@Nullable String contextPath) {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
path -> {
|
named("ServletRequestPathUtils", path -> {
|
||||||
MockHttpServletRequest request = createRequest("GET", contextPath, path);
|
MockHttpServletRequest request = createRequest("GET", contextPath, path);
|
||||||
ServletRequestPathUtils.parseAndCache(request);
|
ServletRequestPathUtils.parseAndCache(request);
|
||||||
return request;
|
return request;
|
||||||
},
|
}),
|
||||||
path -> {
|
named("UrlPathHelper", path -> {
|
||||||
MockHttpServletRequest request = createRequest("GET", contextPath, path);
|
MockHttpServletRequest request = createRequest("GET", contextPath, path);
|
||||||
UrlPathHelper.defaultInstance.resolveAndCacheLookupPath(request);
|
UrlPathHelper.defaultInstance.resolveAndCacheLookupPath(request);
|
||||||
return request;
|
return request;
|
||||||
}
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,6 +19,7 @@ package org.springframework.web.servlet.mvc;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
|
|
@ -42,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
class UrlFilenameViewControllerTests {
|
class UrlFilenameViewControllerTests {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Stream<Function<String, MockHttpServletRequest>> pathPatternsArguments() {
|
private static Stream<Named<Function<String, MockHttpServletRequest>>> pathPatternsArguments() {
|
||||||
return PathPatternsTestUtils.requestArguments();
|
return PathPatternsTestUtils.requestArguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -20,6 +20,7 @@ import java.util.Properties;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.web.servlet.handler.PathPatternsParameterizedTest;
|
import org.springframework.web.servlet.handler.PathPatternsParameterizedTest;
|
||||||
|
|
@ -46,7 +47,7 @@ class WebContentInterceptorTests {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Stream<Function<String, MockHttpServletRequest>> pathPatternsArguments() {
|
private static Stream<Named<Function<String, MockHttpServletRequest>>> pathPatternsArguments() {
|
||||||
return PathPatternsTestUtils.requestArguments();
|
return PathPatternsTestUtils.requestArguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,8 +19,10 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||||
|
|
@ -49,6 +51,8 @@ import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||||
import org.springframework.web.testfixture.servlet.MockHttpServletResponse;
|
import org.springframework.web.testfixture.servlet.MockHttpServletResponse;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test various scenarios for detecting method-level and method parameter annotations depending
|
* Test various scenarios for detecting method-level and method parameter annotations depending
|
||||||
|
|
@ -60,34 +64,39 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
class HandlerMethodAnnotationDetectionTests {
|
class HandlerMethodAnnotationDetectionTests {
|
||||||
|
|
||||||
static Object[][] handlerTypes() {
|
static Stream<Arguments> handlerTypes() {
|
||||||
return new Object[][] {
|
return Stream.of(
|
||||||
{ SimpleController.class, true }, // CGLIB proxy
|
args(SimpleController.class, true), // CGLIB proxy
|
||||||
{ SimpleController.class, false },
|
args(SimpleController.class, false),
|
||||||
|
|
||||||
{ AbstractClassController.class, true }, // CGLIB proxy
|
args(AbstractClassController.class, true), // CGLIB proxy
|
||||||
{ AbstractClassController.class, false },
|
args(AbstractClassController.class, false),
|
||||||
|
|
||||||
{ ParameterizedAbstractClassController.class, true }, // CGLIB proxy
|
args(ParameterizedAbstractClassController.class, true), // CGLIB proxy
|
||||||
{ ParameterizedAbstractClassController.class, false },
|
args(ParameterizedAbstractClassController.class, false),
|
||||||
|
|
||||||
{ ParameterizedSubclassOverridesDefaultMappings.class, true }, // CGLIB proxy
|
args(ParameterizedSubclassOverridesDefaultMappings.class, true), // CGLIB proxy
|
||||||
{ ParameterizedSubclassOverridesDefaultMappings.class, false },
|
args(ParameterizedSubclassOverridesDefaultMappings.class, false),
|
||||||
|
|
||||||
// TODO [SPR-9517] Enable ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass test cases
|
// TODO [SPR-9517] Enable ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass test cases
|
||||||
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLIB proxy
|
// args(ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true), // CGLIB proxy
|
||||||
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false },
|
// args(ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false),
|
||||||
|
|
||||||
// { InterfaceController.class, true }, // JDK dynamic proxy (gh-22154: no longer supported))
|
// args(InterfaceController.class, true), // JDK dynamic proxy (gh-22154: no longer supported))
|
||||||
{ InterfaceController.class, false },
|
args(InterfaceController.class, false),
|
||||||
|
|
||||||
{ ParameterizedInterfaceController.class, false }, // no AOP
|
args(ParameterizedInterfaceController.class, false), // no AOP
|
||||||
|
|
||||||
{ SupportClassController.class, true }, // CGLIB proxy
|
args(SupportClassController.class, true), // CGLIB proxy
|
||||||
{ SupportClassController.class, false }
|
args(SupportClassController.class, false)
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Arguments args(Class<?> controllerType, boolean useAutoProxy) {
|
||||||
|
return arguments(named(controllerType.getSimpleName(), controllerType), useAutoProxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private RequestMappingHandlerMapping handlerMapping;
|
private RequestMappingHandlerMapping handlerMapping;
|
||||||
|
|
||||||
private RequestMappingHandlerAdapter handlerAdapter;
|
private RequestMappingHandlerAdapter handlerAdapter;
|
||||||
|
|
@ -116,9 +125,9 @@ class HandlerMethodAnnotationDetectionTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ParameterizedTest(name = "[{index}] controller [{0}], auto-proxy [{1}]")
|
@ParameterizedTest(name = "[{index}] controller = {0}, auto-proxy = {1}")
|
||||||
@MethodSource("handlerTypes")
|
@MethodSource("handlerTypes")
|
||||||
void testRequestMappingMethod(Class<?> controllerType, boolean useAutoProxy) throws Exception {
|
void requestMappingMethod(Class<?> controllerType, boolean useAutoProxy) throws Exception {
|
||||||
setUp(controllerType, useAutoProxy);
|
setUp(controllerType, useAutoProxy);
|
||||||
|
|
||||||
String datePattern = "MM:dd:yyyy";
|
String datePattern = "MM:dd:yyyy";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,6 +19,8 @@ package org.springframework.web.servlet.view;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Named;
|
||||||
|
|
||||||
import org.springframework.web.servlet.handler.PathPatternsParameterizedTest;
|
import org.springframework.web.servlet.handler.PathPatternsParameterizedTest;
|
||||||
import org.springframework.web.servlet.handler.PathPatternsTestUtils;
|
import org.springframework.web.servlet.handler.PathPatternsTestUtils;
|
||||||
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||||
|
|
@ -38,59 +40,59 @@ public class DefaultRequestToViewNameTranslatorTests {
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Stream<Function<String, MockHttpServletRequest>> pathPatternsArguments() {
|
private static Stream<Named<Function<String, MockHttpServletRequest>>> pathPatternsArguments() {
|
||||||
return PathPatternsTestUtils.requestArguments("/sundays");
|
return PathPatternsTestUtils.requestArguments("/sundays");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameLeavesLeadingSlashIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameLeavesLeadingSlashIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + "/");
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + "/");
|
||||||
this.translator.setStripLeadingSlash(false);
|
this.translator.setStripLeadingSlash(false);
|
||||||
assertViewName(request, "/" + VIEW_NAME);
|
assertViewName(request, "/" + VIEW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameLeavesTrailingSlashIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameLeavesTrailingSlashIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + "/");
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + "/");
|
||||||
this.translator.setStripTrailingSlash(false);
|
this.translator.setStripTrailingSlash(false);
|
||||||
assertViewName(request, VIEW_NAME + "/");
|
assertViewName(request, VIEW_NAME + "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameLeavesExtensionIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameLeavesExtensionIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + EXTENSION);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + EXTENSION);
|
||||||
this.translator.setStripExtension(false);
|
this.translator.setStripExtension(false);
|
||||||
assertViewName(request, VIEW_NAME + EXTENSION);
|
assertViewName(request, VIEW_NAME + EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithDefaultConfiguration(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithDefaultConfiguration(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + EXTENSION);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + EXTENSION);
|
||||||
assertViewName(request, VIEW_NAME);
|
assertViewName(request, VIEW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithCustomSeparator(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithCustomSeparator(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + "/fiona" + EXTENSION);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + "/fiona" + EXTENSION);
|
||||||
this.translator.setSeparator("_");
|
this.translator.setSeparator("_");
|
||||||
assertViewName(request, VIEW_NAME + "_fiona");
|
assertViewName(request, VIEW_NAME + "_fiona");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithNoExtension(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithNoExtension(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
||||||
assertViewName(request, VIEW_NAME);
|
assertViewName(request, VIEW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithSemicolonContent(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithSemicolonContent(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + ";a=A;b=B");
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + ";a=A;b=B");
|
||||||
assertViewName(request, VIEW_NAME);
|
assertViewName(request, VIEW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithPrefix(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithPrefix(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
final String prefix = "fiona_";
|
final String prefix = "fiona_";
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
||||||
this.translator.setPrefix(prefix);
|
this.translator.setPrefix(prefix);
|
||||||
|
|
@ -98,14 +100,14 @@ public class DefaultRequestToViewNameTranslatorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithNullPrefix(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithNullPrefix(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
||||||
this.translator.setPrefix(null);
|
this.translator.setPrefix(null);
|
||||||
assertViewName(request, VIEW_NAME);
|
assertViewName(request, VIEW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithSuffix(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithSuffix(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
final String suffix = ".fiona";
|
final String suffix = ".fiona";
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
||||||
this.translator.setSuffix(suffix);
|
this.translator.setSuffix(suffix);
|
||||||
|
|
@ -113,7 +115,7 @@ public class DefaultRequestToViewNameTranslatorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PathPatternsParameterizedTest
|
@PathPatternsParameterizedTest
|
||||||
void testGetViewNameWithNullSuffix(Function<String, MockHttpServletRequest> requestFactory) {
|
void getViewNameWithNullSuffix(Function<String, MockHttpServletRequest> requestFactory) {
|
||||||
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
|
||||||
this.translator.setSuffix(null);
|
this.translator.setSuffix(null);
|
||||||
assertViewName(request, VIEW_NAME);
|
assertViewName(request, VIEW_NAME);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -46,6 +46,7 @@ import org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrate
|
||||||
import org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy;
|
import org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy;
|
||||||
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Named.named;
|
||||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,15 +67,15 @@ public abstract class AbstractWebSocketIntegrationTests {
|
||||||
|
|
||||||
static Stream<Arguments> argumentsFactory() {
|
static Stream<Arguments> argumentsFactory() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments(new JettyWebSocketTestServer(), new JettyWebSocketClient()),
|
arguments(named("Jetty", new JettyWebSocketTestServer()), named("Jetty", new JettyWebSocketClient())),
|
||||||
arguments(new TomcatWebSocketTestServer(), new StandardWebSocketClient()),
|
arguments(named("Tomcat", new TomcatWebSocketTestServer()), named("Standard", new StandardWebSocketClient())),
|
||||||
arguments(new UndertowTestServer(), new StandardWebSocketClient()));
|
arguments(named("Undertow", new UndertowTestServer()), named("Standard", new StandardWebSocketClient())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@ParameterizedTest(name = "[{index}] server [{0}], client [{1}]")
|
@ParameterizedTest(name = "[{index}] server = {0}, client = {1}")
|
||||||
@MethodSource("argumentsFactory")
|
@MethodSource("argumentsFactory")
|
||||||
protected @interface ParameterizedWebSocketTest {
|
protected @interface ParameterizedWebSocketTest {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@
|
||||||
<suppress files="ExtractingResponseErrorHandlerTests" checks="MutableException" />
|
<suppress files="ExtractingResponseErrorHandlerTests" checks="MutableException" />
|
||||||
<suppress files="ServletAnnotationControllerHandlerMethodTests" checks="InterfaceIsType" />
|
<suppress files="ServletAnnotationControllerHandlerMethodTests" checks="InterfaceIsType" />
|
||||||
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]servlet[\\/]resource[\\/]GzipSupport" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]servlet[\\/]resource[\\/]GzipSupport" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
||||||
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]servlet[\\/]handler[\\/]PathPatterns.+" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
||||||
|
|
||||||
<!-- spring-websocket -->
|
<!-- spring-websocket -->
|
||||||
<suppress files="web[\\/]socket[\\/]CloseStatus" checks="JavadocStyle" />
|
<suppress files="web[\\/]socket[\\/]CloseStatus" checks="JavadocStyle" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue