|
1 | 1 | /* |
2 | | - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2023 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
17 | 17 | package org.springframework.cloud.function.web.mvc; |
18 | 18 |
|
19 | 19 | import java.net.URI; |
| 20 | +import java.net.URISyntaxException; |
20 | 21 | import java.time.Duration; |
21 | 22 | import java.util.ArrayList; |
22 | 23 | import java.util.Arrays; |
|
30 | 31 | import org.junit.jupiter.api.BeforeEach; |
31 | 32 | import org.junit.jupiter.api.Disabled; |
32 | 33 | import org.junit.jupiter.api.Test; |
| 34 | +import org.junit.jupiter.params.ParameterizedTest; |
| 35 | +import org.junit.jupiter.params.provider.ValueSource; |
33 | 36 | import reactor.core.publisher.Flux; |
34 | 37 |
|
35 | 38 | import org.springframework.beans.factory.annotation.Autowired; |
|
56 | 59 |
|
57 | 60 | /** |
58 | 61 | * @author Dave Syer |
| 62 | + * @author Chris Bono |
59 | 63 | */ |
60 | 64 | @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "spring.main.web-application-type=servlet") |
61 | 65 | @ContextConfiguration(classes = { RestApplication.class, ApplicationConfiguration.class }) |
@@ -124,6 +128,18 @@ public void word() throws Exception { |
124 | 128 | assertThat(result.getBody()).isEqualTo("foo"); |
125 | 129 | } |
126 | 130 |
|
| 131 | + // TODO: Once bug is fixed this test (last entry) will fully pass and this COMMENT should be removed |
| 132 | + @ParameterizedTest |
| 133 | + @ValueSource(strings = {"[hello", "hello]", "[hello]"}) |
| 134 | + void textContentTypeWithValueWrappedBracketsIsOk(String inputMessagePayloadValue) throws URISyntaxException { |
| 135 | + ResponseEntity<String> postForEntity = this.rest |
| 136 | + .exchange(RequestEntity.post(new URI("/echo")) |
| 137 | + .contentType(MediaType.TEXT_PLAIN) |
| 138 | + .body(inputMessagePayloadValue), String.class); |
| 139 | + assertThat(postForEntity.getStatusCode()).isEqualTo(HttpStatus.OK); |
| 140 | + assertThat(postForEntity.getBody()).isEqualTo(inputMessagePayloadValue); |
| 141 | + } |
| 142 | + |
127 | 143 | @Test |
128 | 144 | public void foos() throws Exception { |
129 | 145 | ResponseEntity<String> result = this.rest |
@@ -301,6 +317,11 @@ public Supplier<String> word() { |
301 | 317 | return () -> "foo"; |
302 | 318 | } |
303 | 319 |
|
| 320 | + @Bean |
| 321 | + public Function<String, String> echo() { |
| 322 | + return (input) -> input; |
| 323 | + } |
| 324 | + |
304 | 325 | @Bean |
305 | 326 | public Supplier<Flux<Foo>> foos() { |
306 | 327 | return () -> Flux.just(new Foo("foo"), new Foo("bar")); |
|
0 commit comments