ControllerAdvice resolution detects @Order declared on @Bean method as well
Closes gh-25872
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -199,7 +199,7 @@ public class ControllerAdviceBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void findAnnotatedBeansSortsBeans() {
|
||||
Class[] expectedTypes = {
|
||||
// Since ControllerAdviceBean currently treats PriorityOrdered the same as Ordered,
|
||||
@@ -208,6 +208,7 @@ public class ControllerAdviceBeanTests {
|
||||
PriorityOrderedControllerAdvice.class,
|
||||
OrderAnnotationControllerAdvice.class,
|
||||
PriorityAnnotationControllerAdvice.class,
|
||||
SimpleControllerAdviceWithBeanOrder.class,
|
||||
SimpleControllerAdvice.class,
|
||||
};
|
||||
|
||||
@@ -229,7 +230,7 @@ public class ControllerAdviceBeanTests {
|
||||
assertThat(new ControllerAdviceBean(bean).getOrder()).isEqualTo(expectedOrder);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private void assertOrder(Class beanType, int expectedOrder) {
|
||||
String beanName = "myBean";
|
||||
BeanFactory beanFactory = mock(BeanFactory.class);
|
||||
@@ -261,6 +262,9 @@ public class ControllerAdviceBeanTests {
|
||||
@ControllerAdvice
|
||||
static class SimpleControllerAdvice {}
|
||||
|
||||
@ControllerAdvice
|
||||
static class SimpleControllerAdviceWithBeanOrder {}
|
||||
|
||||
@ControllerAdvice
|
||||
@Order(100)
|
||||
static class OrderAnnotationControllerAdvice {}
|
||||
@@ -321,12 +325,12 @@ public class ControllerAdviceBeanTests {
|
||||
static class MarkerClass {}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
static @interface ControllerAnnotation {}
|
||||
@interface ControllerAnnotation {}
|
||||
|
||||
@ControllerAnnotation
|
||||
public static class AnnotatedController {}
|
||||
|
||||
static interface ControllerInterface {}
|
||||
interface ControllerInterface {}
|
||||
|
||||
static class ImplementationController implements ControllerInterface {}
|
||||
|
||||
@@ -342,6 +346,12 @@ public class ControllerAdviceBeanTests {
|
||||
return new SimpleControllerAdvice();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(300)
|
||||
SimpleControllerAdviceWithBeanOrder simpleControllerAdviceWithBeanOrder() {
|
||||
return new SimpleControllerAdviceWithBeanOrder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
OrderAnnotationControllerAdvice orderAnnotationControllerAdvice() {
|
||||
return new OrderAnnotationControllerAdvice();
|
||||
|
||||
Reference in New Issue
Block a user