From 8f9dfd38e3b54a7173190751954f6b1c8e936d6e Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 30 Oct 2017 19:19:20 -0400 Subject: [PATCH] Update tests for 2.0.x --- .../refresh/ContextRefresherTests.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java index 5117d740..a7bea02b 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java @@ -70,17 +70,18 @@ public class ContextRefresherTests { public void parentContextIsClosed() { // Use spring.cloud.bootstrap.name to switch off the defaults (which would pick up // a bootstrapProperties immediately - context = SpringApplication.run(ContextRefresherTests.class, + try (ConfigurableApplicationContext context = SpringApplication.run(ContextRefresherTests.class, "--spring.main.webEnvironment=false", "--debug=false", - "--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh"); - ContextRefresher refresher = new ContextRefresher(context, scope); - EnvironmentTestUtils.addEnvironment(context, - "spring.cloud.bootstrap.sources: org.springframework.cloud.context.refresh.ContextRefresherTests.PropertySourceConfiguration\n" - + ""); - ConfigurableApplicationContext refresherContext = refresher.addConfigFilesToEnvironment(); - assertThat(refresherContext.getParent()).isNotNull().isInstanceOf(ConfigurableApplicationContext.class); - ConfigurableApplicationContext parent = (ConfigurableApplicationContext) refresherContext.getParent(); - assertThat(parent.isActive()).isFalse(); + "--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) { + ContextRefresher refresher = new ContextRefresher(context, scope); + TestPropertyValues.of( + "spring.cloud.bootstrap.sources: org.springframework.cloud.context.refresh.ContextRefresherTests.PropertySourceConfiguration") + .applyTo(context); + ConfigurableApplicationContext refresherContext = refresher.addConfigFilesToEnvironment(); + assertThat(refresherContext.getParent()).isNotNull().isInstanceOf(ConfigurableApplicationContext.class); + ConfigurableApplicationContext parent = (ConfigurableApplicationContext) refresherContext.getParent(); + assertThat(parent.isActive()).isFalse(); + } } private List names(MutablePropertySources propertySources) { List list = new ArrayList<>();