Search in sources :

Example 36 with Environment

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

the class EnvironmentControllerIntegrationTests method environmentWithLabel.

@Test
public void environmentWithLabel() throws Exception {
    Mockito.when(this.repository.findOne("foo", "default", "awesome")).thenReturn(new Environment("foo", "default"));
    this.mvc.perform(MockMvcRequestBuilders.get("/foo/default/awesome")).andExpect(MockMvcResultMatchers.status().isOk());
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 37 with Environment

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

the class EnvironmentControllerIntegrationTests method propertiesNoLabel.

@Test
public void propertiesNoLabel() throws Exception {
    Mockito.when(this.repository.findOne("foo", "default", null)).thenReturn(new Environment("foo", "default"));
    this.mvc.perform(MockMvcRequestBuilders.get("/foo-default.properties")).andExpect(MockMvcResultMatchers.status().isOk());
    Mockito.verify(this.repository).findOne("foo", "default", null);
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 38 with Environment

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

the class EnvironmentControllerIntegrationTests method propertiesLabel.

@Test
public void propertiesLabel() throws Exception {
    Mockito.when(this.repository.findOne("foo", "default", "label")).thenReturn(new Environment("foo", "default"));
    this.mvc.perform(MockMvcRequestBuilders.get("/label/foo-default.properties")).andExpect(MockMvcResultMatchers.status().isOk());
    Mockito.verify(this.repository).findOne("foo", "default", "label");
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 39 with Environment

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

the class EnvironmentControllerIntegrationTests method propertiesLabelWhenApplicationNameContainsHyphen.

@Test
public void propertiesLabelWhenApplicationNameContainsHyphen() throws Exception {
    Mockito.when(this.repository.findOne("foo-bar", "default", "label")).thenReturn(new Environment("foo-bar", "default"));
    this.mvc.perform(MockMvcRequestBuilders.get("/label/foo-bar-default.properties")).andExpect(MockMvcResultMatchers.status().isOk());
    Mockito.verify(this.repository).findOne("foo-bar", "default", "label");
}
Also used : Environment(org.springframework.cloud.config.environment.Environment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 40 with Environment

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

the class JGitEnvironmentRepositoryIntegrationTests method nested.

@Test
public void nested() throws IOException {
    String uri = ConfigServerTestUtils.prepareLocalRepo("another-config-repo");
    this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).run("--spring.cloud.config.server.git.uri=" + uri, "--spring.cloud.config.server.git.searchPaths=sub");
    EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
    repository.findOne("bar", "staging", "master");
    Environment environment = repository.findOne("bar", "staging", "master");
    assertEquals(2, environment.getPropertySources().size());
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) 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