Fix careless mistake in tests
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package org.springframework.cloud.bootstrap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -10,11 +7,15 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.bootstrap.BootstrapOrderingAutoConfigurationIntegrationTests.Application;
|
||||
import org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = Application.class)
|
||||
@IntegrationTest("encrypt.key:deadbeef")
|
||||
@@ -26,7 +27,8 @@ public class BootstrapOrderingAutoConfigurationIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void bootstrapPropertiesExist() {
|
||||
assertTrue(this.environment.getPropertySources().contains("bootstrap"));
|
||||
assertTrue(this.environment.getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.springframework.cloud.bootstrap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -14,6 +11,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.bootstrap.BootstrapOrderingCustomPropertySourceIntegrationTests.Application;
|
||||
import org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration;
|
||||
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
@@ -23,9 +21,12 @@ import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = Application.class)
|
||||
@IntegrationTest({"encrypt.key:deadbeef", "spring.cloud.bootstrap.name:custom"})
|
||||
@IntegrationTest({ "encrypt.key:deadbeef", "spring.cloud.bootstrap.name:custom" })
|
||||
@ActiveProfiles("encrypt")
|
||||
public class BootstrapOrderingCustomPropertySourceIntegrationTests {
|
||||
|
||||
@@ -34,7 +35,8 @@ public class BootstrapOrderingCustomPropertySourceIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void bootstrapPropertiesExist() {
|
||||
assertTrue(this.environment.getPropertySources().contains("bootstrap"));
|
||||
assertTrue(this.environment.getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,7 +55,8 @@ public class BootstrapOrderingCustomPropertySourceIntegrationTests {
|
||||
protected static class PropertySourceConfiguration implements PropertySourceLocator {
|
||||
|
||||
public static Map<String, Object> MAP = new HashMap<String, Object>(
|
||||
Collections.<String, Object> singletonMap("custom.foo", "{cipher}6154ca04d4bb6144d672c4e3d750b5147116dd381946d51fa44f8bc25dc256f4"));
|
||||
Collections.<String, Object> singletonMap("custom.foo",
|
||||
"{cipher}6154ca04d4bb6144d672c4e3d750b5147116dd381946d51fa44f8bc25dc256f4"));
|
||||
|
||||
@Override
|
||||
public PropertySource<?> locate(Environment environment) {
|
||||
|
||||
@@ -78,8 +78,8 @@ public class BootstrapConfigurationTests {
|
||||
.run();
|
||||
assertEquals("externalPropertiesInfoName",
|
||||
this.context.getEnvironment().getProperty("info.name"));
|
||||
assertTrue(
|
||||
this.context.getEnvironment().getPropertySources().contains("bootstrap"));
|
||||
assertTrue(this.context.getEnvironment().getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,8 +96,8 @@ public class BootstrapConfigurationTests {
|
||||
}
|
||||
})
|
||||
.run();
|
||||
assertTrue(
|
||||
this.context.getEnvironment().getPropertySources().contains("bootstrap"));
|
||||
assertTrue(this.context.getEnvironment().getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,8 +127,8 @@ public class BootstrapConfigurationTests {
|
||||
this.context = new SpringApplicationBuilder().web(false)
|
||||
.sources(BareConfiguration.class).run();
|
||||
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
|
||||
assertTrue(
|
||||
this.context.getEnvironment().getPropertySources().contains("bootstrap"));
|
||||
assertTrue(this.context.getEnvironment().getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -264,7 +264,8 @@ public class BootstrapConfigurationTests {
|
||||
this.context.getParent().getEnvironment());
|
||||
MutablePropertySources sources = this.context.getEnvironment()
|
||||
.getPropertySources();
|
||||
PropertySource<?> bootstrap = sources.get("bootstrap");
|
||||
PropertySource<?> bootstrap = sources
|
||||
.get(PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME);
|
||||
assertNotNull(bootstrap);
|
||||
assertEquals(0, sources.precedenceOf(bootstrap));
|
||||
}
|
||||
@@ -277,10 +278,11 @@ public class BootstrapConfigurationTests {
|
||||
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
|
||||
assertNotSame(this.context.getEnvironment(),
|
||||
this.context.getParent().getEnvironment());
|
||||
assertTrue(
|
||||
this.context.getEnvironment().getPropertySources().contains("bootstrap"));
|
||||
assertTrue(this.context.getEnvironment().getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
assertTrue(((ConfigurableEnvironment) this.context.getParent().getEnvironment())
|
||||
.getPropertySources().contains("bootstrap"));
|
||||
.getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -300,7 +302,8 @@ public class BootstrapConfigurationTests {
|
||||
assertFalse(this.context.getParent().getEnvironment().acceptsProfiles("child"));
|
||||
assertTrue(this.context.getParent().getEnvironment().acceptsProfiles("parent"));
|
||||
assertTrue(((ConfigurableEnvironment) this.context.getParent().getEnvironment())
|
||||
.getPropertySources().contains("bootstrap"));
|
||||
.getPropertySources().contains(
|
||||
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
|
||||
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
|
||||
// The "bootstrap" property source is not shared now, but it has the same
|
||||
// properties in it because they are pulled from the PropertySourceConfiguration
|
||||
|
||||
Reference in New Issue
Block a user