2525import org .springframework .beans .factory .config .ConfigurableListableBeanFactory ;
2626import org .springframework .beans .factory .support .BeanDefinitionBuilder ;
2727import org .springframework .beans .factory .support .BeanDefinitionRegistry ;
28- import org .springframework .boot .testcontainers .properties .TestcontainersPropertySource ;
2928import org .springframework .context .annotation .ImportBeanDefinitionRegistrar ;
3029import org .springframework .core .annotation .MergedAnnotation ;
3130import org .springframework .core .env .Environment ;
3231import org .springframework .core .type .AnnotationMetadata ;
3332import org .springframework .core .type .MethodMetadata ;
3433import org .springframework .test .context .DynamicPropertyRegistrar ;
3534import org .springframework .test .context .DynamicPropertyRegistry ;
36- import org .springframework .util .ClassUtils ;
3735
3836/**
3937 * Finds beans annotated with {@link DynamicProperty} and adds the properties to the
@@ -63,13 +61,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B
6361 return ;
6462 }
6563 if (this .beanFactory instanceof ConfigurableListableBeanFactory listableBeanFactory ) {
66- if (ClassUtils .isPresent ("org.springframework.test.context.DynamicPropertyRegistrar" ,
67- getClass ().getClassLoader ())) {
68- registerDynamicPropertyRegistrar (listableBeanFactory , registry );
69- }
70- else {
71- registerTestcontainersPropertySource (listableBeanFactory , registry );
72- }
64+ registerDynamicPropertyRegistrar (listableBeanFactory , registry );
7365 }
7466 }
7567
@@ -93,21 +85,6 @@ private void registerDynamicPropertyRegistrar(ConfigurableListableBeanFactory be
9385 registry .registerBeanDefinition (REGISTRAR_BEAN_NAME , registrarBdb .getBeanDefinition ());
9486 }
9587
96- private void registerTestcontainersPropertySource (ConfigurableListableBeanFactory beanFactory ,
97- BeanDefinitionRegistry registry ) {
98- DynamicPropertyRegistry properties = TestcontainersPropertySource .attach (this .environment );
99- for (String dynamicPropertyBeanName : beanFactory .getBeanNamesForAnnotation (DynamicProperty .class )) {
100- BeanDefinition dynamicPropertyBeanDefinition = registry .getBeanDefinition (dynamicPropertyBeanName );
101- DynamicPropertyRegistryProperty property = createRegistryProperty (dynamicPropertyBeanDefinition ,
102- dynamicPropertyBeanName );
103- if (property == null ) {
104- throw new IllegalStateException (
105- "Missing @DynamicProperty annotation on BeanDefinition of " + dynamicPropertyBeanName );
106- }
107- properties .add (property .name (), property .value ());
108- }
109- }
110-
11188 private DynamicPropertyRegistryProperty createRegistryProperty (BeanDefinition dynamicPropertyBeanDefinition ,
11289 String dynamicPropertyBeanName ) {
11390 if (dynamicPropertyBeanDefinition instanceof AnnotatedBeanDefinition annotatedBeanDefinition ) {
0 commit comments