use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerIntegrationTests method environmentWithLabelContainingSlash.
@Test
public void environmentWithLabelContainingSlash() throws Exception {
Mockito.when(this.repository.findOne("foo", "default", "feature/puff")).thenReturn(new Environment("foo", "default"));
this.mvc.perform(MockMvcRequestBuilders.get("/foo/default/feature(_)puff")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().string(Matchers.containsString("\"propertySources\":")));
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerIntegrationTests method environmentWithApplicationContainingSlash.
@Test
public void environmentWithApplicationContainingSlash() throws Exception {
Mockito.when(this.repository.findOne("foo/app", "default", null)).thenReturn(new Environment("foo/app", "default"));
this.mvc.perform(MockMvcRequestBuilders.get("/foo(_)app/default")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().string(Matchers.containsString("\"propertySources\":")));
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerIntegrationTests method environmentWithLabelContainingPeriod.
@Test
public void environmentWithLabelContainingPeriod() throws Exception {
Mockito.when(this.repository.findOne("foo", "default", "1.0.0")).thenReturn(new Environment("foo", "default"));
this.mvc.perform(MockMvcRequestBuilders.get("/foo/default/1.0.0")).andExpect(MockMvcResultMatchers.status().isOk());
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryConcurrencyTests method vanilla.
@Test
public void vanilla() throws Exception {
String uri = ConfigServerTestUtils.prepareLocalRepo();
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).properties("spring.cloud.config.server.git.uri:" + uri).run();
final EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
ExecutorService threads = Executors.newFixedThreadPool(4);
List<Future<Boolean>> tasks = new ArrayList<Future<Boolean>>();
for (int i = 0; i < 30; i++) {
tasks.add(threads.submit(new Runnable() {
@Override
public void run() {
repository.findOne("bar", "staging", "master");
}
}, true));
}
for (Future<Boolean> future : tasks) {
future.get();
}
Environment environment = repository.findOne("bar", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
assertEquals("bar", environment.getName());
assertArrayEquals(new String[] { "staging" }, environment.getProfiles());
assertEquals("master", environment.getLabel());
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method findOne_CloneOnStartTrue_FindOneSuccess.
@Test
public void findOne_CloneOnStartTrue_FindOneSuccess() throws Exception {
ConfigServerTestUtils.prepareLocalRepo();
String uri = ConfigServerTestUtils.copyLocalRepo("config-copy");
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).run("--spring.cloud.config.server.git.uri=" + uri, "--spring.cloud.config.server.git.cloneOnStart=true");
EnvironmentRepository repository = this.context.getBean(JGitEnvironmentRepository.class);
assertTrue(((JGitEnvironmentRepository) repository).isCloneOnStart());
Environment environment = repository.findOne("bar", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
assertEquals("bar", environment.getName());
assertArrayEquals(new String[] { "staging" }, environment.getProfiles());
assertEquals("master", environment.getLabel());
}
Aggregations