Search in sources :

Example 86 with AnnotationConfigApplicationContext

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

the class EnableTransactionManagementIntegrationTests method repositoryIsTxProxy_withNonConventionalTxManagerName_fallsBackToByTypeLookup.

// TODO SPR-8207
@Ignore
// TODO SPR-8207
@Test
public void repositoryIsTxProxy_withNonConventionalTxManagerName_fallsBackToByTypeLookup() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class, NonConventionalTxManagerNameConfig.class);
    ctx.refresh();
    assertTxProxying(ctx);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 87 with AnnotationConfigApplicationContext

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

the class EnableTransactionManagementIntegrationTests method repositoryIsTxProxy_withCustomTxManagerName.

@Test
public void repositoryIsTxProxy_withCustomTxManagerName() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Config.class, CustomTxManagerNameConfig.class);
    ctx.refresh();
    assertTxProxying(ctx);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 88 with AnnotationConfigApplicationContext

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

the class EnableTransactionManagementIntegrationTests method explicitTxManager.

@Test
public void explicitTxManager() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(ExplicitTxManagerConfig.class);
    ctx.refresh();
    FooRepository fooRepository = ctx.getBean(FooRepository.class);
    fooRepository.findAll();
    CallCountingTransactionManager txManager1 = ctx.getBean("txManager1", CallCountingTransactionManager.class);
    assertThat(txManager1.begun, equalTo(1));
    assertThat(txManager1.commits, equalTo(1));
    assertThat(txManager1.rollbacks, equalTo(0));
    CallCountingTransactionManager txManager2 = ctx.getBean("txManager2", CallCountingTransactionManager.class);
    assertThat(txManager2.begun, equalTo(0));
    assertThat(txManager2.commits, equalTo(0));
    assertThat(txManager2.rollbacks, equalTo(0));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) CallCountingTransactionManager(org.springframework.tests.transaction.CallCountingTransactionManager) Test(org.junit.Test)

Example 89 with AnnotationConfigApplicationContext

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

the class EnvironmentSystemIntegrationTests method annotationConfigApplicationContext_withImportedConfigClasses.

@Test
public void annotationConfigApplicationContext_withImportedConfigClasses() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    assertHasStandardEnvironment(ctx);
    ctx.setEnvironment(prodEnv);
    ctx.register(Config.class);
    ctx.refresh();
    assertEnvironmentAwareInvoked(ctx, prodEnv);
    assertThat("should have prod bean", ctx.containsBean(PROD_BEAN_NAME), is(true));
    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 90 with AnnotationConfigApplicationContext

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

the class EnvironmentSystemIntegrationTests method mostSpecificDerivedClassDrivesEnvironment_withDevEnvAndDerivedDevConfigClass.

@Test
public void mostSpecificDerivedClassDrivesEnvironment_withDevEnvAndDerivedDevConfigClass() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.setEnvironment(devEnv);
    ctx.register(DerivedDevConfig.class);
    ctx.refresh();
    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have derived dev bean", ctx.containsBean(DERIVED_DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) 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