Refactor server into packages
Also removes getDefaultLabel() from EnvironmentRepository.
This commit is contained in:
@@ -14,7 +14,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.ConfigServerApplication;
|
||||
import org.springframework.cloud.config.server.ConfigServerTestUtils;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@@ -20,6 +20,9 @@ import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.ConfigClientOffIntegrationTests.TestConfiguration;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.resource.ResourceRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -20,6 +20,9 @@ import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.ConfigClientOnIntegrationTests.TestConfiguration;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.resource.ResourceRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.ConfigServerApplication;
|
||||
import org.springframework.cloud.config.server.ConfigServerTestUtils;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@@ -15,24 +15,25 @@
|
||||
*/
|
||||
package org.springframework.cloud.config.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.environment.SvnKitEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* @author Michael Prankl
|
||||
* @author Dave Syer
|
||||
@@ -61,7 +62,7 @@ public class SubversionConfigServerIntegrationTests {
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
Environment environment = new TestRestTemplate().getForObject("http://localhost:"
|
||||
+ port + "/foo/development/", Environment.class);
|
||||
+ this.port + "/foo/development/", Environment.class);
|
||||
assertFalse(environment.getPropertySources().isEmpty());
|
||||
assertEquals("overrides", environment.getPropertySources().get(0).getName());
|
||||
assertEquals("{spring.cloud.config.enabled=true}", environment
|
||||
@@ -70,7 +71,7 @@ public class SubversionConfigServerIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void defaultLabel() throws Exception {
|
||||
EnvironmentRepository repository = context.getBean(EnvironmentRepository.class);
|
||||
SvnKitEnvironmentRepository repository = this.context.getBean(SvnKitEnvironmentRepository.class);
|
||||
assertEquals("trunk", repository.getDefaultLabel());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.ConfigServerApplication;
|
||||
import org.springframework.cloud.config.server.ConfigServerTestUtils;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
@@ -10,6 +10,8 @@ import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.config.ConfigServerHealthIndicator;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -4,7 +4,6 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.http.MediaType.TEXT_PLAIN;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.config.server.ConfigServerProperties;
|
||||
import org.springframework.security.crypto.encrypt.Encryptors;
|
||||
|
||||
/**
|
||||
@@ -14,9 +13,8 @@ import org.springframework.security.crypto.encrypt.Encryptors;
|
||||
|
||||
public class EncryptionControllerMultiTextEncryptorTests {
|
||||
|
||||
ConfigServerProperties properties = new ConfigServerProperties();
|
||||
EncryptionController controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(Encryptors.noOpText()), this.properties);
|
||||
new SingleTextEncryptorLocator(Encryptors.noOpText()));
|
||||
|
||||
String application = "application";
|
||||
String profiles = "profile1,profile2";
|
||||
@@ -25,8 +23,8 @@ public class EncryptionControllerMultiTextEncryptorTests {
|
||||
@Test
|
||||
public void shouldEncryptUsingApplicationAndProfiles() {
|
||||
|
||||
this.controller = new EncryptionController(new SingleTextEncryptorLocator(
|
||||
Encryptors.text("application", "11")), this.properties);
|
||||
this.controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(Encryptors.text("application", "11")));
|
||||
|
||||
// when
|
||||
String encrypted = this.controller.encrypt(this.application, this.profiles,
|
||||
|
||||
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.config.server.ConfigServerProperties;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.crypto.encrypt.Encryptors;
|
||||
import org.springframework.security.crypto.encrypt.TextEncryptor;
|
||||
@@ -34,9 +33,8 @@ import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
|
||||
*/
|
||||
public class EncryptionControllerTests {
|
||||
|
||||
private ConfigServerProperties properties = new ConfigServerProperties();
|
||||
private EncryptionController controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(Encryptors.noOpText()), this.properties);
|
||||
new SingleTextEncryptorLocator(Encryptors.noOpText()));
|
||||
|
||||
@Test(expected = KeyNotInstalledException.class)
|
||||
public void cannotDecryptWithoutKey() {
|
||||
@@ -50,24 +48,24 @@ public class EncryptionControllerTests {
|
||||
|
||||
@Test
|
||||
public void sunnyDayRsaKey() {
|
||||
this.controller = new EncryptionController(new SingleTextEncryptorLocator(
|
||||
new RsaSecretEncryptor()), this.properties);
|
||||
this.controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(new RsaSecretEncryptor()));
|
||||
String cipher = this.controller.encrypt("foo", MediaType.TEXT_PLAIN);
|
||||
assertEquals("foo", this.controller.decrypt(cipher, MediaType.TEXT_PLAIN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publicKey() {
|
||||
this.controller = new EncryptionController(new SingleTextEncryptorLocator(
|
||||
new RsaSecretEncryptor()), this.properties);
|
||||
this.controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(new RsaSecretEncryptor()));
|
||||
String key = this.controller.getPublicKey();
|
||||
assertTrue("Wrong key format: " + key, key.startsWith("ssh-rsa"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appAndProfile() {
|
||||
this.controller = new EncryptionController(new SingleTextEncryptorLocator(
|
||||
new RsaSecretEncryptor()), this.properties);
|
||||
this.controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(new RsaSecretEncryptor()));
|
||||
// Add space to input
|
||||
String cipher = this.controller.encrypt("app", "default", "foo bar",
|
||||
MediaType.TEXT_PLAIN);
|
||||
@@ -78,8 +76,8 @@ public class EncryptionControllerTests {
|
||||
|
||||
@Test
|
||||
public void formDataIn() {
|
||||
this.controller = new EncryptionController(new SingleTextEncryptorLocator(
|
||||
new RsaSecretEncryptor()), this.properties);
|
||||
this.controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(new RsaSecretEncryptor()));
|
||||
// Add space to input
|
||||
String cipher = this.controller.encrypt("foo bar=",
|
||||
MediaType.APPLICATION_FORM_URLENCODED);
|
||||
@@ -90,8 +88,8 @@ public class EncryptionControllerTests {
|
||||
|
||||
@Test
|
||||
public void formDataInWithPrefix() {
|
||||
this.controller = new EncryptionController(new SingleTextEncryptorLocator(
|
||||
new RsaSecretEncryptor()), this.properties);
|
||||
this.controller = new EncryptionController(
|
||||
new SingleTextEncryptorLocator(new RsaSecretEncryptor()));
|
||||
// Add space to input
|
||||
String cipher = this.controller.encrypt("{key:test}foo bar=",
|
||||
MediaType.APPLICATION_FORM_URLENCODED);
|
||||
@@ -111,7 +109,7 @@ public class EncryptionControllerTests {
|
||||
return this.encryptor;
|
||||
}
|
||||
};
|
||||
this.controller = new EncryptionController(locator, this.properties);
|
||||
this.controller = new EncryptionController(locator);
|
||||
// Add space to input
|
||||
String cipher = this.controller.encrypt("app", "default", "foo bar",
|
||||
MediaType.TEXT_PLAIN);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
@@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.EnvironmentControllerIntegrationTests.ControllerConfiguration;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentControllerIntegrationTests.ControllerConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -56,26 +56,25 @@ public class EnvironmentControllerIntegrationTests {
|
||||
@Before
|
||||
public void init() {
|
||||
Mockito.reset(this.repository);
|
||||
Mockito.when(this.repository.getDefaultLabel()).thenReturn("master");
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void environmentNoLabel() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "default", "master")).thenReturn(
|
||||
Mockito.when(this.repository.findOne("foo", "default", null)).thenReturn(
|
||||
new Environment("foo", "default"));
|
||||
this.mvc.perform(MockMvcRequestBuilders.get("/foo/default")).andExpect(
|
||||
MockMvcResultMatchers.status().isOk());
|
||||
Mockito.verify(this.repository).findOne("foo", "default", "master");
|
||||
Mockito.verify(this.repository).findOne("foo", "default", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertiesNoLabel() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "default", "master")).thenReturn(
|
||||
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", "master");
|
||||
Mockito.verify(this.repository).findOne("foo", "default", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,7 +128,6 @@ public class EnvironmentControllerIntegrationTests {
|
||||
@Bean
|
||||
public EnvironmentRepository environmentRepository() {
|
||||
EnvironmentRepository repository = Mockito.mock(EnvironmentRepository.class);
|
||||
Mockito.when(repository.getDefaultLabel()).thenReturn("master");
|
||||
return repository;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -53,7 +53,6 @@ public class EnvironmentControllerTests {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
Mockito.when(this.repository.getDefaultLabel()).thenReturn("master");
|
||||
this.controller = new EnvironmentController(this.repository);
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ public class EnvironmentControllerTests {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("a.b.c", "d");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("a:\n b:\n c: d\n", yaml);
|
||||
}
|
||||
@@ -74,7 +73,7 @@ public class EnvironmentControllerTests {
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
this.environment.addFirst(new PropertySource("two", Collections.singletonMap("a.b.c",
|
||||
"e")));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("a:\n b:\n c: e\n", yaml);
|
||||
}
|
||||
@@ -85,7 +84,7 @@ public class EnvironmentControllerTests {
|
||||
map.put("a.b[0]", "c");
|
||||
map.put("a.b[1]", "d");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("a:\n b:\n - c\n - d\n", yaml);
|
||||
}
|
||||
@@ -95,7 +94,7 @@ public class EnvironmentControllerTests {
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
map.put("document", "blah");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("blah\n", yaml);
|
||||
}
|
||||
@@ -106,7 +105,7 @@ public class EnvironmentControllerTests {
|
||||
map.put("document[0]", "c");
|
||||
map.put("document[1]", "d");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("- c\n- d\n", yaml);
|
||||
}
|
||||
@@ -117,7 +116,7 @@ public class EnvironmentControllerTests {
|
||||
map.put("document[0].a", "c");
|
||||
map.put("document[1].a", "d");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("- a: c\n- a: d\n", yaml);
|
||||
}
|
||||
@@ -129,7 +128,7 @@ public class EnvironmentControllerTests {
|
||||
map.put("a.b[0].d", "e");
|
||||
map.put("a.b[1].c", "d");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertTrue("Wrong output: " + yaml,
|
||||
"a:\n b:\n - d: e\n c: d\n - c: d\n".equals(yaml)
|
||||
@@ -142,7 +141,7 @@ public class EnvironmentControllerTests {
|
||||
map.put("b[0].c", "d");
|
||||
map.put("b[1].c", "d");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("b:\n- c: d\n- c: d\n", yaml);
|
||||
}
|
||||
@@ -153,14 +152,14 @@ public class EnvironmentControllerTests {
|
||||
map.put("x.a.b[0].c", "d");
|
||||
map.put("x.a.b[1].c", "d");
|
||||
this.environment.add(new PropertySource("one", map));
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
String yaml = this.controller.yaml("foo", "bar").getBody();
|
||||
assertEquals("x:\n a:\n b:\n - c: d\n - c: d\n", yaml);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mappingForEnvironment() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(this.controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/foo/bar")).andExpect(
|
||||
MockMvcResultMatchers.status().isOk());
|
||||
@@ -176,7 +175,7 @@ public class EnvironmentControllerTests {
|
||||
|
||||
@Test
|
||||
public void mappingForYaml() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(this.controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/foo-bar.yml"))
|
||||
.andExpect(
|
||||
@@ -186,7 +185,7 @@ public class EnvironmentControllerTests {
|
||||
|
||||
@Test
|
||||
public void mappingForJson() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(this.controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/foo-bar.json"))
|
||||
.andExpect(
|
||||
@@ -214,7 +213,7 @@ public class EnvironmentControllerTests {
|
||||
|
||||
@Test
|
||||
public void mappingForProperties() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(this.controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/foo-bar.properties")).andExpect(
|
||||
MockMvcResultMatchers.content().contentType(MediaType.TEXT_PLAIN));
|
||||
@@ -239,7 +238,7 @@ public class EnvironmentControllerTests {
|
||||
|
||||
@Test
|
||||
public void mappingforJsonProperties() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "bar", "master")).thenReturn(this.environment);
|
||||
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(this.controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/foo-bar.json")).andExpect(
|
||||
MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON));
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -46,7 +46,6 @@ public class EnvironmentEncryptorEnvironmentRepositoryTests {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
Mockito.when(this.repository.getDefaultLabel()).thenReturn("master");
|
||||
this.controller = new EnvironmentEncryptorEnvironmentRepository(this.repository);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -34,6 +34,8 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.config.EnvironmentRepositoryConfiguration;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -34,6 +34,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.config.EnvironmentRepositoryConfiguration;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -122,8 +123,8 @@ public class JGitEnvironmentRepositoryIntegrationTests {
|
||||
String uri = ConfigServerTestUtils.prepareLocalRepo();
|
||||
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
.properties("spring.cloud.config.server.git.uri:" + uri).run();
|
||||
EnvironmentRepository repository = this.context
|
||||
.getBean(EnvironmentRepository.class);
|
||||
JGitEnvironmentRepository repository = this.context
|
||||
.getBean(JGitEnvironmentRepository.class);
|
||||
assertEquals("master", repository.getDefaultLabel());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -34,6 +34,8 @@ import org.eclipse.jgit.util.FileUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.environment.JGitEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -31,6 +31,8 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.config.EnvironmentRepositoryConfiguration;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -24,9 +24,9 @@ import java.util.Map;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.ConfigServerTestUtils;
|
||||
import org.springframework.cloud.config.server.MultipleJGitEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepository;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -25,23 +27,22 @@ import java.nio.charset.Charset;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.config.EnvironmentRepositoryConfiguration;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
import org.tmatesoft.svn.core.wc2.SvnCheckout;
|
||||
import org.tmatesoft.svn.core.wc2.SvnCommit;
|
||||
import org.tmatesoft.svn.core.wc2.SvnOperationFactory;
|
||||
import org.tmatesoft.svn.core.wc2.SvnTarget;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.config.EnvironmentRepositoryConfiguration;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Michael Prankl
|
||||
@@ -55,16 +56,16 @@ public class SVNKitEnvironmentRepositoryIntegrationTests {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
workingDir = new File("target/repos/svn-config-repo-update");
|
||||
if (workingDir.exists()) {
|
||||
FileSystemUtils.deleteRecursively(workingDir);
|
||||
this.workingDir = new File("target/repos/svn-config-repo-update");
|
||||
if (this.workingDir.exists()) {
|
||||
FileSystemUtils.deleteRecursively(this.workingDir);
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,10 +73,10 @@ public class SVNKitEnvironmentRepositoryIntegrationTests {
|
||||
public void vanilla() throws Exception {
|
||||
String uri = ConfigServerTestUtils.prepareLocalSvnRepo(
|
||||
"src/test/resources/svn-config-repo", "target/config");
|
||||
context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
.profiles("subversion")
|
||||
.run("--spring.cloud.config.server.svn.uri=" + uri);
|
||||
EnvironmentRepository repository = context.getBean(EnvironmentRepository.class);
|
||||
EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
|
||||
repository.findOne("bar", "staging", "trunk");
|
||||
Environment environment = repository.findOne("bar", "staging", "trunk");
|
||||
assertEquals(2, environment.getPropertySources().size());
|
||||
@@ -85,10 +86,10 @@ public class SVNKitEnvironmentRepositoryIntegrationTests {
|
||||
public void update() throws Exception {
|
||||
String uri = ConfigServerTestUtils.prepareLocalSvnRepo(
|
||||
"src/test/resources/svn-config-repo", "target/config");
|
||||
context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
.profiles("subversion")
|
||||
.run("--spring.cloud.config.server.svn.uri=" + uri);
|
||||
EnvironmentRepository repository = context.getBean(EnvironmentRepository.class);
|
||||
EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
|
||||
repository.findOne("bar", "staging", "trunk");
|
||||
Environment environment = repository.findOne("bar", "staging", "trunk");
|
||||
assertEquals("bar", environment.getPropertySources().get(0).getSource()
|
||||
@@ -104,11 +105,11 @@ public class SVNKitEnvironmentRepositoryIntegrationTests {
|
||||
SvnOperationFactory svnFactory = new SvnOperationFactory();
|
||||
final SvnCheckout checkout = svnFactory.createCheckout();
|
||||
checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(uri)));
|
||||
checkout.setSingleTarget(SvnTarget.fromFile(workingDir));
|
||||
checkout.setSingleTarget(SvnTarget.fromFile(this.workingDir));
|
||||
checkout.run();
|
||||
|
||||
// update bar.properties
|
||||
File barProps = new File(workingDir, "trunk/bar.properties");
|
||||
File barProps = new File(this.workingDir, "trunk/bar.properties");
|
||||
StreamUtils.copy("foo: foo", Charset.defaultCharset(), new FileOutputStream(
|
||||
barProps));
|
||||
// commit to repo
|
||||
@@ -122,10 +123,10 @@ public class SVNKitEnvironmentRepositoryIntegrationTests {
|
||||
public void defaultLabel() throws Exception {
|
||||
String uri = ConfigServerTestUtils.prepareLocalSvnRepo(
|
||||
"src/test/resources/svn-config-repo", "target/config");
|
||||
context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
.profiles("subversion")
|
||||
.run("--spring.cloud.config.server.svn.uri=" + uri);
|
||||
EnvironmentRepository repository = context.getBean(EnvironmentRepository.class);
|
||||
SvnKitEnvironmentRepository repository = this.context.getBean(SvnKitEnvironmentRepository.class);
|
||||
assertEquals("trunk", repository.getDefaultLabel());
|
||||
}
|
||||
|
||||
@@ -133,10 +134,10 @@ public class SVNKitEnvironmentRepositoryIntegrationTests {
|
||||
public void invalidLabel() throws Exception {
|
||||
String uri = ConfigServerTestUtils.prepareLocalSvnRepo(
|
||||
"src/test/resources/svn-config-repo", "target/config");
|
||||
context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
|
||||
.profiles("subversion")
|
||||
.run("--spring.cloud.config.server.svn.uri=" + uri);
|
||||
EnvironmentRepository repository = context.getBean(EnvironmentRepository.class);
|
||||
EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
|
||||
repository.findOne("bar", "staging", "unknownlabel");
|
||||
Environment environment = repository.findOne("bar", "staging", "unknownlabel");
|
||||
assertEquals(0, environment.getPropertySources().size());
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -23,6 +23,9 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.environment.NoSuchLabelException;
|
||||
import org.springframework.cloud.config.server.environment.SvnKitEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.resource;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -22,6 +22,10 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepositoryTests;
|
||||
import org.springframework.cloud.config.server.resource.GenericResourceRepository;
|
||||
import org.springframework.cloud.config.server.resource.NoSuchResourceException;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
package org.springframework.cloud.config.server.resource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -22,6 +22,10 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepositoryTests;
|
||||
import org.springframework.cloud.config.server.resource.GenericResourceRepository;
|
||||
import org.springframework.cloud.config.server.resource.ResourceController;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
Reference in New Issue
Block a user