use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class SimpleRemoteSlsbInvokerInterceptorTests method configuredProxy.
protected Object configuredProxy(SimpleRemoteSlsbInvokerInterceptor si, Class<?> ifc) throws NamingException {
si.afterPropertiesSet();
ProxyFactory pf = new ProxyFactory(new Class<?>[] { ifc });
pf.addAdvice(si);
return pf.getProxy();
}
use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class LocalSlsbInvokerInterceptorTests method testInvokesMethodOnEjbInstance.
@Test
public void testInvokesMethodOnEjbInstance() throws Exception {
Object retVal = new Object();
LocalInterfaceWithBusinessMethods ejb = mock(LocalInterfaceWithBusinessMethods.class);
given(ejb.targetMethod()).willReturn(retVal);
String jndiName = "foobar";
Context mockContext = mockContext(jndiName, ejb);
LocalSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
ProxyFactory pf = new ProxyFactory(new Class<?>[] { BusinessMethods.class });
pf.addAdvice(si);
BusinessMethods target = (BusinessMethods) pf.getProxy();
assertTrue(target.targetMethod() == retVal);
verify(mockContext).close();
verify(ejb).remove();
}
use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class ModelMapTests method testAopCglibProxy.
@Test
public void testAopCglibProxy() throws Exception {
ModelMap map = new ModelMap();
ProxyFactory factory = new ProxyFactory();
SomeInnerClass val = new SomeInnerClass();
factory.setTarget(val);
factory.setProxyTargetClass(true);
map.addAttribute(factory.getProxy());
assertTrue(map.containsKey("someInnerClass"));
assertEquals(val, map.get("someInnerClass"));
}
use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.
the class ModelMapTests method testAopJdkProxy.
@Test
public void testAopJdkProxy() throws Exception {
ModelMap map = new ModelMap();
ProxyFactory factory = new ProxyFactory();
Map<?, ?> target = new HashMap<>();
factory.setTarget(target);
factory.addInterface(Map.class);
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 ModelMapTests method testAopJdkProxyWithMultipleInterfaces.
@Test
public void testAopJdkProxyWithMultipleInterfaces() throws Exception {
ModelMap map = new ModelMap();
Map<?, ?> target = new HashMap<>();
ProxyFactory factory = new ProxyFactory();
factory.setTarget(target);
factory.addInterface(Serializable.class);
factory.addInterface(Cloneable.class);
factory.addInterface(Comparable.class);
factory.addInterface(Map.class);
Object proxy = factory.getProxy();
map.addAttribute(proxy);
assertSame(proxy, map.get("map"));
}
Aggregations