use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method testVersionUpdate.
@Test
public void testVersionUpdate() throws Exception {
JGitConfigServerTestData testData = JGitConfigServerTestData.prepareClonedGitRepository(TestConfiguration.class);
// get our starting versions
String startingLocalVersion = getCommitID(testData.getClonedGit().getGit(), "master");
String startingRemoteVersion = getCommitID(testData.getServerGit().getGit(), "master");
// make sure we get the right version out of the gate
Environment environment = testData.getRepository().findOne("bar", "staging", "master");
// make sure the environments version is the same as the remote repo
// version
assertEquals(environment.getVersion(), startingRemoteVersion);
// update the remote repo
FileOutputStream out = new FileOutputStream(new File(testData.getServerGit().getGitWorkingDirectory(), "bar.properties"));
StreamUtils.copy("foo: foo", Charset.defaultCharset(), out);
testData.getServerGit().getGit().add().addFilepattern("bar.properties").call();
testData.getServerGit().getGit().commit().setMessage("Updated for pull").call();
// pull the environment again which should update the local repo from
// the just updated remote repo
environment = testData.getRepository().findOne("bar", "staging", "master");
// do some more check outs to get updated version numbers
String updatedLocalVersion = getCommitID(testData.getClonedGit().getGit(), "master");
String updatedRemoteVersion = getCommitID(testData.getClonedGit().getGit(), "master");
// make sure our versions have been updated
assertEquals(updatedRemoteVersion, updatedLocalVersion);
assertNotEquals(updatedRemoteVersion, startingRemoteVersion);
assertNotEquals(updatedLocalVersion, startingLocalVersion);
// make sure our environment also reflects the updated version
// this used to have a bug
assertEquals(environment.getVersion(), updatedRemoteVersion);
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method pullMissingRepo.
@Test
public void pullMissingRepo() throws Exception {
pull();
JGitEnvironmentRepository repository = this.context.getBean(JGitEnvironmentRepository.class);
new File(repository.getUri().replaceAll("file:", ""), ".git/index.lock").createNewFile();
repository.findOne("bar", "staging", "master");
Environment environment = repository.findOne("bar", "staging", "master");
assertEquals("foo", environment.getPropertySources().get(0).getSource().get("foo"));
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryTests method tag.
@Test
public void tag() {
this.repository.setBasedir(this.basedir);
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);
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class ConfigClientOffIntegrationTests method contextLoads.
@Test
public void contextLoads() {
Environment environment = new TestRestTemplate().getForObject("http://localhost:" + this.port + "/foo/development/", Environment.class);
assertTrue(environment.getPropertySources().isEmpty());
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class SubversionConfigServerIntegrationTests method contextLoads.
@Test
public void contextLoads() {
Environment environment = new TestRestTemplate().getForObject("http://localhost:" + this.port + "/foo/development/", Environment.class);
assertFalse(environment.getPropertySources().isEmpty());
assertEquals("overrides", environment.getPropertySources().get(0).getName());
assertEquals("{spring.cloud.config.enabled=true}", environment.getPropertySources().get(0).getSource().toString());
}
Aggregations