use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class EnvironmentMvcEndpointTests method nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty.
@Test
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("my.foo", "${my.bar}");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources().addFirst(new MapPropertySource("unresolved-placeholder", map));
this.mvc.perform(get("/env/my.*")).andExpect(status().isOk()).andExpect(content().string(containsString("\"my.foo\":\"${my.bar}\"")));
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class EnvironmentMvcEndpointTests method nestedPathWithSensitivePlaceholderShouldSanitize.
@Test
public void nestedPathWithSensitivePlaceholderShouldSanitize() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("my.foo", "${my.password}");
map.put("my.password", "hello");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources().addFirst(new MapPropertySource("placeholder", map));
this.mvc.perform(get("/env/my.*")).andExpect(status().isOk()).andExpect(content().string(containsString("\"my.foo\":\"******\"")));
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class EnvironmentMvcEndpointTests method regex.
@Test
public void regex() throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("food", null);
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources().addFirst(new MapPropertySource("null-value", map));
this.mvc.perform(get("/env/foo.*")).andExpect(status().isOk()).andExpect(content().string(containsString("\"foo\":\"bar\""))).andExpect(content().string(containsString("\"fool\":\"baz\"")));
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method testCompositeSource.
@SuppressWarnings("unchecked")
@Test
public void testCompositeSource() throws Exception {
EnvironmentEndpoint report = getEndpointBean();
CompositePropertySource source = new CompositePropertySource("composite");
source.addPropertySource(new MapPropertySource("one", Collections.singletonMap("foo", (Object) "bar")));
source.addPropertySource(new MapPropertySource("two", Collections.singletonMap("foo", (Object) "spam")));
this.context.getEnvironment().getPropertySources().addFirst(source);
Map<String, Object> env = report.invoke();
assertThat(((Map<String, Object>) env.get("composite:one")).get("foo")).isEqualTo("bar");
}
use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.
the class FlywayAutoConfigurationTests method overrideBaselineVersionNumber.
@Test
public void overrideBaselineVersionNumber() throws Exception {
Map<String, Object> source = Collections.<String, Object>singletonMap("flyway.baseline-version", 1);
this.context.getEnvironment().getPropertySources().addLast(new MapPropertySource("flyway", source));
registerAndRefresh(EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
Flyway flyway = this.context.getBean(Flyway.class);
assertThat(flyway.getBaselineVersion()).isEqualTo(MigrationVersion.fromVersion("1"));
}
Aggregations