|
16 | 16 | package org.springframework.web.reactive.function.client;
|
17 | 17 |
|
18 | 18 | import java.time.Duration;
|
| 19 | +import java.util.Map; |
19 | 20 | import java.util.function.Function;
|
20 | 21 |
|
21 | 22 | import io.netty.buffer.ByteBufAllocator;
|
|
28 | 29 | import reactor.core.publisher.Mono;
|
29 | 30 | import reactor.test.StepVerifier;
|
30 | 31 |
|
| 32 | +import org.springframework.core.ParameterizedTypeReference; |
31 | 33 | import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
|
32 | 34 | import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
33 | 35 | import org.springframework.http.HttpStatus;
|
34 | 36 | import org.springframework.http.MediaType;
|
35 | 37 | import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
36 | 38 | import org.springframework.http.client.reactive.ReactorResourceFactory;
|
| 39 | +import org.springframework.web.reactive.function.UnsupportedMediaTypeException; |
37 | 40 |
|
38 | 41 | import static org.junit.Assert.*;
|
39 | 42 |
|
@@ -103,6 +106,21 @@ public void bodyToMonoVoid() {
|
103 | 106 | assertEquals(1, this.server.getRequestCount());
|
104 | 107 | }
|
105 | 108 |
|
| 109 | + @Test // SPR-17482 |
| 110 | + public void bodyToMonoVoidWithoutContentType() { |
| 111 | + |
| 112 | + this.server.enqueue(new MockResponse() |
| 113 | + .setResponseCode(HttpStatus.ACCEPTED.value()) |
| 114 | + .setChunkedBody("{\"foo\" : \"123\", \"baz\" : \"456\", \"baz\" : \"456\"}", 5)); |
| 115 | + |
| 116 | + Mono<Map<String, String>> mono = this.webClient.get() |
| 117 | + .uri("/sample").accept(MediaType.APPLICATION_JSON) |
| 118 | + .retrieve() |
| 119 | + .bodyToMono(new ParameterizedTypeReference<Map<String, String>>() {}); |
| 120 | + |
| 121 | + StepVerifier.create(mono).expectError(UnsupportedMediaTypeException.class).verify(Duration.ofSeconds(3)); |
| 122 | + assertEquals(1, this.server.getRequestCount()); |
| 123 | + } |
106 | 124 |
|
107 | 125 | @Test
|
108 | 126 | public void onStatusWithBodyNotConsumed() {
|
|
0 commit comments