diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/BootstrapConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/BootstrapConfigServerIntegrationTests.java new file mode 100644 index 00000000..60fb5159 --- /dev/null +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/BootstrapConfigServerIntegrationTests.java @@ -0,0 +1,53 @@ +package org.springframework.cloud.config.server; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.IOException; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.IntegrationTest; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.TestRestTemplate; +import org.springframework.cloud.config.Environment; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = ConfigServerApplication.class) +@IntegrationTest({ "debug", "server.port:0", + "spring.cloud.bootstrap.name:enable-bootstrap" }) +@WebAppConfiguration +@ActiveProfiles("test") +public class BootstrapConfigServerIntegrationTests { + + @Value("${local.server.port}") + private int port; + + @Value("${info.foo}") + private String foo; + + @BeforeClass + public static void init() throws IOException { + ConfigServerTestUtils.prepareLocalRepo(); + } + + @Test + public void contextLoads() { + Environment environment = new TestRestTemplate().getForObject("http://localhost:" + + port + "/foo/development/", Environment.class); + assertFalse(environment.getPropertySources().isEmpty()); + assertEquals("bar", environment.getPropertySources().get(0) + .getSource().get("info.foo")); + } + + @Test + public void environmentBootstraps() throws Exception { + assertEquals("bar", foo); + } + +} diff --git a/spring-cloud-config-server/src/test/resources/enable-bootstrap.yml b/spring-cloud-config-server/src/test/resources/enable-bootstrap.yml new file mode 100644 index 00000000..c780b861 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/enable-bootstrap.yml @@ -0,0 +1,7 @@ +spring: + cloud: + config: + server: + git: + uri: file:./target/repos/config-repo + bootstrap: true \ No newline at end of file