Search in sources :

Example 91 with Environment

use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.

the class SVNKitEnvironmentRepositoryIntegrationTests method update.

@Test
public void update() throws Exception {
    String uri = ConfigServerTestUtils.prepareLocalSvnRepo("src/test/resources/svn-config-repo", "target/config");
    this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).profiles("subversion").run("--spring.cloud.config.server.svn.uri=" + uri);
    EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
    repository.findOne("bar", "staging", "trunk");
    Environment environment = repository.findOne("bar", "staging", "trunk");
    assertEquals("bar", environment.getPropertySources().get(0).getSource().get("foo"));
    updateRepoForUpdate(uri);
    environment = repository.findOne("bar", "staging", "trunk");
    assertEquals("foo", environment.getPropertySources().get(0).getSource().get("foo"));
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 92 with Environment

use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.

the class SVNKitEnvironmentRepositoryIntegrationTests method invalidLabel.

@Test(expected = NoSuchLabelException.class)
public void invalidLabel() throws Exception {
    String uri = ConfigServerTestUtils.prepareLocalSvnRepo("src/test/resources/svn-config-repo", "target/config");
    this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).profiles("subversion").run("--spring.cloud.config.server.svn.uri=" + uri);
    EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
    repository.findOne("bar", "staging", "unknownlabel");
    Environment environment = repository.findOne("bar", "staging", "unknownlabel");
    assertEquals(0, environment.getPropertySources().size());
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 93 with Environment

use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.

the class SVNKitEnvironmentRepositoryIntegrationTests method branchLabel.

@Test
public void branchLabel() throws Exception {
    String uri = ConfigServerTestUtils.prepareLocalSvnRepo("src/test/resources/svn-config-repo", "target/config");
    this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).profiles("subversion").run("--spring.cloud.config.server.svn.uri=" + uri);
    EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
    Environment environment = repository.findOne("bar", "staging", "demobranch");
    assertTrue(environment.getPropertySources().get(0).getName().contains("bar.properties"));
    assertEquals(1, environment.getPropertySources().size());
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 94 with Environment

use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.

the class SVNKitEnvironmentRepositoryIntegrationTests method vanilla.

@Test
public void vanilla() throws Exception {
    String uri = ConfigServerTestUtils.prepareLocalSvnRepo("src/test/resources/svn-config-repo", "target/config");
    this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).profiles("subversion").run("--spring.cloud.config.server.svn.uri=" + uri);
    EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
    repository.findOne("bar", "staging", "trunk");
    Environment environment = repository.findOne("bar", "staging", "trunk");
    assertEquals(2, environment.getPropertySources().size());
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 95 with Environment

use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.

the class MultipleJGitEnvironmentLabelPlaceholderRepositoryTests method missingRepo.

@Test
public void missingRepo() {
    Environment environment = this.repository.findOne("missing-config-repo", "staging", "master");
    assertEquals("Wrong property sources: " + environment, 1, environment.getPropertySources().size());
    assertEquals(this.defaultUri + "application.yml", environment.getPropertySources().get(0).getName());
    assertVersion(environment);
}
Also used : StandardEnvironment(org.springframework.core.env.StandardEnvironment) Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Aggregations

Environment (org.springframework.cloud.config.environment.Environment)118 Test (org.junit.Test)104 StandardEnvironment (org.springframework.core.env.StandardEnvironment)37 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)20 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)19 PropertySource (org.springframework.cloud.config.environment.PropertySource)12 LinkedHashMap (java.util.LinkedHashMap)9 File (java.io.File)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 TestRestTemplate (org.springframework.boot.test.web.client.TestRestTemplate)7 FileOutputStream (java.io.FileOutputStream)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)4 EnvironmentPropertySource.prepareEnvironment (org.springframework.cloud.config.server.support.EnvironmentPropertySource.prepareEnvironment)4 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)4 HttpEntity (org.springframework.http.HttpEntity)4 RestTemplate (org.springframework.web.client.RestTemplate)4 Git (org.eclipse.jgit.api.Git)3 Matchers.anyString (org.mockito.Matchers.anyString)3