Adding endpoint for .json similar to .yml, .yaml, and .properties
Fixes gh-113, fixes gh-112
This commit is contained in:
@@ -29,9 +29,6 @@ import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.environment.PropertySource;
|
||||
import org.springframework.cloud.config.server.EncryptionController;
|
||||
import org.springframework.cloud.config.server.EnvironmentController;
|
||||
import org.springframework.cloud.config.server.EnvironmentRepository;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
@@ -180,6 +177,31 @@ public class EnvironmentControllerTests {
|
||||
MockMvcResultMatchers.status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mappingforLabelledJsonProperties() throws Exception {
|
||||
Mockito.when(repository.findOne("foo", "bar", "other")).thenReturn(environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/other/foo-bar.json")).andExpect(
|
||||
MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mappingforJsonProperties() throws Exception {
|
||||
Mockito.when(repository.findOne("foo", "bar", "master")).thenReturn(environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/foo-bar.json")).andExpect(
|
||||
MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mappingForLabelledJsonPropertiesWithHyphen() throws Exception {
|
||||
Mockito.when(repository.findOne("foo", "bar-spam", "other")).thenReturn(
|
||||
environment);
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(controller).build();
|
||||
mvc.perform(MockMvcRequestBuilders.get("/other/foo-bar-spam.json")).andExpect(
|
||||
MockMvcResultMatchers.status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowOverrideFalse() throws Exception {
|
||||
controller.setOverrides(Collections.singletonMap("foo", "bar"));
|
||||
|
||||
Reference in New Issue
Block a user