use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class TraceBeforeAdvice method testRepeatedAroundAdviceInvocations.
private long testRepeatedAroundAdviceInvocations(String file, int howmany, String technology) {
ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
StopWatch sw = new StopWatch();
sw.start(howmany + " repeated around advice invocations with " + technology);
ITestBean adrian = (ITestBean) bf.getBean("adrian");
assertTrue(AopUtils.isAopProxy(adrian));
assertEquals(68, adrian.getAge());
for (int i = 0; i < howmany; i++) {
adrian.getAge();
}
sw.stop();
System.out.println(sw.prettyPrint());
return sw.getLastTaskTimeMillis();
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class TraceBeforeAdvice method testBeforeAdviceWithoutJoinPoint.
private long testBeforeAdviceWithoutJoinPoint(String file, int howmany, String technology) {
ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
StopWatch sw = new StopWatch();
sw.start(howmany + " repeated before advice invocations with " + technology);
ITestBean adrian = (ITestBean) bf.getBean("adrian");
assertTrue(AopUtils.isAopProxy(adrian));
Advised a = (Advised) adrian;
assertTrue(a.getAdvisors().length >= 3);
assertEquals("adrian", adrian.getName());
for (int i = 0; i < howmany; i++) {
adrian.getName();
}
sw.stop();
System.out.println(sw.prettyPrint());
return sw.getLastTaskTimeMillis();
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class AopNamespaceHandlerProxyTargetClassTests method testIsClassProxy.
@Test
public void testIsClassProxy() {
ITestBean bean = getTestBean();
assertTrue("Should be a CGLIB proxy", AopUtils.isCglibProxy(bean));
assertTrue("Should expose proxy", ((Advised) bean).isExposeProxy());
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class CountingAspectJAdvice method testIsProxy.
@Test
public void testIsProxy() throws Exception {
ITestBean bean = getTestBean();
assertTrue("Bean is not a proxy", AopUtils.isAopProxy(bean));
// check the advice details
Advised advised = (Advised) bean;
Advisor[] advisors = advised.getAdvisors();
assertTrue("Advisors should not be empty", advisors.length > 0);
}
use of org.springframework.tests.sample.beans.ITestBean in project spring-framework by spring-projects.
the class AbstractAopProxyTests method testRejectsBogusDynamicIntroductionAdviceWithNoAdapter.
@Test
public void testRejectsBogusDynamicIntroductionAdviceWithNoAdapter() throws Throwable {
TestBean target = new TestBean();
target.setAge(21);
ProxyFactory pc = new ProxyFactory(target);
pc.addAdvisor(new DefaultIntroductionAdvisor(new DummyIntroductionAdviceImpl(), Comparable.class));
try {
// TODO May fail on either call: may want to tighten up definition
ITestBean proxied = (ITestBean) createProxy(pc);
proxied.getName();
fail("Bogus introduction");
} catch (Exception ex) {
// TODO used to catch UnknownAdviceTypeException, but
// with CGLIB some errors are in proxy creation and are wrapped
// in aspect exception. Error message is still fine.
//assertTrue(ex.getMessage().indexOf("ntroduction") > -1);
}
}
Aggregations