Search in sources :

Example 91 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class EnvironmentSystemIntegrationTests method annotationConfigApplicationContext_withProdEnvAndProdConfigClass.

@Test
public void annotationConfigApplicationContext_withProdEnvAndProdConfigClass() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    assertHasStandardEnvironment(ctx);
    ctx.setEnvironment(prodEnv);
    ctx.register(ProdConfig.class);
    ctx.refresh();
    assertThat("should have prod bean", ctx.containsBean(PROD_BEAN_NAME), is(true));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 92 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class EnvironmentSystemIntegrationTests method annotationConfigApplicationContext_withDevEnvAndDevConfigClass.

@Test
public void annotationConfigApplicationContext_withDevEnvAndDevConfigClass() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    assertHasStandardEnvironment(ctx);
    ctx.setEnvironment(devEnv);
    ctx.register(DevConfig.class);
    ctx.refresh();
    assertThat("should have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(true));
    assertThat("should have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(true));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 93 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class AnnotatedServiceWithoutInterface method annotatedService_PTC_false.

@Test
public void annotatedService_PTC_false() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PTCFalse.class, NonAnnotatedServiceImpl.class);
    ctx.refresh();
    AnnotatedService s = ctx.getBean(AnnotatedService.class);
    assertTrue("expected a jdk proxy", AopUtils.isJdkDynamicProxy(s));
    assertThat(s, not(instanceOf(NonAnnotatedServiceImpl.class)));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 94 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class AnnotatedServiceWithoutInterface method annotatedServiceWithoutInterface_PTC_true.

@Test
public void annotatedServiceWithoutInterface_PTC_true() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PTCTrue.class, AnnotatedServiceWithoutInterface.class);
    ctx.refresh();
    AnnotatedServiceWithoutInterface s = ctx.getBean(AnnotatedServiceWithoutInterface.class);
    assertTrue("expected a subclass proxy", AopUtils.isCglibProxy(s));
    assertThat(s, instanceOf(AnnotatedServiceWithoutInterface.class));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 95 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project camel by apache.

the class MongoDbSpringDslOperationsTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    applicationContext = new AnnotationConfigApplicationContext(MongoBasicOperationsConfiguration.class);
    CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
    return ctx;
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext)

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