Search in sources :

Example 1 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project jersey by jersey.

the class SpringDevProfileResourceTest method configure.

@Override
protected Application configure() {
    System.setProperty("spring.profiles.active", "dev");
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.glassfish.jersey.server.spring.profiles");
    return new ResourceConfig().register(RequestContextFilter.class).register(LoggingFeature.class).packages("org.glassfish.jersey.server.spring.profiles").property("contextConfig", context);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) RequestContextFilter(org.glassfish.jersey.server.spring.scope.RequestContextFilter) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 2 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project jersey by jersey.

the class SpringProfilesTest method shouldGetDevProfileBean.

@Test
public void shouldGetDevProfileBean() {
    System.setProperty("spring.profiles.active", "dev");
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.glassfish.jersey.server.spring.profiles");
    assertEquals("dev", context.getBean(TestService.class).test());
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 3 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 4 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)

Example 5 with AnnotationConfigApplicationContext

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

the class ZipkinElasticsearchAwsStorageAutoConfigurationTest method doesntProvidesAWSSignatureVersion4_whenStorageTypeElasticsearchAndHostsNotUrls.

@Test
public void doesntProvidesAWSSignatureVersion4_whenStorageTypeElasticsearchAndHostsNotUrls() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.storage.type:elasticsearch");
    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)1332 Test (org.junit.Test)428 Test (org.junit.jupiter.api.Test)354 DSLContext (org.jooq.DSLContext)90 ApplicationContext (org.springframework.context.ApplicationContext)83 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)74 Properties (java.util.Properties)26 BeforeEach (org.junit.jupiter.api.BeforeEach)26 Before (org.junit.Before)24 TestBean (org.springframework.beans.testfixture.beans.TestBean)24 SimpleConfig (com.ctrip.framework.apollo.internals.SimpleConfig)23 IOException (java.io.IOException)22 List (java.util.List)19 Map (java.util.Map)19 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)17 ArrayList (java.util.ArrayList)16 Record1 (org.jooq.Record1)16 DIConfiguration (com.khartec.waltz.service.DIConfiguration)15 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)15 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)12