use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointTests method testKeySanitizationWithCustomPatternByEnvironment.
@SuppressWarnings("unchecked")
@Test
public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "endpoints.configprops.keys-to-sanitize: .*pass.*");
this.context.register(Config.class);
this.context.refresh();
ConfigurationPropertiesReportEndpoint report = getEndpointBean();
Map<String, Object> properties = report.invoke();
Map<String, Object> nestedProperties = (Map<String, Object>) ((Map<String, Object>) properties.get("testProperties")).get("properties");
assertThat(nestedProperties).isNotNull();
assertThat(nestedProperties.get("dbPassword")).isEqualTo("******");
assertThat(nestedProperties.get("myTestProperty")).isEqualTo("654321");
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointTests method testKeySanitizationWithCustomKeysByEnvironment.
@SuppressWarnings("unchecked")
@Test
public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "endpoints.configprops.keys-to-sanitize:property");
this.context.register(Config.class);
this.context.refresh();
ConfigurationPropertiesReportEndpoint report = getEndpointBean();
Map<String, Object> properties = report.invoke();
Map<String, Object> nestedProperties = (Map<String, Object>) ((Map<String, Object>) properties.get("testProperties")).get("properties");
assertThat(nestedProperties).isNotNull();
assertThat(nestedProperties.get("dbPassword")).isEqualTo("123456");
assertThat(nestedProperties.get("myTestProperty")).isEqualTo("******");
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.
the class ZipkinElasticsearchStorageAutoConfigurationTest method strictTraceId_defaultsToTrue.
@Test
public void strictTraceId_defaultsToTrue() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "zipkin.storage.type:elasticsearch");
context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinElasticsearchStorageAutoConfiguration.class);
context.refresh();
assertThat(es().strictTraceId).isTrue();
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.
the class ZipkinMySQLStorageAutoConfigurationTest method providesStorageComponent_whenStorageTypeMySQL.
@Test
public void providesStorageComponent_whenStorageTypeMySQL() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "zipkin.storage.type:mysql");
context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinMySQLStorageAutoConfiguration.class);
context.refresh();
assertThat(context.getBean(MySQLStorage.class)).isNotNull();
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.
the class ZipkinMySQLStorageAutoConfigurationTest method canOverridesProperty_username.
@Test
public void canOverridesProperty_username() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "zipkin.storage.type:mysql", "zipkin.storage.mysql.username:robot");
context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinMySQLStorageAutoConfiguration.class);
context.refresh();
assertThat(context.getBean(ZipkinMySQLStorageProperties.class).getUsername()).isEqualTo("robot");
}
Aggregations