Search in sources :

Example 21 with Environment

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

the class NativeEnvironmentRepositoryTests method placeholdersApplicationAndProfile.

@Test
public void placeholdersApplicationAndProfile() {
    this.repository.setSearchLocations("classpath:/test/{profile}/{application}/");
    Environment environment = this.repository.findOne("app", "dev", "master");
    assertEquals(1, environment.getPropertySources().size());
    assertEquals("app", environment.getPropertySources().get(0).getSource().get("foo"));
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 22 with Environment

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

the class NativeEnvironmentRepositoryTests method ignoresExistingProfile.

@Test
public void ignoresExistingProfile() {
    System.setProperty("spring.profiles.active", "cloud");
    Environment environment = this.repository.findOne("foo", "main", "master");
    assertEquals(1, environment.getPropertySources().size());
    assertEquals("version was wrong", "myversion", environment.getVersion());
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 23 with Environment

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

the class NativeEnvironmentRepositoryTests method placeholdersLabel.

@Test
public void placeholdersLabel() {
    this.repository.setSearchLocations("classpath:/test/{label}/");
    Environment environment = this.repository.findOne("foo", "development", "dev");
    assertEquals(1, environment.getPropertySources().size());
    assertEquals("dev_bar", environment.getPropertySources().get(0).getSource().get("foo"));
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 24 with Environment

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

the class NativeEnvironmentRepositoryTests method locationDontAddLabelLocations.

@Test
public void locationDontAddLabelLocations() {
    this.repository.setSearchLocations("classpath:/test/dev/");
    this.repository.setAddLabelLocations(false);
    Environment environment = this.repository.findOne("foo", "development", "ignore");
    assertEquals(1, environment.getPropertySources().size());
    assertEquals("dev_bar", environment.getPropertySources().get(0).getSource().get("foo"));
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test)

Example 25 with Environment

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

the class NativeEnvironmentRepositoryTests method vanilla.

@Test
public void vanilla() {
    Environment environment = this.repository.findOne("foo", "development", "master");
    assertEquals(2, environment.getPropertySources().size());
    assertEquals("version was wrong", "myversion", environment.getVersion());
}
Also used : 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