Add test for spring.cloud.config.server.bootstrap

Setting this flag to "true" makes the config server load its own
configuration from the git repository (hence both have to be
confifgured in bootstrap.yml)
This commit is contained in:
Dave Syer
2015-02-10 11:01:26 +00:00
parent f8d91ef32b
commit 2d63d598db
2 changed files with 60 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -0,0 +1,7 @@
spring:
cloud:
config:
server:
git:
uri: file:./target/repos/config-repo
bootstrap: true