Require type-level @Controller annotation
Closes gh-22154
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -78,7 +78,7 @@ class HandlerMethodAnnotationDetectionTests {
|
||||
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLIB proxy
|
||||
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false },
|
||||
|
||||
{ InterfaceController.class, true }, // JDK dynamic proxy
|
||||
// { InterfaceController.class, true }, // JDK dynamic proxy (gh-22154: no longer supported))
|
||||
{ InterfaceController.class, false },
|
||||
|
||||
{ ParameterizedInterfaceController.class, false }, // no AOP
|
||||
@@ -250,6 +250,7 @@ class HandlerMethodAnnotationDetectionTests {
|
||||
* <p>JDK Dynamic proxy: All annotations must be on the interface.
|
||||
* <p>Without AOP: Annotations can be on interface methods except parameter annotations.
|
||||
*/
|
||||
@Controller
|
||||
static class InterfaceController implements MappingInterface {
|
||||
|
||||
@Override
|
||||
@@ -443,6 +444,7 @@ class HandlerMethodAnnotationDetectionTests {
|
||||
* <p>All annotations can be on interface except parameter annotations.
|
||||
* <p>Cannot be used as JDK dynamic proxy since parameterized interface does not contain type information.
|
||||
*/
|
||||
@Controller
|
||||
static class ParameterizedInterfaceController implements MappingGenericInterface<String, Date, Date> {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,6 +77,7 @@ import static org.springframework.web.servlet.mvc.method.annotation.MvcUriCompon
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class MvcUriComponentsBuilderTests {
|
||||
|
||||
private final MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
@@ -455,7 +456,8 @@ public class MvcUriComponentsBuilderTests {
|
||||
this.request.setServerPort(9999);
|
||||
this.request.setContextPath("/base");
|
||||
|
||||
assertThat(fromController(PersonsAddressesController.class).buildAndExpand("123").toString()).isEqualTo("https://example.org:9999/base/api/people/123/addresses");
|
||||
assertThat(fromController(PersonsAddressesController.class).buildAndExpand("123").toString())
|
||||
.isEqualTo("https://example.org:9999/base/api/people/123/addresses");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -468,8 +470,12 @@ public class MvcUriComponentsBuilderTests {
|
||||
this.request.setServerPort(9999);
|
||||
this.request.setContextPath("/base");
|
||||
|
||||
assertThat(fromMethodCall(on(PersonsAddressesController.class).getAddressesForCountry("DE"))
|
||||
.buildAndExpand("123").toString()).isEqualTo("https://example.org:9999/base/api/people/123/addresses/DE");
|
||||
String url = fromMethodCall(on(PersonsAddressesController.class)
|
||||
.getAddressesForCountry("DE"))
|
||||
.buildAndExpand("123")
|
||||
.toString();
|
||||
|
||||
assertThat(url).isEqualTo("https://example.org:9999/base/api/people/123/addresses/DE");
|
||||
}
|
||||
|
||||
private void initWebApplicationContext(Class<?> configClass) {
|
||||
@@ -500,6 +506,7 @@ public class MvcUriComponentsBuilderTests {
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/people/{id}/addresses")
|
||||
static class PersonsAddressesController {
|
||||
|
||||
@@ -509,6 +516,7 @@ public class MvcUriComponentsBuilderTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Controller
|
||||
@RequestMapping({"people"})
|
||||
static class PathWithoutLeadingSlashController {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user