Browse Source

Polish DynamicPropertyRegistrar documentation

pull/33529/head
Sam Brannen 1 year ago
parent
commit
d097eea3a8
  1. 4
      framework-docs/modules/ROOT/pages/testing/testcontext-framework/ctx-management/dynamic-property-sources.adoc
  2. 5
      spring-test/src/main/java/org/springframework/test/context/DynamicPropertyRegistrar.java
  3. 4
      spring-test/src/test/java/org/springframework/test/context/DynamicPropertyRegistrarIntegrationTests.java
  4. 2
      spring-test/src/test/java/org/springframework/test/context/DynamicPropertySourceIntegrationTests.java

4
framework-docs/modules/ROOT/pages/testing/testcontext-framework/ctx-management/dynamic-property-sources.adoc

@ -162,7 +162,7 @@ Java:: @@ -162,7 +162,7 @@ Java::
}
@Bean
DynamicPropertyRegistrar apiServerProperties(ApiServer apiServer) {
DynamicPropertyRegistrar apiPropertiesRegistrar(ApiServer apiServer) {
return registry -> registry.add("api.url", apiServer::getUrl);
}
}
@ -181,7 +181,7 @@ Kotlin:: @@ -181,7 +181,7 @@ Kotlin::
}
@Bean
fun apiServerProperties(apiServer: ApiServer): DynamicPropertyRegistrar {
fun apiPropertiesRegistrar(apiServer: ApiServer): DynamicPropertyRegistrar {
return registry -> registry.add("api.url", apiServer::getUrl)
}
}

5
spring-test/src/main/java/org/springframework/test/context/DynamicPropertyRegistrar.java

@ -67,7 +67,7 @@ package org.springframework.test.context; @@ -67,7 +67,7 @@ package org.springframework.test.context;
* }
*
* @Bean
* DynamicPropertyRegistrar apiServerProperties(ApiServer apiServer) {
* DynamicPropertyRegistrar apiPropertiesRegistrar(ApiServer apiServer) {
* return registry -> registry.add("api.url", apiServer::getUrl);
* }
*
@ -82,6 +82,9 @@ package org.springframework.test.context; @@ -82,6 +82,9 @@ package org.springframework.test.context;
@FunctionalInterface
public interface DynamicPropertyRegistrar {
/**
* Register dynamic properties in the supplied registry.
*/
void accept(DynamicPropertyRegistry registry);
}

4
spring-test/src/test/java/org/springframework/test/context/DynamicPropertyRegistrarIntegrationTests.java

@ -117,12 +117,12 @@ class DynamicPropertyRegistrarIntegrationTests { @@ -117,12 +117,12 @@ class DynamicPropertyRegistrarIntegrationTests {
// context which further ensures that the dynamic "api.url" property is
// available to all standard singleton beans.
@Bean
DynamicPropertyRegistrar apiServerProperties1(ApiServer apiServer) {
DynamicPropertyRegistrar apiPropertiesRegistrar1(ApiServer apiServer) {
return registry -> registry.add(API_URL_1, () -> apiServer.getUrl() + "/1");
}
@Bean
DynamicPropertyRegistrar apiServerProperties2(ApiServer apiServer) {
DynamicPropertyRegistrar apiPropertiesRegistrar2(ApiServer apiServer) {
return registry -> registry.add(API_URL_2, () -> apiServer.getUrl() + "/2");
}

2
spring-test/src/test/java/org/springframework/test/context/DynamicPropertySourceIntegrationTests.java

@ -112,7 +112,7 @@ class DynamicPropertySourceIntegrationTests { @@ -112,7 +112,7 @@ class DynamicPropertySourceIntegrationTests {
static class Config {
@Bean
DynamicPropertyRegistrar magicWordProperties() {
DynamicPropertyRegistrar magicPropertiesRegistrar() {
return registry -> registry.add(MAGIC_WORD, () -> "enigma");
}

Loading…
Cancel
Save