Detect ControllerAdvice beans in ancestor contexts as well
Issue: SPR-11570
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.method;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -83,18 +100,17 @@ public class ControllerAdviceBeanTests {
|
||||
assertNotApplicable("should not match", bean, InheritanceController.class);
|
||||
}
|
||||
|
||||
private void assertApplicable(String message, ControllerAdviceBean controllerAdvice,
|
||||
Class<?> controllerBeanType) {
|
||||
private void assertApplicable(String message, ControllerAdviceBean controllerAdvice, Class<?> controllerBeanType) {
|
||||
assertNotNull(controllerAdvice);
|
||||
assertTrue(message,controllerAdvice.isApplicableToBeanType(controllerBeanType));
|
||||
}
|
||||
|
||||
private void assertNotApplicable(String message, ControllerAdviceBean controllerAdvice,
|
||||
Class<?> controllerBeanType) {
|
||||
private void assertNotApplicable(String message, ControllerAdviceBean controllerAdvice, Class<?> controllerBeanType) {
|
||||
assertNotNull(controllerAdvice);
|
||||
assertFalse(message,controllerAdvice.isApplicableToBeanType(controllerBeanType));
|
||||
}
|
||||
|
||||
|
||||
// ControllerAdvice classes
|
||||
|
||||
@ControllerAdvice
|
||||
@@ -139,4 +155,5 @@ public class ControllerAdviceBeanTests {
|
||||
static abstract class AbstractController {}
|
||||
|
||||
static class InheritanceController extends AbstractController {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user