use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class ModelMapTests method testAopJdkProxyWithDetectedInterfaces.
@Test
public void testAopJdkProxyWithDetectedInterfaces() throws Exception {
ModelMap map = new ModelMap();
Map<?, ?> target = new HashMap<>();
ProxyFactory factory = new ProxyFactory(target);
Object proxy = factory.getProxy();
map.addAttribute(proxy);
assertSame(proxy, map.get("map"));
}
use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class GroovyAspectTests method testAdvice.
private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message, boolean proxyTargetClass) throws Exception {
logAdvice.reset();
ProxyFactory factory = new ProxyFactory(target);
factory.setProxyTargetClass(proxyTargetClass);
factory.addAdvisor(advisor);
TestService bean = (TestService) factory.getProxy();
assertEquals(0, logAdvice.getCountThrows());
try {
bean.sayHello();
fail("Expected exception");
} catch (TestException ex) {
assertEquals(message, ex.getMessage());
}
assertEquals(1, logAdvice.getCountThrows());
}
use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class FormattingConversionServiceTests method proxiedConverterFactory.
@Test
public void proxiedConverterFactory() {
ConverterFactory<?, ?> converterFactory = new IntegerConverterFactory();
formattingService.addConverterFactory((ConverterFactory<?, ?>) new ProxyFactory(converterFactory).getProxy());
assertEquals(Integer.valueOf(1), formattingService.convert("1", Integer.class));
}
use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class AopTestUtilsTests method cglibProxy.
private Foo cglibProxy(Foo foo) {
ProxyFactory pf = new ProxyFactory();
pf.setTarget(foo);
pf.setProxyTargetClass(true);
Foo proxy = (Foo) pf.getProxy();
assertTrue("Proxy is a CGLIB proxy", AopUtils.isCglibProxy(proxy));
assertThat(proxy, instanceOf(FooImpl.class));
return proxy;
}
use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class ReflectionTestUtilsTests method setFieldAndGetFieldViaCglibProxy.
@Test
public void setFieldAndGetFieldViaCglibProxy() throws Exception {
ProxyFactory pf = new ProxyFactory(this.person);
pf.setProxyTargetClass(true);
Person proxy = (Person) pf.getProxy();
assertTrue("Proxy is a CGLIB proxy", AopUtils.isCglibProxy(proxy));
assertSetFieldAndGetFieldBehaviorForProxy(proxy, this.person);
}
Aggregations