Merge branch '6.1.x'

This commit is contained in:
Stéphane Nicoll
2024-04-23 15:25:20 +02:00
2 changed files with 38 additions and 11 deletions

View File

@@ -42,6 +42,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.http.HttpEntity;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Controller;
import org.springframework.util.MultiValueMap;
@@ -334,6 +335,14 @@ public class MvcUriComponentsBuilderTests {
assertThat(uriComponents.toUriString()).isEqualTo("http://localhost/something/custom/1/foo");
}
@Test
void fromMethodNameWithAnnotationsOnInterface() {
initWebApplicationContext(WebConfig.class);
UriComponents uriComponents = fromMethodName(HelloController.class, "get", "test").build();
assertThat(uriComponents.toString()).isEqualTo("http://localhost/hello/test");
}
@Test
void fromMethodCallOnSubclass() {
UriComponents uriComponents = fromMethodCall(on(ExtendedController.class).myMethod(null)).build();
@@ -855,4 +864,20 @@ public class MvcUriComponentsBuilderTests {
}
}
interface HelloInterface {
@GetMapping("/hello/{name}")
ResponseEntity<String> get(@PathVariable String name);
}
@Controller
static class HelloController implements HelloInterface {
@Override
public ResponseEntity<String> get(String name) {
return ResponseEntity.ok("Hello " + name);
}
}
}