From 5cfe42b9af4be16d57719d1d7bb8cf7b66f2a759 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 1 Feb 2016 13:26:21 +0000 Subject: [PATCH] Fix careless mistake in tests --- .../PropertySourceBootstrapConfiguration.java | 2 +- ...ringAutoConfigurationIntegrationTests.java | 10 +++++--- ...gCustomPropertySourceIntegrationTests.java | 15 ++++++----- .../config/BootstrapConfigurationTests.java | 25 +++++++++++-------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java index bd3ba86f..f0669274 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java @@ -56,7 +56,7 @@ import org.springframework.util.ResourceUtils; public class PropertySourceBootstrapConfiguration implements ApplicationContextInitializer, Ordered { - private static final String BOOTSTRAP_PROPERTY_SOURCE_NAME = BootstrapApplicationListener.BOOTSTRAP_PROPERTY_SOURCE_NAME + public static final String BOOTSTRAP_PROPERTY_SOURCE_NAME = BootstrapApplicationListener.BOOTSTRAP_PROPERTY_SOURCE_NAME + "Properties"; private static Log logger = LogFactory diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java index 81240eec..c69d69c7 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java @@ -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 diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java index 9bc8e28e..efeae0b1 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java @@ -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 MAP = new HashMap( - Collections. singletonMap("custom.foo", "{cipher}6154ca04d4bb6144d672c4e3d750b5147116dd381946d51fa44f8bc25dc256f4")); + Collections. singletonMap("custom.foo", + "{cipher}6154ca04d4bb6144d672c4e3d750b5147116dd381946d51fa44f8bc25dc256f4")); @Override public PropertySource locate(Environment environment) { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java index fdb7af3e..6267fcd1 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java @@ -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