Search in sources :

Example 36 with AnnotationConfigApplicationContext

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");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 37 with AnnotationConfigApplicationContext

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("******");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 38 with AnnotationConfigApplicationContext

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();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 39 with AnnotationConfigApplicationContext

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();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 40 with AnnotationConfigApplicationContext

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");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ZipkinMySQLStorageProperties(zipkin.autoconfigure.storage.mysql.ZipkinMySQLStorageProperties) Test(org.junit.Test)

Aggregations

AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)800 Test (org.junit.Test)528 DSLContext (org.jooq.DSLContext)53 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)42 ApplicationContext (org.springframework.context.ApplicationContext)25 Before (org.junit.Before)23 DIConfiguration (com.khartec.waltz.service.DIConfiguration)15 Filter (javax.servlet.Filter)15 Map (java.util.Map)14 OncePerRequestFilter (org.springframework.web.filter.OncePerRequestFilter)14 TestBean (org.springframework.tests.sample.beans.TestBean)13 PropertyPlaceholderAutoConfiguration (org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration)12 MockMvc (org.springframework.test.web.servlet.MockMvc)12 EntityKind (com.khartec.waltz.model.EntityKind)11 List (java.util.List)10 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)10 MockEnvironment (org.springframework.mock.env.MockEnvironment)10 EntityReference (com.khartec.waltz.model.EntityReference)9 MapPropertySource (org.springframework.core.env.MapPropertySource)9 IOException (java.io.IOException)8