Fix deprecated StandardAnnotationMetadata usages
Closes gh-16930
This commit is contained in:
parent
9ba5c78878
commit
27ca7e17d9
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
||||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
|
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
import org.springframework.core.type.AnnotationMetadata;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class ManagementContextConfigurationImportSelectorTests {
|
||||||
public void selectImportsShouldOrderResult() {
|
public void selectImportsShouldOrderResult() {
|
||||||
String[] imports = new TestManagementContextConfigurationsImportSelector(C.class,
|
String[] imports = new TestManagementContextConfigurationsImportSelector(C.class,
|
||||||
A.class, D.class, B.class).selectImports(
|
A.class, D.class, B.class).selectImports(
|
||||||
new StandardAnnotationMetadata(EnableChildContext.class));
|
AnnotationMetadata.introspect(EnableChildContext.class));
|
||||||
assertThat(imports).containsExactly(A.class.getName(), B.class.getName(),
|
assertThat(imports).containsExactly(A.class.getName(), B.class.getName(),
|
||||||
C.class.getName(), D.class.getName());
|
C.class.getName(), D.class.getName());
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class ManagementContextConfigurationImportSelectorTests {
|
||||||
public void selectImportsFiltersChildOnlyConfigurationWhenUsingSameContext() {
|
public void selectImportsFiltersChildOnlyConfigurationWhenUsingSameContext() {
|
||||||
String[] imports = new TestManagementContextConfigurationsImportSelector(
|
String[] imports = new TestManagementContextConfigurationsImportSelector(
|
||||||
ChildOnly.class, SameOnly.class, A.class).selectImports(
|
ChildOnly.class, SameOnly.class, A.class).selectImports(
|
||||||
new StandardAnnotationMetadata(EnableSameContext.class));
|
AnnotationMetadata.introspect(EnableSameContext.class));
|
||||||
assertThat(imports).containsExactlyInAnyOrder(SameOnly.class.getName(),
|
assertThat(imports).containsExactlyInAnyOrder(SameOnly.class.getName(),
|
||||||
A.class.getName());
|
A.class.getName());
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class ManagementContextConfigurationImportSelectorTests {
|
||||||
public void selectImportsFiltersSameOnlyConfigurationWhenUsingChildContext() {
|
public void selectImportsFiltersSameOnlyConfigurationWhenUsingChildContext() {
|
||||||
String[] imports = new TestManagementContextConfigurationsImportSelector(
|
String[] imports = new TestManagementContextConfigurationsImportSelector(
|
||||||
ChildOnly.class, SameOnly.class, A.class).selectImports(
|
ChildOnly.class, SameOnly.class, A.class).selectImports(
|
||||||
new StandardAnnotationMetadata(EnableChildContext.class));
|
AnnotationMetadata.introspect(EnableChildContext.class));
|
||||||
assertThat(imports).containsExactlyInAnyOrder(ChildOnly.class.getName(),
|
assertThat(imports).containsExactlyInAnyOrder(ChildOnly.class.getName(),
|
||||||
A.class.getName());
|
A.class.getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.core.type.AnnotationMetadata;
|
import org.springframework.core.type.AnnotationMetadata;
|
||||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
|
||||||
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
|
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
|
||||||
import org.springframework.data.repository.config.BootstrapMode;
|
import org.springframework.data.repository.config.BootstrapMode;
|
||||||
import org.springframework.data.repository.config.RepositoryConfigurationDelegate;
|
import org.springframework.data.repository.config.RepositoryConfigurationDelegate;
|
||||||
|
@ -66,8 +65,7 @@ public abstract class AbstractRepositoryConfigurationSourceSupport
|
||||||
|
|
||||||
private AnnotationRepositoryConfigurationSource getConfigurationSource(
|
private AnnotationRepositoryConfigurationSource getConfigurationSource(
|
||||||
BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {
|
BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {
|
||||||
StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(
|
AnnotationMetadata metadata = AnnotationMetadata.introspect(getConfiguration());
|
||||||
getConfiguration(), true);
|
|
||||||
return new AutoConfiguredAnnotationRepositoryConfigurationSource(metadata,
|
return new AutoConfiguredAnnotationRepositoryConfigurationSource(metadata,
|
||||||
getAnnotation(), this.resourceLoader, this.environment, registry,
|
getAnnotation(), this.resourceLoader, this.environment, registry,
|
||||||
importBeanNameGenerator) {
|
importBeanNameGenerator) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2018 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -25,7 +25,6 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||||
import org.springframework.core.type.AnnotationMetadata;
|
import org.springframework.core.type.AnnotationMetadata;
|
||||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
|
||||||
import org.springframework.integration.annotation.IntegrationComponentScan;
|
import org.springframework.integration.annotation.IntegrationComponentScan;
|
||||||
import org.springframework.integration.config.IntegrationComponentScanRegistrar;
|
import org.springframework.integration.config.IntegrationComponentScanRegistrar;
|
||||||
|
|
||||||
|
@ -49,8 +48,8 @@ class IntegrationAutoConfigurationScanRegistrar extends IntegrationComponentScan
|
||||||
@Override
|
@Override
|
||||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
||||||
final BeanDefinitionRegistry registry) {
|
final BeanDefinitionRegistry registry) {
|
||||||
super.registerBeanDefinitions(new StandardAnnotationMetadata(
|
super.registerBeanDefinitions(AnnotationMetadata
|
||||||
IntegrationComponentScanConfiguration.class, true), registry);
|
.introspect(IntegrationComponentScanConfiguration.class), registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfigurati
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.DefaultResourceLoader;
|
import org.springframework.core.io.DefaultResourceLoader;
|
||||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
import org.springframework.core.type.AnnotationMetadata;
|
||||||
import org.springframework.mock.env.MockEnvironment;
|
import org.springframework.mock.env.MockEnvironment;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -220,7 +220,7 @@ public class AutoConfigurationImportSelectorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] selectImports(Class<?> source) {
|
private String[] selectImports(Class<?> source) {
|
||||||
return this.importSelector.selectImports(new StandardAnnotationMetadata(source));
|
return this.importSelector.selectImports(AnnotationMetadata.introspect(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAutoConfigurationClassNames() {
|
private List<String> getAutoConfigurationClassNames() {
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.core.style.ToStringCreator;
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.core.type.AnnotationMetadata;
|
import org.springframework.core.type.AnnotationMetadata;
|
||||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
|
||||||
import org.springframework.test.context.ContextCustomizer;
|
import org.springframework.test.context.ContextCustomizer;
|
||||||
import org.springframework.test.context.MergedContextConfiguration;
|
import org.springframework.test.context.MergedContextConfiguration;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
@ -284,8 +283,8 @@ class ImportsContextCustomizer implements ContextCustomizer {
|
||||||
private Set<Object> determineImports(Set<Annotation> annotations,
|
private Set<Object> determineImports(Set<Annotation> annotations,
|
||||||
Class<?> testClass) {
|
Class<?> testClass) {
|
||||||
Set<Object> determinedImports = new LinkedHashSet<>();
|
Set<Object> determinedImports = new LinkedHashSet<>();
|
||||||
AnnotationMetadata testClassMetadata = new StandardAnnotationMetadata(
|
AnnotationMetadata testClassMetadata = AnnotationMetadata
|
||||||
testClass);
|
.introspect(testClass);
|
||||||
for (Annotation annotation : annotations) {
|
for (Annotation annotation : annotations) {
|
||||||
for (Class<?> source : getImports(annotation)) {
|
for (Class<?> source : getImports(annotation)) {
|
||||||
Set<Object> determinedSourceImports = determineImports(source,
|
Set<Object> determinedSourceImports = determineImports(source,
|
||||||
|
|
Loading…
Reference in New Issue