@Test
 public void testProxyFactory2Lazy() throws NoSuchMethodException {
   ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Lazy");
   assertFalse(factory.containsSingleton("target"));
   assertEquals(666, testBean.getAge());
   assertTrue(factory.containsSingleton("target"));
 }
 @Test
 public void testGetsAreNotTransactionalWithProxyFactory2DynamicProxy()
     throws NoSuchMethodException {
   this.factory.preInstantiateSingletons();
   ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2DynamicProxy");
   assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass()));
   doTestGetsAreNotTransactional(testBean);
 }
  private void doTestGetsAreNotTransactional(final ITestBean testBean) {
    // Install facade
    PlatformTransactionManager ptm = mock(PlatformTransactionManager.class);
    PlatformTransactionManagerFacade.delegate = ptm;

    assertTrue("Age should not be " + testBean.getAge(), testBean.getAge() == 666);

    // Expect no methods
    verifyZeroInteractions(ptm);

    // Install facade expecting a call
    final TransactionStatus ts = mock(TransactionStatus.class);
    ptm =
        new PlatformTransactionManager() {
          private boolean invoked;

          @Override
          public TransactionStatus getTransaction(TransactionDefinition def)
              throws TransactionException {
            if (invoked) {
              throw new IllegalStateException(
                  "getTransaction should not get invoked more than once");
            }
            invoked = true;
            if (!(def.getName().contains(DerivedTestBean.class.getName())
                && def.getName().contains("setAge"))) {
              throw new IllegalStateException(
                  "transaction name should contain class and method name: " + def.getName());
            }
            return ts;
          }

          @Override
          public void commit(TransactionStatus status) throws TransactionException {
            assertTrue(status == ts);
          }

          @Override
          public void rollback(TransactionStatus status) throws TransactionException {
            throw new IllegalStateException("rollback should not get invoked");
          }
        };
    PlatformTransactionManagerFacade.delegate = ptm;

    // TODO same as old age to avoid ordering effect for now
    int age = 666;
    testBean.setAge(age);
    assertTrue(testBean.getAge() == age);
  }
 @Test
 public void testGetsAreNotTransactionalWithProxyFactory1() throws NoSuchMethodException {
   ITestBean testBean = (ITestBean) factory.getBean("proxyFactory1");
   assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass()));
   doTestGetsAreNotTransactional(testBean);
 }