Search in sources :

Example 6 with CXFInvocationHandler

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]));
    }
}
Also used : CXFInvocationHandler(org.apache.cxf.jca.cxf.CXFInvocationHandler) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with CXFInvocationHandler

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);
}
Also used : CXFInvocationHandler(org.apache.cxf.jca.cxf.CXFInvocationHandler) CXFInvocationHandlerData(org.apache.cxf.jca.cxf.CXFInvocationHandlerData) Before(org.junit.Before)

Aggregations

CXFInvocationHandler (org.apache.cxf.jca.cxf.CXFInvocationHandler)7 Test (org.junit.Test)5 CXFInvocationHandlerData (org.apache.cxf.jca.cxf.CXFInvocationHandlerData)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 ResourceAdapterInternalException (org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException)1 Before (org.junit.Before)1