Search in sources :

Example 21 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.

the class ZipkinElasticsearchStorageAutoConfigurationTest method canOverridesProperty_hostsWithList.

@Test
public void canOverridesProperty_hostsWithList() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.hosts:host1:9300,host2:9300");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinElasticsearchStorageAutoConfiguration.class);
    context.refresh();
    assertThat(context.getBean(ZipkinElasticsearchStorageProperties.class).getHosts()).containsExactly("host1:9300", "host2:9300");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ZipkinElasticsearchStorageProperties(zipkin.autoconfigure.storage.elasticsearch.ZipkinElasticsearchStorageProperties) Test(org.junit.Test)

Example 22 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.

the class ZipkinElasticsearchStorageAutoConfigurationTest method dailyIndexFormat_overridingDateSeparator.

@Test
public void dailyIndexFormat_overridingDateSeparator() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.date-separator:.");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinElasticsearchStorageAutoConfiguration.class);
    context.refresh();
    assertThat(es().indexNameFormatter.indexNameForTimestamp(0)).isEqualTo("zipkin-1970.01.01");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 23 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.

the class ZipkinElasticsearchStorageAutoConfigurationTest method dailyIndexFormat_overridingPrefix.

@Test
public void dailyIndexFormat_overridingPrefix() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.index:zipkin_prod");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinElasticsearchStorageAutoConfiguration.class);
    context.refresh();
    assertThat(es().indexNameFormatter.indexNameForTimestamp(0)).isEqualTo("zipkin_prod-1970-01-01");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 24 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.

the class ZipkinElasticsearchAwsStorageAutoConfigurationTest method providesAWSSignatureVersion4_whenStorageTypeElasticsearchAndDomain.

@Test
public void providesAWSSignatureVersion4_whenStorageTypeElasticsearchAndDomain() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.aws.domain:foobar", "zipkin.storage.elasticsearch.aws.region:us-west-2");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinElasticsearchOkHttpAutoConfiguration.class, ZipkinElasticsearchAwsStorageAutoConfiguration.class);
    context.refresh();
    assertThat(context.getBean(OkHttpClient.class).networkInterceptors()).extracting(i -> i.getClass()).contains((Class) AWSSignatureVersion4.class);
}
Also used : EnvironmentTestUtils.addEnvironment(org.springframework.boot.test.util.EnvironmentTestUtils.addEnvironment) OkHttpClient(okhttp3.OkHttpClient) Rule(org.junit.Rule) After(org.junit.After) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) ZipkinElasticsearchOkHttpAutoConfiguration(zipkin.autoconfigure.storage.elasticsearch.http.ZipkinElasticsearchOkHttpAutoConfiguration) ExpectedException(org.junit.rules.ExpectedException) PropertyPlaceholderAutoConfiguration(org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 25 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project zipkin by openzipkin.

the class ZipkinElasticsearchAwsStorageAutoConfigurationTest method doesntProvideAWSSignatureVersion4_whenStorageTypeElasticsearchAndHostsNotAwsUrls.

@Test
public void doesntProvideAWSSignatureVersion4_whenStorageTypeElasticsearchAndHostsNotAwsUrls() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.hosts:https://localhost:9200");
    context.register(PropertyPlaceholderAutoConfiguration.class, ZipkinElasticsearchAwsStorageAutoConfiguration.class);
    context.refresh();
    thrown.expect(NoSuchBeanDefinitionException.class);
    context.getBean(AWSSignatureVersion4.class);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Aggregations

AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)694 Test (org.junit.Test)513 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)42 Before (org.junit.Before)21 ApplicationContext (org.springframework.context.ApplicationContext)19 Filter (javax.servlet.Filter)15 OncePerRequestFilter (org.springframework.web.filter.OncePerRequestFilter)14 Map (java.util.Map)13 TestBean (org.springframework.tests.sample.beans.TestBean)13 PropertyPlaceholderAutoConfiguration (org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration)12 MockMvc (org.springframework.test.web.servlet.MockMvc)12 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)10 MockEnvironment (org.springframework.mock.env.MockEnvironment)10 MapPropertySource (org.springframework.core.env.MapPropertySource)9 HashMap (java.util.HashMap)8 ConcurrentMapCache (org.springframework.cache.concurrent.ConcurrentMapCache)7 MBeanExporter (org.springframework.jmx.export.MBeanExporter)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7 Ignore (org.junit.Ignore)6 Method (java.lang.reflect.Method)5