use of org.apache.cxf.jca.cxf.CXFInvocationHandler in project cxf by apache.
the class InvocationHandlerFactoryTest method testCreateHandlerChain.
@Test
public void testCreateHandlerChain() throws ResourceAdapterInternalException {
CXFInvocationHandler first = handler;
CXFInvocationHandler last = null;
assertNotNull("handler must not be null", handler);
int count = 0;
Set<Class<?>> allHandlerTypes = new HashSet<Class<?>>();
while (handler != null) {
assertSame("managed connection must be set", mci, handler.getData().getManagedConnection());
assertSame("bus must be set", mockBus, handler.getData().getBus());
assertSame("subject must be set", testSubject, handler.getData().getSubject());
assertSame("target must be set", target, handler.getData().getTarget());
allHandlerTypes.add(handler.getClass());
last = handler;
handler = handler.getNext();
count++;
}
assertNotNull(last);
assertEquals("must create correct number of handlers", count, 4);
assertTrue("first handler must a ProxyInvocationHandler", first instanceof ProxyInvocationHandler);
assertTrue("last handler must be an InvokingInvocationHandler", last instanceof InvokingInvocationHandler);
Class<?>[] types = { ProxyInvocationHandler.class, ObjectMethodInvocationHandler.class, InvokingInvocationHandler.class, SecurityTestHandler.class };
for (int i = 0; i < types.length; i++) {
assertTrue("handler chain must contain type: " + types[i], allHandlerTypes.contains(types[i]));
}
}
use of org.apache.cxf.jca.cxf.CXFInvocationHandler in project cxf by apache.
the class InvokingInvocationHandlerTest method setUp.
@Before
public void setUp() {
super.setUp();
target = new TestTarget();
data = new CXFInvocationHandlerDataImpl();
data.setTarget(target);
handler = new InvokingInvocationHandler(data);
Class<?>[] interfaces = { TestInterface.class };
test = (TestInterface) Proxy.newProxyInstance(TestInterface.class.getClassLoader(), interfaces, handler);
handler.getData().setTarget(target);
CXFInvocationHandlerData data2 = new CXFInvocationHandlerDataImpl();
CXFInvocationHandler handler2 = new InvokingInvocationHandler(data2);
test2 = (TestInterface) Proxy.newProxyInstance(TestInterface.class.getClassLoader(), interfaces, handler2);
handler2.getData().setTarget(target);
}
Aggregations