/* * Copyright 2015-2016 Norbert Potocki (norbert.potocki@nort.pl) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.cfg4j.source.git; import static org.assertj.core.api.Assertions.assertThat; import org.cfg4j.provider.ConfigurationProvider; import org.cfg4j.provider.ConfigurationProviderBuilder; import org.cfg4j.source.ConfigurationSource; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.nio.file.Paths; public class SimpleConfigurationProviderIntegrationTest { @Rule public ExpectedException expectedException = ExpectedException.none(); private TempConfigurationGitRepo remoteRepo; @Before public void setUp() throws Exception { remoteRepo = new TempConfigurationGitRepo("org.cfg4j-test-repo.git"); remoteRepo.changeProperty(Paths.get("application.properties"), "some.setting", "masterValue"); } @After public void tearDown() throws Exception { remoteRepo.remove(); } @Test public void readsConfigsFromGitConfigurationSource() throws Exception { ConfigurationSource source = new GitConfigurationSourceBuilder() .withRepositoryURI(remoteRepo.dirPath.toString()) .build(); ConfigurationProvider provider = new ConfigurationProviderBuilder() .withConfigurationSource(source) .build(); assertThat(provider.getProperty("some.setting", String.class)).isEqualTo("masterValue"); } }