Search in sources :

Example 1 with SpringTransactionHooks

use of cucumber.api.spring.SpringTransactionHooks in project cucumber-jvm by cucumber.

the class SpringTransactionHooksTest method shouldObtainPlatformTransactionManagerByTypeWhenTxnManagerBeanNameNotSet.

@Test
public void shouldObtainPlatformTransactionManagerByTypeWhenTxnManagerBeanNameNotSet() {
    SpringTransactionHooks localTarget = new SpringTransactionHooks();
    localTarget.setBeanFactory(mockedBeanFactory);
    when(mockedBeanFactory.getBean(PlatformTransactionManager.class)).thenReturn(mockedPlatformTransactionManager);
    assertSame(localTarget.obtainPlatformTransactionManager(), mockedPlatformTransactionManager);
    verify(mockedBeanFactory).getBean(PlatformTransactionManager.class);
}
Also used : SpringTransactionHooks(cucumber.api.spring.SpringTransactionHooks) Test(org.junit.Test)

Example 2 with SpringTransactionHooks

use of cucumber.api.spring.SpringTransactionHooks in project cucumber-jvm by cucumber.

the class SpringTransactionHooksTest method shouldObtainPlatformTransactionManagerByNameWhenTxnManagerBeanNameIsSet.

@Test
public void shouldObtainPlatformTransactionManagerByNameWhenTxnManagerBeanNameIsSet() {
    SpringTransactionHooks localTarget = new SpringTransactionHooks();
    localTarget.setBeanFactory(mockedBeanFactory);
    final String txnManagerBeanName = "myTxnManagerBeanName";
    localTarget.setTxnManagerBeanName(txnManagerBeanName);
    when(mockedBeanFactory.getBean(txnManagerBeanName, PlatformTransactionManager.class)).thenReturn(mockedPlatformTransactionManager);
    assertSame(localTarget.obtainPlatformTransactionManager(), mockedPlatformTransactionManager);
    verify(mockedBeanFactory).getBean(txnManagerBeanName, PlatformTransactionManager.class);
}
Also used : SpringTransactionHooks(cucumber.api.spring.SpringTransactionHooks) Test(org.junit.Test)

Example 3 with SpringTransactionHooks

use of cucumber.api.spring.SpringTransactionHooks in project cucumber-jvm by cucumber.

the class SpringTransactionHooksTest method setUp.

@Before
public void setUp() {
    target = new SpringTransactionHooks() {

        @Override
        public PlatformTransactionManager obtainPlatformTransactionManager() {
            return mockedPlatformTransactionManager;
        }
    };
    target.setBeanFactory(mockedBeanFactory);
}
Also used : SpringTransactionHooks(cucumber.api.spring.SpringTransactionHooks) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) Before(org.junit.Before)

Aggregations

SpringTransactionHooks (cucumber.api.spring.SpringTransactionHooks)3 Test (org.junit.Test)2 Before (org.junit.Before)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1