Stop using convention-based annotation attribute overrides in tests
This commit replaces convention-based annotation attribute overrides in tests with explicit use of @AliasFor -- except for tests in spring-core, since we still want to test our support for convention-based annotation attribute overrides. See gh-28760
This commit is contained in:
parent
6812de7b82
commit
73d92d66b9
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
|
@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
||||
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
|
||||
|
|
@ -139,6 +140,7 @@ public class AnnotationScopeMetadataResolverTests {
|
|||
@Scope("request")
|
||||
@interface CustomRequestScopeWithAttributeOverride {
|
||||
|
||||
@AliasFor(annotation = Scope.class)
|
||||
ScopedProxyMode proxyMode();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
|
@ -52,6 +52,7 @@ import org.springframework.context.annotation.componentscan.simple.ClassWithNest
|
|||
import org.springframework.context.annotation.componentscan.simple.SimpleComponent;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.context.testfixture.SimpleMapScope;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.Profiles;
|
||||
|
|
@ -274,6 +275,7 @@ public class ComponentScanAnnotationIntegrationTests {
|
|||
@Target(ElementType.TYPE)
|
||||
public @interface ComposedConfiguration {
|
||||
|
||||
@AliasFor(annotation = ComponentScan.class)
|
||||
String[] basePackages() default {};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import org.springframework.beans.testfixture.beans.TestBean;
|
|||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.componentscan.simple.SimpleComponent;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
|
@ -1471,6 +1472,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Scope(scopeName = "prototype")
|
||||
public @interface PrototypeScoped {
|
||||
|
||||
@AliasFor(annotation = Scope.class)
|
||||
ScopedProxyMode proxyMode() default ScopedProxyMode.TARGET_CLASS;
|
||||
}
|
||||
|
||||
|
|
@ -1628,8 +1630,10 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Target(ElementType.TYPE)
|
||||
public @interface ComposedConfigurationWithAttributeOverrides {
|
||||
|
||||
@AliasFor(annotation = ComponentScan.class)
|
||||
String[] basePackages() default {};
|
||||
|
||||
@AliasFor(annotation = ComponentScan.class)
|
||||
ComponentScan.Filter[] excludeFilters() default {};
|
||||
}
|
||||
|
||||
|
|
@ -1656,6 +1660,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Target(ElementType.TYPE)
|
||||
public @interface ComposedComposedConfigurationWithAttributeOverrides {
|
||||
|
||||
@AliasFor(annotation = ComposedConfigurationWithAttributeOverrides.class)
|
||||
String[] basePackages() default {};
|
||||
}
|
||||
|
||||
|
|
@ -1675,6 +1680,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Target(ElementType.TYPE)
|
||||
public @interface MetaComponentScanConfigurationWithAttributeOverrides {
|
||||
|
||||
@AliasFor(annotation = ComponentScan.class)
|
||||
String[] basePackages() default {};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -259,6 +260,7 @@ class BeanMethodQualificationTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface InterestingBeanWithName {
|
||||
|
||||
@AliasFor(annotation = Bean.class)
|
||||
String name();
|
||||
}
|
||||
|
||||
|
|
@ -271,6 +273,7 @@ class BeanMethodQualificationTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface InterestingNeedWithRequiredOverride {
|
||||
|
||||
@AliasFor(annotation = Autowired.class)
|
||||
boolean required();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1061,6 +1061,8 @@ class AnnotatedElementUtilsTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface ConventionBasedComposedContextConfig {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfig.class)
|
||||
String[] locations() default {};
|
||||
}
|
||||
|
||||
|
|
@ -1068,6 +1070,8 @@ class AnnotatedElementUtilsTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface InvalidConventionBasedComposedContextConfig {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfig.class)
|
||||
String[] locations();
|
||||
}
|
||||
|
||||
|
|
@ -1225,9 +1229,13 @@ class AnnotatedElementUtilsTests {
|
|||
@AliasFor(annotation = ContextConfig.class, attribute = "locations")
|
||||
String[] locations() default {};
|
||||
|
||||
// Do NOT use @AliasFor(annotation = ...) here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfig.class, attribute = "classes")
|
||||
@AliasFor("value")
|
||||
Class<?>[] classes() default {};
|
||||
|
||||
// Do NOT use @AliasFor(annotation = ...) here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfig.class, attribute = "classes")
|
||||
@AliasFor("classes")
|
||||
Class<?>[] value() default {};
|
||||
}
|
||||
|
|
@ -1266,6 +1274,8 @@ class AnnotatedElementUtilsTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface ConventionBasedSinglePackageComponentScan {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ComponentScan.class)
|
||||
String basePackages();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1367,6 +1367,8 @@ class AnnotationUtilsTests {
|
|||
@WebMapping(method = RequestMethod.POST, name = "")
|
||||
@interface Post {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = WebMapping.class)
|
||||
String path() default "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2425,6 +2425,8 @@ class MergedAnnotationsTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface ConventionBasedComposedContextConfiguration {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfiguration.class)
|
||||
String[] locations() default {};
|
||||
}
|
||||
|
||||
|
|
@ -2432,6 +2434,8 @@ class MergedAnnotationsTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface InvalidConventionBasedComposedContextConfiguration {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfiguration.class)
|
||||
String[] locations();
|
||||
}
|
||||
|
||||
|
|
@ -2443,6 +2447,8 @@ class MergedAnnotationsTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface HalfConventionBasedAndHalfAliasedComposedContextConfiguration {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfiguration.class)
|
||||
String[] locations() default {};
|
||||
|
||||
@AliasFor(annotation = ContextConfiguration.class, attribute = "locations")
|
||||
|
|
@ -2564,9 +2570,13 @@ class MergedAnnotationsTests {
|
|||
@AliasFor(annotation = ContextConfiguration.class, attribute = "locations")
|
||||
String[] locations() default {};
|
||||
|
||||
// Do NOT use @AliasFor(annotation = ...) here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfiguration.class, attribute = "classes")
|
||||
@AliasFor("value")
|
||||
Class<?>[] classes() default {};
|
||||
|
||||
// Do NOT use @AliasFor(annotation = ...) here until Spring 6.1
|
||||
// @AliasFor(annotation = ContextConfiguration.class, attribute = "classes")
|
||||
@AliasFor("classes")
|
||||
Class<?>[] value() default {};
|
||||
}
|
||||
|
|
@ -2603,6 +2613,8 @@ class MergedAnnotationsTests {
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface ConventionBasedSinglePackageComponentScan {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ComponentScan.class)
|
||||
String basePackages();
|
||||
}
|
||||
|
||||
|
|
@ -3193,6 +3205,8 @@ class MergedAnnotationsTests {
|
|||
@RequestMapping(method = RequestMethod.POST, name = "")
|
||||
@interface PostMapping {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = RequestMapping.class)
|
||||
String path() default "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -196,6 +196,8 @@ class TypeMappedAnnotationTests {
|
|||
|
||||
String value() default "";
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = ConventionAliasMetaAnnotationTarget.class)
|
||||
String convention() default "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -549,6 +549,8 @@ class AnnotationMetadataTests {
|
|||
@Target(ElementType.TYPE)
|
||||
public @interface ComposedConfigurationWithAttributeOverrides {
|
||||
|
||||
// Do NOT use @AliasFor here until Spring 6.1
|
||||
// @AliasFor(annotation = TestComponentScan.class)
|
||||
String[] basePackages() default {};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
|
@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.testfixture.io.SerializationTestUtils;
|
||||
import org.springframework.transaction.TransactionManager;
|
||||
|
|
@ -668,6 +669,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
|||
@Transactional(rollbackFor = Exception.class, noRollbackFor = IOException.class)
|
||||
@interface TxWithAttribute {
|
||||
|
||||
@AliasFor(annotation = Transactional.class)
|
||||
boolean readOnly();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
|
|
@ -32,6 +32,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
||||
import org.springframework.http.HttpEntity;
|
||||
|
|
@ -635,6 +636,7 @@ public class MvcUriComponentsBuilderTests {
|
|||
@Documented
|
||||
private @interface PostJson {
|
||||
|
||||
@AliasFor(annotation = RequestMapping.class)
|
||||
String[] path() default {};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue