diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilterTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilterTests.java index a75c89d0..cf927f3b 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilterTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/GatewayMetricsFilterTests.java @@ -36,7 +36,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -119,7 +119,7 @@ public class GatewayMetricsFilterTests extends BaseWebClientTests { .build(); } - @RequestMapping("/httpbin/badtargeturi") + @GetMapping("/httpbin/badtargeturi") public String exception() { throw new RuntimeException("an error"); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/RetryGatewayFilterFactoryIntegrationTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/RetryGatewayFilterFactoryIntegrationTests.java index 16b9ad8d..46e76748 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/RetryGatewayFilterFactoryIntegrationTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/RetryGatewayFilterFactoryIntegrationTests.java @@ -53,8 +53,8 @@ import org.springframework.http.HttpStatus; 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.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -211,7 +211,7 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest @Value("${test.uri}") private String uri; - @RequestMapping("/httpbin/sleep") + @GetMapping("/httpbin/sleep") public Mono> sleep(@RequestParam("key") String key, @RequestParam("millis") long millisToSleep) { AtomicInteger num = getCount(key); @@ -221,7 +221,7 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest .header("X-Retry-Count", String.valueOf(retryCount)).body("slept " + millisToSleep + " ms")); } - @RequestMapping("/httpbin/retryalwaysfail") + @GetMapping("/httpbin/retryalwaysfail") public ResponseEntity retryalwaysfail(@RequestParam("key") String key, @RequestParam(name = "count", defaultValue = "3") int count) { AtomicInteger num = getCount(key); @@ -231,7 +231,7 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest .body("permanently broken"); } - @RequestMapping("/httpbin/retrypost") + @GetMapping("/httpbin/retrypost") public ResponseEntity retrypost(@RequestParam("key") String key, @RequestParam(name = "count", defaultValue = "3") int count, @RequestParam("expectedbody") String expectedbody, @RequestBody String body) { @@ -244,7 +244,7 @@ public class RetryGatewayFilterFactoryIntegrationTests extends BaseWebClientTest return response; } - @RequestMapping("/httpbin/retry") + @GetMapping("/httpbin/retry") public ResponseEntity retry(@RequestParam("key") String key, @RequestParam(name = "count", defaultValue = "3") int count, @RequestParam(name = "failStatus", required = false) Integer failStatus) { diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerTestConfig.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerTestConfig.java index 73d1bc4e..80712f5e 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerTestConfig.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory/SpringCloudCircuitBreakerTestConfig.java @@ -37,7 +37,7 @@ import org.springframework.context.annotation.Import; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.function.server.RouterFunction; @@ -62,27 +62,27 @@ public class SpringCloudCircuitBreakerTestConfig { @Value("${test.uri}") private String uri; - @RequestMapping("/circuitbreakerFallbackController") + @GetMapping("/circuitbreakerFallbackController") public Map fallbackcontroller(@RequestParam("a") String a) { return Collections.singletonMap("from", "circuitbreakerfallbackcontroller"); } - @RequestMapping("/circuitbreakerFallbackController2") + @GetMapping("/circuitbreakerFallbackController2") public Map fallbackcontroller2() { return Collections.singletonMap("from", "circuitbreakerfallbackcontroller2"); } - @RequestMapping("/circuitbreakerFallbackController3") + @GetMapping("/circuitbreakerFallbackController3") public Map fallbackcontroller3() { return Collections.singletonMap("from", "circuitbreakerfallbackcontroller3"); } - @RequestMapping("/statusCodeFallbackController") + @GetMapping("/statusCodeFallbackController") public Map statusCodeFallbackController(ServerWebExchange exchange) { return Collections.singletonMap("from", "statusCodeFallbackController"); } - @RequestMapping("/resetExchangeFallbackController") + @GetMapping("/resetExchangeFallbackController") public ResponseEntity> resetExchangeFallbackController(ServerWebExchange exchange) { return ResponseEntity.status(HttpStatus.OK) .headers((HttpHeaders) exchange.getRequest().getHeaders().entrySet().stream() diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/PrincipalNameKeyResolverIntegrationTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/PrincipalNameKeyResolverIntegrationTests.java index 50a09964..201b547c 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/PrincipalNameKeyResolverIntegrationTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/PrincipalNameKeyResolverIntegrationTests.java @@ -46,6 +46,7 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.SocketUtils; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -96,7 +97,7 @@ public class PrincipalNameKeyResolverIntegrationTests { @Value("${server.port}") private int port; - @RequestMapping("/myapi/{id}") + @GetMapping("/myapi/{id}") public Map myapi(@PathVariable String id, Principal principal) { return Collections.singletonMap(principal.getName(), id); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ForwardTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ForwardTests.java index 8c455f4a..5586ea2e 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ForwardTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ForwardTests.java @@ -32,7 +32,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.WebTestClient; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -72,7 +72,7 @@ public class ForwardTests { @Import(PermitAllSecurityConfiguration.class) public static class TestConfig { - @RequestMapping("/httpbin/localcontroller") + @GetMapping("/httpbin/localcontroller") public Map localController() { return Collections.singletonMap("from", "localcontroller"); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/GatewayIntegrationTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/GatewayIntegrationTests.java index 5a5620be..711f916c 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/GatewayIntegrationTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/GatewayIntegrationTests.java @@ -49,7 +49,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ServerWebExchange; @@ -174,7 +174,7 @@ class GatewayIntegrationTests extends BaseWebClientTests { return Mono.empty(); } - @RequestMapping("/httpbin/nocontenttype") + @GetMapping("/httpbin/nocontenttype") ResponseEntity nocontenttype() { return ResponseEntity.status(204).build(); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpBinCompatibleController.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpBinCompatibleController.java index 381f6ec3..5b9a990c 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpBinCompatibleController.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpBinCompatibleController.java @@ -45,7 +45,10 @@ import org.springframework.http.codec.multipart.Part; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.util.FileCopyUtils; import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; +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.RequestMethod; @@ -60,7 +63,7 @@ public class HttpBinCompatibleController { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - @RequestMapping("/") + @GetMapping("/") public String home() { return "httpbin compatible home"; } @@ -73,7 +76,7 @@ public class HttpBinCompatibleController { return result; } - @RequestMapping(path = "/headers", method = RequestMethod.PATCH) + @PatchMapping("/headers") public ResponseEntity> headersPatch(ServerWebExchange exchange, @RequestBody Map headersToAdd) { Map result = new HashMap<>(); @@ -92,19 +95,19 @@ public class HttpBinCompatibleController { return result; } - @RequestMapping(path = "/delay/{sec}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/delay/{sec}", produces = MediaType.APPLICATION_JSON_VALUE) public Mono> get(ServerWebExchange exchange, @PathVariable int sec) throws InterruptedException { int delay = Math.min(sec, 10); return Mono.just(get(exchange)).delayElement(Duration.ofSeconds(delay)); } - @RequestMapping(path = "/anything/{anything}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/anything/{anything}", produces = MediaType.APPLICATION_JSON_VALUE) public Map anything(ServerWebExchange exchange, @PathVariable(required = false) String anything) { return get(exchange); } - @RequestMapping(path = "/get", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/get", produces = MediaType.APPLICATION_JSON_VALUE) public Map get(ServerWebExchange exchange) { if (log.isDebugEnabled()) { log.debug("httpbin /get"); @@ -119,7 +122,7 @@ public class HttpBinCompatibleController { return result; } - @RequestMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, + @GetMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public Mono> postFormData(@RequestBody Mono> parts) { // StringDecoder decoder = StringDecoder.allMimeTypes(true); @@ -133,13 +136,13 @@ public class HttpBinCompatibleController { }).map(files -> Collections.singletonMap("files", files)); } - @RequestMapping(path = "/post", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, + @GetMapping(path = "/post", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public Mono> postUrlEncoded(ServerWebExchange exchange) throws IOException { return post(exchange, null); } - @RequestMapping(path = "/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(path = "/post", produces = MediaType.APPLICATION_JSON_VALUE) public Mono> post(ServerWebExchange exchange, @RequestBody(required = false) String body) throws IOException { HashMap ret = new HashMap<>(); @@ -158,7 +161,7 @@ public class HttpBinCompatibleController { }); } - @RequestMapping("/status/{status}") + @GetMapping("/status/{status}") public ResponseEntity status(@PathVariable int status) { return ResponseEntity.status(status).body("Failed with " + status); } @@ -174,12 +177,12 @@ public class HttpBinCompatibleController { return ResponseEntity.status(status).headers(httpHeaders).body(Collections.singletonMap("status", status)); } - @RequestMapping(path = "/post/empty", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(path = "/post/empty", produces = MediaType.APPLICATION_JSON_VALUE) public Mono emptyResponse() { return Mono.empty(); } - @RequestMapping(path = "/gzip", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/gzip", produces = MediaType.APPLICATION_JSON_VALUE) public Mono gzip(ServerWebExchange exchange) throws IOException { if (log.isDebugEnabled()) { log.debug("httpbin /gzip"); diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpStatusTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpStatusTests.java index 11b0c574..87fd38ea 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpStatusTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/HttpStatusTests.java @@ -29,7 +29,7 @@ import org.springframework.context.annotation.Import; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -82,7 +82,7 @@ public class HttpStatusTests extends BaseWebClientTests { @Import(DefaultTestConfig.class) static class TestConfig { - @RequestMapping("/httpbin/exception") + @GetMapping("/httpbin/exception") String exception() { throw new RuntimeException("an error"); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java index 101a4b9e..718a9cda 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/sse/SseIntegrationTests.java @@ -44,7 +44,7 @@ import org.springframework.core.ResolvableType; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.server.reactive.HttpHandler; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.DispatcherHandler; import org.springframework.web.reactive.config.EnableWebFlux; @@ -189,17 +189,17 @@ public class SseIntegrationTests { private static final Flux INTERVAL = interval(Duration.ofMillis(100), 50); - @RequestMapping("/sse/string") + @GetMapping("/sse/string") Flux string() { return INTERVAL.map(l -> "foo " + l); } - @RequestMapping("/sse/person") + @GetMapping("/sse/person") Flux person() { return INTERVAL.map(l -> new Person("foo " + l)); } - @RequestMapping("/sse/event") + @GetMapping("/sse/event") Flux> sse() { return INTERVAL.map(l -> ServerSentEvent.builder("foo").id(Long.toString(l)).comment("bar").build()); } diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java index cfc7d11c..15289a0f 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java @@ -34,7 +34,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -68,7 +68,7 @@ public class SingleCertSSLTests extends BaseWebClientTests { @RestController public static class TestConfig { - @RequestMapping("/httpbin/ssltrust") + @GetMapping("/httpbin/ssltrust") public ResponseEntity nocontenttype() { return ResponseEntity.status(204).build(); }