use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method nestedWithProfilePlaceholders.
@Test
public void nestedWithProfilePlaceholders() throws IOException {
String uri = ConfigServerTestUtils.prepareLocalRepo("nested-repo");
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).run("--spring.cloud.config.server.git.uri=" + uri, "--spring.cloud.config.server.git.searchPaths={profile}");
EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
repository.findOne("foo,bar", "staging", "master");
Environment environment = repository.findOne("staging", "foo,bar", "master");
assertEquals(3, environment.getPropertySources().size());
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method testShouldFailIfRemoteBranchWasDeleted.
@Test(expected = NoSuchLabelException.class)
public void testShouldFailIfRemoteBranchWasDeleted() throws Exception {
JGitConfigServerTestData testData = JGitConfigServerTestData.prepareClonedGitRepository(Collections.singleton("spring.cloud.config.server.git.deleteUntrackedBranches=true"), TestConfiguration.class);
String branchToDelete = "branchToDelete";
testData.getServerGit().getGit().branchCreate().setName(branchToDelete).call();
// checkout and simulate regular flow
Environment environment = testData.getRepository().findOne("bar", "staging", "branchToDelete");
assertNotNull(environment);
// remove branch
testData.getServerGit().getGit().branchDelete().setBranchNames(branchToDelete).call();
// test
testData.getRepository().findOne("bar", "staging", "branchToDelete");
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method nestedWithApplicationPlaceholders.
@Test
public void nestedWithApplicationPlaceholders() throws IOException {
String uri = ConfigServerTestUtils.prepareLocalRepo("nested-repo");
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).run("--spring.cloud.config.server.git.uri=" + uri, "--spring.cloud.config.server.git.searchPaths={application}");
EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
repository.findOne("foo,bar", "staging", "master");
Environment environment = repository.findOne("foo,bar", "staging", "master");
assertEquals(3, environment.getPropertySources().size());
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method testNewCommitID.
@Test
public void testNewCommitID() throws Exception {
JGitConfigServerTestData testData = JGitConfigServerTestData.prepareClonedGitRepository(TestConfiguration.class);
// get our starting versions
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");
assertEquals(environment.getVersion(), startingRemoteVersion);
// update the remote repo
FileOutputStream out = new FileOutputStream(new File(testData.getServerGit().getGitWorkingDirectory(), "bar.properties"));
StreamUtils.copy("foo: barNewCommit", Charset.defaultCharset(), out);
testData.getServerGit().getGit().add().addFilepattern("bar.properties").call();
testData.getServerGit().getGit().commit().setMessage("Updated for pull").call();
String updatedRemoteVersion = getCommitID(testData.getServerGit().getGit(), "master");
// do a normal request and verify we get the new version
environment = testData.getRepository().findOne("bar", "staging", "master");
assertEquals(environment.getVersion(), updatedRemoteVersion);
Object fooProperty = ConfigServerTestUtils.getProperty(environment, "bar.properties", "foo");
assertEquals(fooProperty, "barNewCommit");
// request the prior commit ID and make sure we get it
environment = testData.getRepository().findOne("bar", "staging", startingRemoteVersion);
assertEquals(environment.getVersion(), startingRemoteVersion);
fooProperty = ConfigServerTestUtils.getProperty(environment, "bar.properties", "foo");
assertEquals(fooProperty, "bar");
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method testNewRemoteBranch.
@Test
public void testNewRemoteBranch() throws Exception {
JGitConfigServerTestData testData = JGitConfigServerTestData.prepareClonedGitRepository(TestConfiguration.class);
Environment environment = testData.getRepository().findOne("bar", "staging", "master");
Object fooProperty = ConfigServerTestUtils.getProperty(environment, "bar.properties", "foo");
assertEquals(fooProperty, "bar");
testData.getServerGit().getGit().branchCreate().setName("testNewRemoteBranch").call();
testData.getServerGit().getGit().checkout().setName("testNewRemoteBranch").call();
// update the remote repo
FileOutputStream out = new FileOutputStream(new File(testData.getServerGit().getGitWorkingDirectory(), "/bar.properties"));
StreamUtils.copy("foo: branchBar", Charset.defaultCharset(), out);
testData.getServerGit().getGit().add().addFilepattern("bar.properties").call();
testData.getServerGit().getGit().commit().setMessage("Updated for branch test").call();
environment = testData.getRepository().findOne("bar", "staging", "testNewRemoteBranch");
fooProperty = ConfigServerTestUtils.getProperty(environment, "bar.properties", "foo");
assertEquals(fooProperty, "branchBar");
}
Aggregations