Updates mappings to pass tests

This commit is contained in:
spencergibb
2021-10-06 23:20:12 -04:00
parent 96804e8d5d
commit 0037ef60f9
5 changed files with 15 additions and 9 deletions

View File

@@ -284,6 +284,9 @@ public class XForwardedHeadersFilter implements HttpHeadersFilter, Ordered {
}
private void write(HttpHeaders headers, String name, String value, boolean append) {
if (value == null) {
return;
}
if (append) {
headers.add(name, value);
// these headers should be treated as a single comma separated header

View File

@@ -54,7 +54,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -211,7 +213,7 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest
@Value("${test.uri}")
private String uri;
@GetMapping("/httpbin/sleep")
@RequestMapping("/httpbin/sleep")
public Mono<ResponseEntity<String>> sleep(@RequestParam("key") String key,
@RequestParam("millis") long millisToSleep) {
AtomicInteger num = getCount(key);
@@ -231,7 +233,7 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest
.body("permanently broken");
}
@GetMapping("/httpbin/retrypost")
@PostMapping("/httpbin/retrypost")
public ResponseEntity<String> retrypost(@RequestParam("key") String key,
@RequestParam(name = "count", defaultValue = "3") int count,
@RequestParam("expectedbody") String expectedbody, @RequestBody String body) {

View File

@@ -44,7 +44,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
* @author Ryan Baxter
*/
@SpringBootTest(webEnvironment = RANDOM_PORT,
properties = { "debug=true", "spring.cloud.circuitbreaker.hystrix.enabled=false" })
properties = { "logging.level.org.springframework.cloud.gateway=TRACE", "debug=true", "spring.cloud.circuitbreaker.hystrix.enabled=false" })
@ContextConfiguration(classes = SpringCloudCircuitBreakerResilience4JFilterFactoryTests.Config.class)
@DirtiesContext
public class SpringCloudCircuitBreakerResilience4JFilterFactoryTests

View File

@@ -38,6 +38,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.server.RouterFunction;
@@ -82,7 +83,7 @@ public class SpringCloudCircuitBreakerTestConfig {
return Collections.singletonMap("from", "statusCodeFallbackController");
}
@GetMapping("/resetExchangeFallbackController")
@RequestMapping("/resetExchangeFallbackController")
public ResponseEntity<Map<String, String>> resetExchangeFallbackController(ServerWebExchange exchange) {
return ResponseEntity.status(HttpStatus.OK)
.headers((HttpHeaders) exchange.getRequest().getHeaders().entrySet().stream()
@@ -98,10 +99,10 @@ public class SpringCloudCircuitBreakerTestConfig {
@Bean
public RouteLocator circuitBreakerRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("circuitbreaker_fallback_forward", r -> r.host("**.circuitbreakerforward.org")
.filters(f -> f.circuitBreaker(config -> config.setFallbackUri("forward:/fallback"))).uri(uri))
.route("fallback_controller_3",
r -> r.path("/fallback").filters(f -> f.setPath("/circuitbreakerFallbackController3")).uri(uri))
.route("circuitbreaker_fallback_forward", r -> r.host("**.circuitbreakerforward.org")
.filters(f -> f.circuitBreaker(config -> config.setFallbackUri("forward:/fallback"))).uri(uri))
.route("circuitbreaker_java",
r -> r.host("**.circuitbreakerjava.org")
.filters(f -> f.prefixPath("/httpbin").circuitBreaker(

View File

@@ -96,7 +96,7 @@ public class HttpBinCompatibleController {
}
@GetMapping(path = "/delay/{sec}", produces = MediaType.APPLICATION_JSON_VALUE)
public Mono<Map<String, Object>> get(ServerWebExchange exchange, @PathVariable int sec)
public Mono<Map<String, Object>> delay(ServerWebExchange exchange, @PathVariable int sec)
throws InterruptedException {
int delay = Math.min(sec, 10);
return Mono.just(get(exchange)).delayElement(Duration.ofSeconds(delay));
@@ -122,7 +122,7 @@ public class HttpBinCompatibleController {
return result;
}
@GetMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
@PostMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public Mono<Map<String, Object>> postFormData(@RequestBody Mono<MultiValueMap<String, Part>> parts) {
// StringDecoder decoder = StringDecoder.allMimeTypes(true);
@@ -136,7 +136,7 @@ public class HttpBinCompatibleController {
}).map(files -> Collections.singletonMap("files", files));
}
@GetMapping(path = "/post", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
@PostMapping(path = "/post", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public Mono<Map<String, Object>> postUrlEncoded(ServerWebExchange exchange) throws IOException {
return post(exchange, null);