use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class BeanFactoryTransactionTests method testGetsAreNotTransactionalWithProxyFactory3.
@Test
public void testGetsAreNotTransactionalWithProxyFactory3() throws NoSuchMethodException {
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory3");
assertTrue("testBean is a full proxy", testBean instanceof DerivedTestBean);
assertTrue(testBean instanceof TransactionalProxy);
InvocationCounterPointcut txnCounter = (InvocationCounterPointcut) factory.getBean("txnInvocationCounterPointcut");
InvocationCounterInterceptor preCounter = (InvocationCounterInterceptor) factory.getBean("preInvocationCounterInterceptor");
InvocationCounterInterceptor postCounter = (InvocationCounterInterceptor) factory.getBean("postInvocationCounterInterceptor");
txnCounter.counter = 0;
preCounter.counter = 0;
postCounter.counter = 0;
doTestGetsAreNotTransactional(testBean);
// Can't assert it's equal to 4 as the pointcut may be optimized and only invoked once
assertTrue(0 < txnCounter.counter && txnCounter.counter <= 4);
assertEquals(4, preCounter.counter);
assertEquals(4, postCounter.counter);
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class BeanFactoryTransactionTests method testGetsAreNotTransactionalWithProxyFactory1.
@Test
public void testGetsAreNotTransactionalWithProxyFactory1() throws NoSuchMethodException {
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory1");
assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass()));
assertFalse(testBean instanceof TransactionalProxy);
doTestGetsAreNotTransactional(testBean);
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class BeanFactoryTransactionTests method testGetsAreNotTransactionalWithProxyFactory2Cglib.
@Test
public void testGetsAreNotTransactionalWithProxyFactory2Cglib() throws NoSuchMethodException {
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Cglib");
assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(testBean));
assertTrue(testBean instanceof TransactionalProxy);
doTestGetsAreNotTransactional(testBean);
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class BeanFactoryTransactionTests method testProxyFactory2Lazy.
@Test
public void testProxyFactory2Lazy() throws NoSuchMethodException {
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Lazy");
assertFalse(factory.containsSingleton("target"));
assertEquals(666, testBean.getAge());
assertTrue(factory.containsSingleton("target"));
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class PerThisAspect method testFailureWithoutExplicitDeclarePrecedence.
@Test
public void testFailureWithoutExplicitDeclarePrecedence() {
TestBean target = new TestBean();
MetadataAwareAspectInstanceFactory aspectInstanceFactory = new SingletonMetadataAwareAspectInstanceFactory(new NoDeclarePrecedenceShouldFail(), "someBean");
ITestBean itb = (ITestBean) createProxy(target, getFixture().getAdvisors(aspectInstanceFactory), ITestBean.class);
itb.getAge();
}
Aggregations