Polishing

This commit is contained in:
Juergen Hoeller
2018-08-08 23:56:17 +02:00
parent 247ec572b2
commit 7cf98261ce
7 changed files with 77 additions and 54 deletions

View File

@@ -67,20 +67,20 @@ public class HandlerMethodAnnotationDetectionTests {
public static Object[][] handlerTypes() {
return new Object[][] {
{ SimpleController.class, true }, // CGLib proxy
{ SimpleController.class, true }, // CGLIB proxy
{ SimpleController.class, false },
{ AbstractClassController.class, true }, // CGLib proxy
{ AbstractClassController.class, true }, // CGLIB proxy
{ AbstractClassController.class, false },
{ ParameterizedAbstractClassController.class, true }, // CGLib proxy
{ ParameterizedAbstractClassController.class, true }, // CGLIB proxy
{ ParameterizedAbstractClassController.class, false },
{ ParameterizedSubclassOverridesDefaultMappings.class, true }, // CGLib proxy
{ ParameterizedSubclassOverridesDefaultMappings.class, true }, // CGLIB proxy
{ ParameterizedSubclassOverridesDefaultMappings.class, false },
// TODO [SPR-9517] Enable ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass test cases
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLib proxy
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, true }, // CGLIB proxy
// { ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass.class, false },
{ InterfaceController.class, true }, // JDK dynamic proxy
@@ -88,7 +88,7 @@ public class HandlerMethodAnnotationDetectionTests {
{ ParameterizedInterfaceController.class, false }, // no AOP
{ SupportClassController.class, true }, // CGLib proxy
{ SupportClassController.class, true }, // CGLIB proxy
{ SupportClassController.class, false }
};
@@ -100,7 +100,8 @@ public class HandlerMethodAnnotationDetectionTests {
private ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver();
public HandlerMethodAnnotationDetectionTests(final Class<?> controllerType, boolean useAutoProxy) {
public HandlerMethodAnnotationDetectionTests(Class<?> controllerType, boolean useAutoProxy) {
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.registerBeanDefinition("controller", new RootBeanDefinition(controllerType));
context.registerBeanDefinition("handlerMapping", new RootBeanDefinition(RequestMappingHandlerMapping.class));
@@ -120,12 +121,6 @@ public class HandlerMethodAnnotationDetectionTests {
context.close();
}
class TestPointcut extends StaticMethodMatcherPointcut {
@Override
public boolean matches(Method method, @Nullable Class<?> clazz) {
return method.getName().equals("hashCode");
}
}
@Test
public void testRequestMappingMethod() throws Exception {
@@ -203,9 +198,9 @@ public class HandlerMethodAnnotationDetectionTests {
public abstract String handleException(Exception exception);
}
/**
* CONTROLLER WITH ABSTRACT CLASS
*
* <p>All annotations can be on methods in the abstract class except parameter annotations.
*/
static class AbstractClassController extends MappingAbstractClass {
@@ -232,10 +227,10 @@ public class HandlerMethodAnnotationDetectionTests {
}
}
// SPR-9374
// SPR-9374
@RequestMapping
static interface MappingInterface {
interface MappingInterface {
@InitBinder
void initBinder(WebDataBinder dataBinder, @RequestParam("datePattern") String thePattern);
@@ -252,14 +247,11 @@ public class HandlerMethodAnnotationDetectionTests {
String handleException(Exception exception);
}
/**
* CONTROLLER WITH INTERFACE
*
* JDK Dynamic proxy:
* All annotations must be on the interface.
*
* Without AOP:
* Annotations can be on interface methods except parameter annotations.
* <p>JDK Dynamic proxy: All annotations must be on the interface.
* <p>Without AOP: Annotations can be on interface methods except parameter annotations.
*/
static class InterfaceController implements MappingInterface {
@@ -304,9 +296,9 @@ public class HandlerMethodAnnotationDetectionTests {
public abstract String handleException(Exception exception);
}
/**
* CONTROLLER WITH PARAMETERIZED BASE CLASS
*
* <p>All annotations can be on methods in the abstract class except parameter annotations.
*/
static class ParameterizedAbstractClassController extends MappingGenericAbstractClass<String, Date, Date> {
@@ -333,6 +325,7 @@ public class HandlerMethodAnnotationDetectionTests {
}
}
@Controller
static abstract class MappedGenericAbstractClassWithConcreteImplementations<A, B, C> {
@@ -353,6 +346,7 @@ public class HandlerMethodAnnotationDetectionTests {
public abstract String handleException(Exception exception);
}
static class ParameterizedSubclassDoesNotOverrideConcreteImplementationsFromGenericAbstractSuperclass extends
MappedGenericAbstractClassWithConcreteImplementations<String, Date, Date> {
@@ -375,6 +369,7 @@ public class HandlerMethodAnnotationDetectionTests {
}
}
@Controller
static abstract class GenericAbstractClassDeclaresDefaultMappings<A, B, C> {
@@ -395,6 +390,7 @@ public class HandlerMethodAnnotationDetectionTests {
public abstract String handleException(Exception exception);
}
static class ParameterizedSubclassOverridesDefaultMappings
extends GenericAbstractClassDeclaresDefaultMappings<String, Date, Date> {
@@ -425,8 +421,9 @@ public class HandlerMethodAnnotationDetectionTests {
}
}
@RequestMapping
static interface MappingGenericInterface<A, B, C> {
interface MappingGenericInterface<A, B, C> {
@InitBinder
void initBinder(WebDataBinder dataBinder, A thePattern);
@@ -443,11 +440,10 @@ public class HandlerMethodAnnotationDetectionTests {
String handleException(Exception exception);
}
/**
* CONTROLLER WITH PARAMETERIZED INTERFACE
*
* <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.
*/
static class ParameterizedInterfaceController implements MappingGenericInterface<String, Date, Date> {
@@ -483,7 +479,6 @@ public class HandlerMethodAnnotationDetectionTests {
/**
* SPR-8248
*
* <p>Support class contains all annotations. Subclass has type-level @{@link RequestMapping}.
*/
@Controller