diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java index 838b9ccec7..68137b61ca 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java @@ -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(); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java index 17e13829c2..0150754567 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java @@ -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 {}; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index d093d438b7..3ab1e7d015 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -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 {}; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java index 4fbc1fb2b6..a8676e55c8 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java @@ -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(); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index b121cbb779..012da18142 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -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(); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 556c7c6843..ac669cb1ba 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -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 ""; } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 7b0c51d00f..307ee7b164 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -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 ""; } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java b/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java index c69188efcc..c3fa70caad 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java @@ -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 ""; } diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index fbe34d103e..d271c2abb7 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -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 {}; } diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java index aa02845750..9abd2fb27c 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java @@ -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(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java index dc49c0a539..182504eeed 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java @@ -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 {}; }