You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce DynamicPropertyRegistrar to replace DynamicPropertyRegistry bean
Spring Boot's testing support registers a DynamicPropertyRegistry as a
bean in the ApplicationContext, which conflicts with the
DynamicPropertyRegistry registered as a bean by the Spring TestContext
Framework (TCF) since Spring Framework 6.2 M2.
To avoid that conflict and to improve the user experience for Spring's
testing support, this commit introduces a DynamicPropertyRegistrar API
to replace the DynamicPropertyRegistry bean support.
Specifically, the TCF no longer registers a DynamicPropertyRegistry as
a bean in the ApplicationContext.
Instead, users can now register custom implementations of
DynamicPropertyRegistrar as beans in the ApplicationContext, and the
DynamicPropertiesContextCustomizer now registers a
DynamicPropertyRegistrarBeanInitializer which eagerly initializes
DynamicPropertyRegistrar beans and invokes their accept() methods with
an appropriate DynamicPropertyRegistry.
In addition, a singleton DynamicValuesPropertySource is created and
registered with the Environment for use in
DynamicPropertiesContextCustomizer and
DynamicPropertyRegistrarBeanInitializer, which allows
@DynamicPropertySource methods and DynamicPropertyRegistrar beans to
transparently populate the same DynamicValuesPropertySource.
Closesgh-33501
Copy file name to clipboardExpand all lines: framework-docs/modules/ROOT/pages/testing/testcontext-framework/ctx-management/dynamic-property-sources.adoc
+76-53
Original file line number
Diff line number
Diff line change
@@ -2,39 +2,51 @@
2
2
= Context Configuration with Dynamic Property Sources
3
3
4
4
The Spring TestContext Framework provides support for _dynamic_ properties via the
5
-
`@DynamicPropertySource` annotation and the `DynamicPropertyRegistry`.
5
+
`DynamicPropertyRegistry`, the `@DynamicPropertySource` annotation, and the
6
+
`DynamicPropertyRegistrar` API.
6
7
7
8
[NOTE]
8
9
====
9
-
The `@DynamicPropertySource` annotation and its supporting infrastructure were originally
10
-
designed to allow properties from {testcontainers-site}[Testcontainers] based tests to be
11
-
exposed easily to Spring integration tests. However, this feature may be used with any
12
-
form of external resource whose lifecycle is managed outside the test's
13
-
`ApplicationContext` or with beans whose lifecycle is managed by the test's
14
-
`ApplicationContext`.
10
+
The dynamic property source infrastructure was originally designed to allow properties
11
+
from {testcontainers-site}[Testcontainers] based tests to be exposed easily to Spring
12
+
integration tests. However, these features may be used with any form of external resource
13
+
whose lifecycle is managed outside the test's `ApplicationContext` or with beans whose
14
+
lifecycle is managed by the test's `ApplicationContext`.
0 commit comments