Method level only, empty RequestMapping matches "" and "/"

Closes gh-30293
This commit is contained in:
rstoyanchev
2023-06-12 16:09:49 +01:00
parent 3fb98b6a97
commit bbab4faf7a
7 changed files with 53 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,15 +48,12 @@ public class DefaultControllerSpecTests {
.exchange()
.expectStatus().isOk()
.expectBody(String.class).isEqualTo("Success");
}
@Test
public void controllerEmptyPath() {
new DefaultControllerSpec(new MyController()).build()
.get().uri("")
.exchange()
.expectStatus().isOk()
.expectBody(String.class).isEqualTo("Success empty path");
.expectBody(String.class).isEqualTo("Success");
}
@Test
@@ -121,19 +118,15 @@ public class DefaultControllerSpecTests {
}
@SuppressWarnings("unused")
@RestController
private static class MyController {
@GetMapping("/")
@GetMapping
public String handleRootPath() {
return "Success";
}
@GetMapping
public String handleEmptyPath() {
return "Success empty path";
}
@GetMapping("/exception")
public void handleWithError() {
throw new IllegalStateException();