Search in sources :

Example 86 with Environment

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

the class MultipleJGitEnvironmentProfilePlaceholderRepositoryTests method otherMappingRepo.

@Test
public void otherMappingRepo() {
    Environment environment = this.repository.findOne("application", "test2-config-repo", "master");
    assertEquals(1, environment.getPropertySources().size());
    assertEquals(getUri("*").replace("{profile}", "test2-config-repo") + "/application.properties", 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)

Example 87 with Environment

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

the class MultipleJGitEnvironmentProfilePlaceholderRepositoryTests method twoMappingRepos.

@Test
public void twoMappingRepos() {
    Environment environment = this.repository.findOne("application", "test1-config-repo,test2-config-repo,missing-config-repo", "master");
    assertEquals(1, environment.getPropertySources().size());
    assertEquals(getUri("*").replace("{profile}", "test2-config-repo") + "/application.properties", environment.getPropertySources().get(0).getName());
    assertVersion(environment);
    assertArrayEquals(environment.getProfiles(), new String[] { "test1-config-repo", "test2-config-repo", "missing-config-repo" });
}
Also used : StandardEnvironment(org.springframework.core.env.StandardEnvironment) Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 88 with Environment

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

the class MultipleJGitEnvironmentRepositoryTests method defaultRepoTag.

@Test
public void defaultRepoTag() {
    Environment environment = this.repository.findOne("bar", "staging", "foo");
    assertEquals(2, environment.getPropertySources().size());
    assertEquals(this.repository.getUri() + "/bar.properties", 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)

Example 89 with Environment

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

the class MultipleJGitEnvironmentRepositoryTests method defaultLabel.

@Test
public void defaultLabel() {
    this.repository.setDefaultLabel("raw");
    Environment environment = this.repository.findOne("bar", "staging", null);
    assertEquals("raw", environment.getLabel());
    assertEquals(2, environment.getPropertySources().size());
    assertEquals(this.repository.getUri() + "/bar.properties", 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)

Example 90 with Environment

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

the class MultipleJGitEnvironmentRepositoryTests method mappingRepoWithDefaultLabel.

@Test
public void mappingRepoWithDefaultLabel() {
    Environment environment = this.repository.findOne("test1-svc", "staging", null);
    assertEquals("master", environment.getLabel());
    assertEquals(2, environment.getPropertySources().size());
    assertEquals(getUri("*test1*") + "/test1-svc.properties", 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