Skip to content

Commit d745b69

Browse files
committed
Replace usages of EnvironmentTestUtils
1 parent 05254fe commit d745b69

File tree

156 files changed

+863
-883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+863
-883
lines changed

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/BootCuriesHrefIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.junit.After;
2424
import org.junit.Test;
2525

26-
import org.springframework.boot.test.util.EnvironmentTestUtils;
26+
import org.springframework.boot.test.util.TestPropertyValues;
2727
import org.springframework.boot.test.web.client.TestRestTemplate;
2828
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
2929
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
@@ -123,7 +123,7 @@ public URL getResource(String name) {
123123
}
124124

125125
});
126-
EnvironmentTestUtils.addEnvironment(this.context, properties);
126+
TestPropertyValues.of(properties).applyTo(this.context);
127127
this.context.register(TestConfiguration.class);
128128
new ServerPortInfoApplicationContextInitializer().initialize(this.context);
129129
this.context.refresh();

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfigurationTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import org.springframework.boot.context.properties.bind.Binder;
6060
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
6161
import org.springframework.boot.logging.LoggingSystem;
62-
import org.springframework.boot.test.util.EnvironmentTestUtils;
62+
import org.springframework.boot.test.util.TestPropertyValues;
6363
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
6464
import org.springframework.context.annotation.Bean;
6565
import org.springframework.context.annotation.Configuration;
@@ -172,7 +172,7 @@ public void autoConfigurationAuditEndpoints() {
172172
@Test
173173
public void testInfoEndpoint() throws Exception {
174174
this.context = new AnnotationConfigApplicationContext();
175-
EnvironmentTestUtils.addEnvironment(this.context, "info.foo:bar");
175+
TestPropertyValues.of("info.foo:bar").applyTo(this.context);
176176
this.context.register(ProjectInfoAutoConfiguration.class,
177177
InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class);
178178
this.context.refresh();
@@ -186,8 +186,7 @@ public void testInfoEndpoint() throws Exception {
186186
@Test
187187
public void testInfoEndpointNoGitProperties() throws Exception {
188188
this.context = new AnnotationConfigApplicationContext();
189-
EnvironmentTestUtils.addEnvironment(this.context,
190-
"spring.info.git.location:classpath:nonexistent");
189+
TestPropertyValues.of("spring.info.git.location:classpath:nonexistent").applyTo(this.context);
191190
this.context.register(InfoContributorAutoConfiguration.class,
192191
EndpointAutoConfiguration.class);
193192
this.context.refresh();
@@ -199,7 +198,7 @@ public void testInfoEndpointNoGitProperties() throws Exception {
199198
@Test
200199
public void testInfoEndpointOrdering() throws Exception {
201200
this.context = new AnnotationConfigApplicationContext();
202-
EnvironmentTestUtils.addEnvironment(this.context, "info.name:foo");
201+
TestPropertyValues.of("info.name:foo").applyTo(this.context);
203202
this.context.register(CustomInfoContributorsConfig.class,
204203
ProjectInfoAutoConfiguration.class,
205204
InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class);

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java

Lines changed: 53 additions & 59 deletions
Large diffs are not rendered by default.

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
3030
import org.springframework.boot.autoconfigure.web.ServerProperties;
3131
import org.springframework.boot.context.properties.EnableConfigurationProperties;
32-
import org.springframework.boot.test.util.EnvironmentTestUtils;
32+
import org.springframework.boot.test.util.TestPropertyValues;
3333
import org.springframework.context.annotation.Bean;
3434
import org.springframework.context.annotation.Configuration;
3535
import org.springframework.hateoas.Link;
@@ -126,7 +126,7 @@ public URL getResource(String name) {
126126
}
127127

128128
});
129-
EnvironmentTestUtils.addEnvironment(this.context, properties);
129+
TestPropertyValues.of(properties).applyTo(this.context);
130130
this.context.register(TestConfiguration.class,
131131
HttpMessageConvertersAutoConfiguration.class,
132132
EndpointWebMvcHypermediaManagementContextConfiguration.class);

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
3131
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
3232
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
33-
import org.springframework.boot.test.util.EnvironmentTestUtils;
33+
import org.springframework.boot.test.util.TestPropertyValues;
3434
import org.springframework.mock.web.MockServletContext;
3535
import org.springframework.test.util.ReflectionTestUtils;
3636
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@@ -68,9 +68,9 @@ public void close() {
6868

6969
@Test
7070
public void endpointHandlerMapping() throws Exception {
71-
EnvironmentTestUtils.addEnvironment(this.context,
71+
TestPropertyValues.of(
7272
"management.security.enabled=false",
73-
"management.security.roles=my-role,your-role");
73+
"management.security.roles=my-role,your-role").applyTo(this.context);
7474
this.context.refresh();
7575
EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping",
7676
EndpointHandlerMapping.class);

0 commit comments

Comments
 (0)