Examples of CallCountingTransactionManager


Examples of org.springframework.tests.transaction.CallCountingTransactionManager

    ctx.refresh();

    Thread.sleep(100); // allow @Scheduled method to be called several times

    MyRepository repository = ctx.getBean(MyRepository.class);
    CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
    assertThat("repository is not a proxy", AopUtils.isAopProxy(repository), equalTo(true));
    assertThat("@Scheduled method never called", repository.getInvocationCount(), greaterThan(0));
    assertThat("no transactions were committed", txManager.commits, greaterThan(0));
  }
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

    ctx.refresh();

    Thread.sleep(50); // allow @Scheduled method to be called several times

    MyRepositoryWithScheduledMethod repository = ctx.getBean(MyRepositoryWithScheduledMethod.class);
    CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
    assertThat("repository is not a proxy", AopUtils.isAopProxy(repository), is(true));
    assertThat("@Scheduled method never called", repository.getInvocationCount(), greaterThan(0));
    assertThat("no transactions were committed", txManager.commits, greaterThan(0));
  }
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

      return new PersistenceExceptionTranslationPostProcessor();
    }

    @Bean
    public PlatformTransactionManager txManager() {
      return new CallCountingTransactionManager();
    }
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"annotationDrivenConfigurationClassTests.xml"}, getClass(), parent);
    doTestWithMultipleTransactionManagers(context);
  }

  private void doTestWithMultipleTransactionManagers(ApplicationContext context) {
    CallCountingTransactionManager tm1 = context.getBean("transactionManager1", CallCountingTransactionManager.class);
    CallCountingTransactionManager tm2 = context.getBean("transactionManager2", CallCountingTransactionManager.class);
    TransactionalService service = context.getBean("service", TransactionalService.class);
    assertTrue(AopUtils.isCglibProxy(service));
    service.setSomething("someName");
    assertEquals(1, tm1.commits);
    assertEquals(0, tm2.commits);
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

public class AnnotationTransactionAttributeSourceTests {

  @Test
  public void testSerializable() throws Exception {
    TestBean1 tb = new TestBean1();
    CallCountingTransactionManager ptm = new CallCountingTransactionManager();
    AnnotationTransactionAttributeSource tas = new AnnotationTransactionAttributeSource();
    TransactionInterceptor ti = new TransactionInterceptor(ptm, tas);

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setInterfaces(new Class[] {ITestBean.class});
    proxyFactory.addAdvice(ti);
    proxyFactory.setTarget(tb);
    ITestBean proxy = (ITestBean) proxyFactory.getProxy();
    proxy.getAge();
    assertEquals(1, ptm.commits);

    ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
    serializedProxy.getAge();
    Advised advised = (Advised) serializedProxy;
    TransactionInterceptor serializedTi = (TransactionInterceptor) advised.getAdvisors()[0].getAdvice();
    CallCountingTransactionManager serializedPtm =
        (CallCountingTransactionManager) serializedTi.getTransactionManager();
    assertEquals(2, serializedPtm.commits);
  }
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

public class TransactionManagerConfiguration {

  @Bean
  @Qualifier("synch")
  public PlatformTransactionManager transactionManager1() {
    return new CallCountingTransactionManager();
  }
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

  }

  @Bean
  @Qualifier("noSynch")
  public PlatformTransactionManager transactionManager2() {
    CallCountingTransactionManager tm = new CallCountingTransactionManager();
    tm.setTransactionSynchronization(CallCountingTransactionManager.SYNCHRONIZATION_NEVER);
    return tm;
  }
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

    assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
  }

  public void testInvokeTransactional() throws Exception {
    ITestBean testBean = getTestBean();
    CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager");

    // try with transactional
    assertEquals("Should not have any started transactions", 0, ptm.begun);
    testBean.getName();
    assertTrue(ptm.lastDefinition.isReadOnly());
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

    ImplementsNoInterfaces ini = (ImplementsNoInterfaces) factory.getBean("cglibNoInterfaces");
    assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(ini));
    String newName = "Gordon";

    // Install facade
    CallCountingTransactionManager ptm = new CallCountingTransactionManager();
    PlatformTransactionManagerFacade.delegate = ptm;

    ini.setName(newName);
    assertEquals(newName, ini.getName());
    assertEquals(2, ptm.commits);
View Full Code Here

Examples of org.springframework.tests.transaction.CallCountingTransactionManager

  /**
   * Test that we can set the target to a dynamic TargetSource.
   */
  public void testDynamicTargetSource() throws NoSuchMethodException {
    // Install facade
    CallCountingTransactionManager txMan = new CallCountingTransactionManager();
    PlatformTransactionManagerFacade.delegate = txMan;

    TestBean tb = (TestBean) factory.getBean("hotSwapped");
    assertEquals(666, tb.getAge());
    int newAge = 557;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.