Skip to content

Commit 3fa9e03

Browse files
committed
Merge pull request #18337 from dreis2211
* gh-18337: Test compression with invalid content type for all webservers Closes gh-18337
2 parents c5cb41d + 7bc28fc commit 3fa9e03

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.boot.web.embedded.netty;
1818

19-
import java.time.Duration;
2019
import java.util.Arrays;
2120

2221
import org.junit.jupiter.api.Test;
@@ -25,10 +24,7 @@
2524

2625
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
2726
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests;
28-
import org.springframework.boot.web.server.Compression;
2927
import org.springframework.boot.web.server.PortInUseException;
30-
import org.springframework.http.ResponseEntity;
31-
import org.springframework.web.reactive.function.client.WebClient;
3228

3329
import static org.assertj.core.api.Assertions.assertThat;
3430
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -87,15 +83,4 @@ void useForwardedHeaders() {
8783
assertForwardHeaderIsUsed(factory);
8884
}
8985

90-
@Test
91-
void noCompressionForResponseWithInvalidContentType() {
92-
Compression compression = new Compression();
93-
compression.setEnabled(true);
94-
compression.setMimeTypes(new String[] { "application/json" });
95-
WebClient client = prepareCompressionTest(compression, "test~plain");
96-
ResponseEntity<Void> response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class))
97-
.block(Duration.ofSeconds(30));
98-
assertResponseIsNotCompressed(response);
99-
}
100-
10186
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,17 @@ void noCompressionForUserAgent() {
273273
assertResponseIsNotCompressed(response);
274274
}
275275

276+
@Test
277+
void noCompressionForResponseWithInvalidContentType() {
278+
Compression compression = new Compression();
279+
compression.setEnabled(true);
280+
compression.setMimeTypes(new String[] { "application/json" });
281+
WebClient client = prepareCompressionTest(compression, "test~plain");
282+
ResponseEntity<Void> response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class))
283+
.block(Duration.ofSeconds(30));
284+
assertResponseIsNotCompressed(response);
285+
}
286+
276287
@Test
277288
void whenSslIsEnabledAndNoKeyStoreIsConfiguredThenServerFailsToStart() {
278289
assertThatThrownBy(() -> testBasicSslWithKeyStore(null, null))

0 commit comments

Comments
 (0)