SPR-13033: Use @RequestMapping of correct class

MvcUriComponentsBuilder::fromMethodCall creates wrong URLs with derived
controller classes. The @RequestMapping of the declaring class of the
method that is called is used instead of the @RequstMapping of the
given controller class.

https://jira.spring.io/browse/SPR-13033
This commit is contained in:
james
2015-05-15 22:34:59 +02:00
committed by Rossen Stoyanchev
parent 5e8d838334
commit e41877d64e
2 changed files with 33 additions and 3 deletions

View File

@@ -229,6 +229,14 @@ public class MvcUriComponentsBuilderTests {
assertThat(uriComponents.toUriString(), endsWith("/something/else"));
}
@Test
public void testFromMethodCallOnSubclass() {
UriComponents uriComponents = fromMethodCall(on(ExtendedController.class).myMethod(null)).build();
assertThat(uriComponents.toUriString(), startsWith("http://localhost"));
assertThat(uriComponents.toUriString(), endsWith("/extended/else"));
}
@Test
public void testFromMethodCallWithTypeLevelUriVars() {
UriComponents uriComponents = fromMethodCall(on(
@@ -418,6 +426,11 @@ public class MvcUriComponentsBuilderTests {
}
}
@RequestMapping("/extended")
static class ExtendedController extends ControllerWithMethods {
}
@RequestMapping("/user/{userId}/contacts")
static class UserContactController {