Update to new binder

This commit is contained in:
Spencer Gibb
2017-05-01 08:58:28 -06:00
parent 6abf2def40
commit 6a4789a691
4 changed files with 36 additions and 33 deletions

View File

@@ -25,7 +25,6 @@ import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -46,6 +45,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.springframework.boot.WebApplicationType.NONE;
/**
* @author Dave Syer
@@ -80,7 +80,7 @@ public class BootstrapConfigurationTests {
public void pickupExternalBootstrapProperties() {
String externalPropertiesPath = getExternalProperties();
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class)
.properties("spring.cloud.bootstrap.location:" + externalPropertiesPath)
.run();
@@ -92,7 +92,7 @@ public class BootstrapConfigurationTests {
@Test
public void bootstrapPropertiesAvailableInInitializer() {
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class).initializers(
new ApplicationContextInitializer<ConfigurableApplicationContext>() {
@Override
@@ -123,7 +123,7 @@ public class BootstrapConfigurationTests {
}
else {
externalProperties = new File(
"spring-cloud-config-client/src/test/resources/external-properties/bootstrap.properties");
"spring-cloud-context/src/test/resources/external-properties/bootstrap.properties");
externalPropertiesPath = externalProperties.getAbsolutePath();
}
return externalPropertiesPath;
@@ -132,7 +132,7 @@ public class BootstrapConfigurationTests {
@Test
public void picksUpAdditionalPropertySource() {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class).run();
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
assertTrue(this.context.getEnvironment().getPropertySources().contains(
@@ -143,7 +143,7 @@ public class BootstrapConfigurationTests {
public void failsOnPropertySource() {
System.setProperty("expected.fail", "true");
this.expected.expectMessage("Planned");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class).run();
}
@@ -151,7 +151,7 @@ public class BootstrapConfigurationTests {
public void overrideSystemPropertySourceByDefault() {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class).run();
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
}
@@ -162,7 +162,7 @@ public class BootstrapConfigurationTests {
PropertySourceConfiguration.MAP
.put("spring.cloud.config.overrideSystemProperties", "false");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class).run();
assertEquals("system",
this.context.getEnvironment().getProperty("bootstrap.foo"));
@@ -178,7 +178,7 @@ public class BootstrapConfigurationTests {
// their own remote property source.
PropertySourceConfiguration.MAP.put("spring.cloud.config.allowOverride", "false");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class).run();
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
}
@@ -190,7 +190,7 @@ public class BootstrapConfigurationTests {
.put("spring.cloud.config.overrideSystemProperties", "false");
PropertySourceConfiguration.MAP.put("spring.cloud.config.allowOverride", "true");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.sources(BareConfiguration.class).run();
assertEquals("system",
this.context.getEnvironment().getProperty("bootstrap.foo"));
@@ -204,7 +204,7 @@ public class BootstrapConfigurationTests {
ConfigurableEnvironment environment = new StandardEnvironment();
environment.getPropertySources().addLast(new MapPropertySource("last",
Collections.<String, Object>singletonMap("bootstrap.foo", "splat")));
this.context = new SpringApplicationBuilder().web(false).environment(environment)
this.context = new SpringApplicationBuilder().web(NONE).environment(environment)
.sources(BareConfiguration.class).run();
assertEquals("splat", this.context.getEnvironment().getProperty("bootstrap.foo"));
}
@@ -212,7 +212,7 @@ public class BootstrapConfigurationTests {
@Test
public void applicationNameInBootstrapAndMain() {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.properties("spring.cloud.bootstrap.name:other",
"spring.config.name:plain")
.sources(BareConfiguration.class).run();
@@ -232,7 +232,7 @@ public class BootstrapConfigurationTests {
@Test
public void applicationNameNotInBootstrap() {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.properties("spring.cloud.bootstrap.name:application",
"spring.config.name:other")
.sources(BareConfiguration.class).run();
@@ -247,7 +247,7 @@ public class BootstrapConfigurationTests {
@Test
public void applicationNameOnlyInBootstrap() {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder().web(false)
this.context = new SpringApplicationBuilder().web(NONE)
.properties("spring.cloud.bootstrap.name:other")
.sources(BareConfiguration.class).run();
// The main context is called "main" because spring.application.name is specified
@@ -266,7 +266,7 @@ public class BootstrapConfigurationTests {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().sources(BareConfiguration.class)
.environment(new StandardEnvironment()).child(BareConfiguration.class)
.web(false).run();
.web(NONE).run();
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
assertEquals(this.context.getEnvironment(),
this.context.getParent().getEnvironment());
@@ -283,7 +283,7 @@ public class BootstrapConfigurationTests {
TestHigherPriorityBootstrapConfiguration.count.set(0);
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().sources(BareConfiguration.class)
.child(BareConfiguration.class).web(false).run();
.child(BareConfiguration.class).web(NONE).run();
assertEquals(1, TestHigherPriorityBootstrapConfiguration.count.get());
assertNotNull(context.getParent());
assertEquals("bootstrap", context.getParent().getParent().getId());
@@ -298,9 +298,9 @@ public class BootstrapConfigurationTests {
SpringApplicationBuilder builder = new SpringApplicationBuilder()
.sources(BareConfiguration.class);
this.sibling = builder.child(BareConfiguration.class)
.properties("spring.application.name=sibling").web(false).run();
.properties("spring.application.name=sibling").web(NONE).run();
this.context = builder.child(BareConfiguration.class)
.properties("spring.application.name=context").web(false).run();
.properties("spring.application.name=context").web(NONE).run();
assertEquals(1, TestHigherPriorityBootstrapConfiguration.count.get());
assertNotNull(context.getParent());
assertEquals("bootstrap", context.getParent().getParent().getId());
@@ -320,7 +320,7 @@ public class BootstrapConfigurationTests {
public void environmentEnrichedInParentContext() {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().sources(BareConfiguration.class)
.child(BareConfiguration.class).web(false).run();
.child(BareConfiguration.class).web(NONE).run();
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
assertNotSame(this.context.getEnvironment(),
this.context.getParent().getEnvironment());
@@ -336,9 +336,9 @@ public class BootstrapConfigurationTests {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
// Profiles are always merged with the child
ConfigurableApplicationContext parent = new SpringApplicationBuilder()
.sources(BareConfiguration.class).profiles("parent").web(false).run();
.sources(BareConfiguration.class).profiles("parent").web(NONE).run();
this.context = new SpringApplicationBuilder(BareConfiguration.class)
.profiles("child").parent(parent).web(false).run();
.profiles("child").parent(parent).web(NONE).run();
assertNotSame(this.context.getEnvironment(),
this.context.getParent().getEnvironment());
// The ApplicationContext merges profiles (profiles and property sources), see
@@ -364,7 +364,7 @@ public class BootstrapConfigurationTests {
@Test
public void includeProfileFromBootstrapPropertySource() {
PropertySourceConfiguration.MAP.put("spring.profiles.include", "bar,baz");
this.context = new SpringApplicationBuilder().web(false).profiles("foo")
this.context = new SpringApplicationBuilder().web(NONE).profiles("foo")
.sources(BareConfiguration.class).run();
assertTrue(this.context.getEnvironment().acceptsProfiles("baz"));
assertTrue(this.context.getEnvironment().acceptsProfiles("bar"));