|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2015 the original author or authors. |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -66,31 +66,29 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
@Parameters(name = "controller [{0}], auto-proxy [{1}]") |
|
|
|
@Parameters(name = "controller [{0}], auto-proxy [{1}]") |
|
|
|
public static Object[][] handlerTypes() { |
|
|
|
public static Object[][] handlerTypes() { |
|
|
|
return new Object[][] { |
|
|
|
return new Object[][] { |
|
|
|
|
|
|
|
{ SimpleController.class, true }, // CGLIB proxy
|
|
|
|
|
|
|
|
{ SimpleController.class, false }, |
|
|
|
|
|
|
|
|
|
|
|
{ SimpleController.class, true }, // CGLib proxy
|
|
|
|
{ AbstractClassController.class, true }, // CGLIB proxy
|
|
|
|
{ SimpleController.class, false }, |
|
|
|
{ AbstractClassController.class, false }, |
|
|
|
|
|
|
|
|
|
|
|
{ AbstractClassController.class, true }, // CGLib proxy
|
|
|
|
{ ParameterizedAbstractClassController.class, true }, // CGLIB proxy
|
|
|
|
{ AbstractClassController.class, false }, |
|
|
|
{ ParameterizedAbstractClassController.class, false }, |
|
|
|
|
|
|
|
|
|
|
|
{ ParameterizedAbstractClassController.class, true }, // CGLib proxy
|
|
|
|
{ ParameterizedSubclassOverridesDefaultMappings.class, true }, // CGLIB proxy
|
|
|
|
{ ParameterizedAbstractClassController.class, false }, |
|
|
|
{ ParameterizedSubclassOverridesDefaultMappings.class, false }, |
|
|
|
|
|
|
|
|
|
|
|
{ ParameterizedSubclassOverridesDefaultMappings.class, true }, // CGLib proxy
|
|
|
|
// TODO [SPR-9517] Enable ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass test cases
|
|
|
|
{ ParameterizedSubclassOverridesDefaultMappings.class, false }, |
|
|
|
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLIB proxy
|
|
|
|
|
|
|
|
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false },
|
|
|
|
|
|
|
|
|
|
|
|
// TODO [SPR-9517] Enable ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass test cases
|
|
|
|
{ InterfaceController.class, true }, // JDK dynamic proxy
|
|
|
|
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLib proxy
|
|
|
|
{ InterfaceController.class, false }, |
|
|
|
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ InterfaceController.class, true }, // JDK dynamic proxy
|
|
|
|
{ ParameterizedInterfaceController.class, false }, // no AOP
|
|
|
|
{ InterfaceController.class, false }, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ ParameterizedInterfaceController.class, false }, // no AOP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ SupportClassController.class, true }, // CGLib proxy
|
|
|
|
|
|
|
|
{ SupportClassController.class, false } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ SupportClassController.class, true }, // CGLIB proxy
|
|
|
|
|
|
|
|
{ SupportClassController.class, false } |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -100,7 +98,8 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
|
|
|
|
|
|
|
|
private ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver(); |
|
|
|
private ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver(); |
|
|
|
|
|
|
|
|
|
|
|
public HandlerMethodAnnotationDetectionTests(final Class<?> controllerType, boolean useAutoProxy) { |
|
|
|
|
|
|
|
|
|
|
|
public HandlerMethodAnnotationDetectionTests(Class<?> controllerType, boolean useAutoProxy) { |
|
|
|
GenericWebApplicationContext context = new GenericWebApplicationContext(); |
|
|
|
GenericWebApplicationContext context = new GenericWebApplicationContext(); |
|
|
|
context.registerBeanDefinition("controller", new RootBeanDefinition(controllerType)); |
|
|
|
context.registerBeanDefinition("controller", new RootBeanDefinition(controllerType)); |
|
|
|
context.registerBeanDefinition("handlerMapping", new RootBeanDefinition(RequestMappingHandlerMapping.class)); |
|
|
|
context.registerBeanDefinition("handlerMapping", new RootBeanDefinition(RequestMappingHandlerMapping.class)); |
|
|
|
@ -120,12 +119,6 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
context.close(); |
|
|
|
context.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TestPointcut extends StaticMethodMatcherPointcut { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean matches(Method method, @Nullable Class<?> clazz) { |
|
|
|
|
|
|
|
return method.getName().equals("hashCode"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testRequestMappingMethod() throws Exception { |
|
|
|
public void testRequestMappingMethod() throws Exception { |
|
|
|
@ -203,9 +196,9 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* CONTROLLER WITH ABSTRACT CLASS |
|
|
|
* CONTROLLER WITH ABSTRACT CLASS |
|
|
|
* |
|
|
|
|
|
|
|
* <p>All annotations can be on methods in the abstract class except parameter annotations. |
|
|
|
* <p>All annotations can be on methods in the abstract class except parameter annotations. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static class AbstractClassController extends MappingAbstractClass { |
|
|
|
static class AbstractClassController extends MappingAbstractClass { |
|
|
|
@ -232,10 +225,10 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SPR-9374
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SPR-9374
|
|
|
|
@RequestMapping |
|
|
|
@RequestMapping |
|
|
|
static interface MappingInterface { |
|
|
|
interface MappingInterface { |
|
|
|
|
|
|
|
|
|
|
|
@InitBinder |
|
|
|
@InitBinder |
|
|
|
void initBinder(WebDataBinder dataBinder, @RequestParam("datePattern") String thePattern); |
|
|
|
void initBinder(WebDataBinder dataBinder, @RequestParam("datePattern") String thePattern); |
|
|
|
@ -252,14 +245,11 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
String handleException(Exception exception); |
|
|
|
String handleException(Exception exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* CONTROLLER WITH INTERFACE |
|
|
|
* CONTROLLER WITH INTERFACE |
|
|
|
* |
|
|
|
* <p>JDK Dynamic proxy: All annotations must be on the interface. |
|
|
|
* JDK Dynamic proxy: |
|
|
|
* <p>Without AOP: Annotations can be on interface methods except parameter annotations. |
|
|
|
* All annotations must be on the interface. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Without AOP: |
|
|
|
|
|
|
|
* Annotations can be on interface methods except parameter annotations. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static class InterfaceController implements MappingInterface { |
|
|
|
static class InterfaceController implements MappingInterface { |
|
|
|
|
|
|
|
|
|
|
|
@ -304,9 +294,9 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* CONTROLLER WITH PARAMETERIZED BASE CLASS |
|
|
|
* CONTROLLER WITH PARAMETERIZED BASE CLASS |
|
|
|
* |
|
|
|
|
|
|
|
* <p>All annotations can be on methods in the abstract class except parameter annotations. |
|
|
|
* <p>All annotations can be on methods in the abstract class except parameter annotations. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static class ParameterizedAbstractClassController extends MappingGenericAbstractClass<String, Date, Date> { |
|
|
|
static class ParameterizedAbstractClassController extends MappingGenericAbstractClass<String, Date, Date> { |
|
|
|
@ -333,6 +323,7 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
|
static abstract class MappedGenericAbstractClassWithConcreteImplementations<A, B, C> { |
|
|
|
static abstract class MappedGenericAbstractClassWithConcreteImplementations<A, B, C> { |
|
|
|
|
|
|
|
|
|
|
|
@ -353,6 +344,7 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass extends |
|
|
|
static class ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass extends |
|
|
|
MappedGenericAbstractClassWithConcreteImplementations<String, Date, Date> { |
|
|
|
MappedGenericAbstractClassWithConcreteImplementations<String, Date, Date> { |
|
|
|
|
|
|
|
|
|
|
|
@ -375,6 +367,7 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
|
static abstract class GenericAbstractClassDeclaresDefaultMappings<A, B, C> { |
|
|
|
static abstract class GenericAbstractClassDeclaresDefaultMappings<A, B, C> { |
|
|
|
|
|
|
|
|
|
|
|
@ -395,6 +388,7 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
public abstract String handleException(Exception exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class ParameterizedSubclassOverridesDefaultMappings |
|
|
|
static class ParameterizedSubclassOverridesDefaultMappings |
|
|
|
extends GenericAbstractClassDeclaresDefaultMappings<String, Date, Date> { |
|
|
|
extends GenericAbstractClassDeclaresDefaultMappings<String, Date, Date> { |
|
|
|
|
|
|
|
|
|
|
|
@ -425,8 +419,9 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping |
|
|
|
@RequestMapping |
|
|
|
static interface MappingGenericInterface<A, B, C> { |
|
|
|
interface MappingGenericInterface<A, B, C> { |
|
|
|
|
|
|
|
|
|
|
|
@InitBinder |
|
|
|
@InitBinder |
|
|
|
void initBinder(WebDataBinder dataBinder, A thePattern); |
|
|
|
void initBinder(WebDataBinder dataBinder, A thePattern); |
|
|
|
@ -443,11 +438,10 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
String handleException(Exception exception); |
|
|
|
String handleException(Exception exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* CONTROLLER WITH PARAMETERIZED INTERFACE |
|
|
|
* CONTROLLER WITH PARAMETERIZED INTERFACE |
|
|
|
* |
|
|
|
|
|
|
|
* <p>All annotations can be on interface except parameter annotations. |
|
|
|
* <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. |
|
|
|
* <p>Cannot be used as JDK dynamic proxy since parameterized interface does not contain type information. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static class ParameterizedInterfaceController implements MappingGenericInterface<String, Date, Date> { |
|
|
|
static class ParameterizedInterfaceController implements MappingGenericInterface<String, Date, Date> { |
|
|
|
@ -483,7 +477,6 @@ public class HandlerMethodAnnotationDetectionTests { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* SPR-8248 |
|
|
|
* SPR-8248 |
|
|
|
* |
|
|
|
|
|
|
|
* <p>Support class contains all annotations. Subclass has type-level @{@link RequestMapping}. |
|
|
|
* <p>Support class contains all annotations. Subclass has type-level @{@link RequestMapping}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Controller |
|
|
|
@Controller |
|
|
|
|