Skip to content

Commit d89adfa

Browse files
dreis2211wilkinsona
authored andcommitted
Test compression with invalid content type for all webservers
Closes gh-18338
1 parent 12751fe commit d89adfa

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.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 @@ public void useForwardedHeaders() {
8783
assertForwardHeaderIsUsed(factory);
8884
}
8985

90-
@Test
91-
public 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
@@ -278,6 +278,17 @@ public void noCompressionForUserAgent() {
278278
assertResponseIsNotCompressed(response);
279279
}
280280

281+
@Test
282+
public void noCompressionForResponseWithInvalidContentType() {
283+
Compression compression = new Compression();
284+
compression.setEnabled(true);
285+
compression.setMimeTypes(new String[] { "application/json" });
286+
WebClient client = prepareCompressionTest(compression, "test~plain");
287+
ResponseEntity<Void> response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class))
288+
.block(Duration.ofSeconds(30));
289+
assertResponseIsNotCompressed(response);
290+
}
291+
281292
@Test
282293
public void whenSslIsEnabledAndNoKeyStoreIsConfiguredThenServerFailsToStart() {
283294
assertThatThrownBy(() -> testBasicSslWithKeyStore(null, null))

0 commit comments

Comments
 (0)