Search in sources :

Example 1 with Connection

use of org.apache.cxf.connector.Connection in project cxf by apache.

the class ManagedConnectionImplTest method testCloseConnection.

@Test
public void testCloseConnection() throws Exception {
    Connection conn = (Connection) mci.getConnection(subj, cri);
    EasyMock.reset(mockListener);
    mockListener.connectionClosed(EasyMock.isA(ConnectionEvent.class));
    EasyMock.expectLastCall();
    EasyMock.replay(mockListener);
    conn.close();
}
Also used : Connection(org.apache.cxf.connector.Connection) ConnectionEvent(javax.resource.spi.ConnectionEvent) Test(org.junit.Test)

Example 2 with Connection

use of org.apache.cxf.connector.Connection in project cxf by apache.

the class OutBoundConnectionTest method verifyResult.

private void verifyResult(Object o) throws Exception {
    assertTrue("returned connect does not implement Connection interface", o instanceof Connection);
    assertTrue("returned connect does not implement Connection interface", o instanceof Greeter);
    Greeter greeter = (Greeter) o;
    String response = new String("Bonjour");
    for (int idx = 0; idx < 5; idx++) {
        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response, reply);
    }
    ((Connection) o).close();
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) ManagedConnection(javax.resource.spi.ManagedConnection) Connection(org.apache.cxf.connector.Connection) Endpoint(javax.xml.ws.Endpoint)

Example 3 with Connection

use of org.apache.cxf.connector.Connection in project cxf by apache.

the class ManagedConnectionImplTest method testAssociateConnection.

@Test
public void testAssociateConnection() throws Exception {
    CXFConnectionRequestInfo cri2 = new CXFConnectionRequestInfo(Greeter.class, new URL("file:/tmp/foo2"), new QName("service2"), new QName("fooPort2"));
    ManagedConnectionImpl mci2 = new ManagedConnectionImpl(factory, cri2, new Subject());
    mci2.addConnectionEventListener(mockListener);
    Object o = mci.getConnection(subj, cri);
    assertTrue("Returned connection does not implement Connection interface", o instanceof Connection);
    assertTrue("Returned connection does not implement Connection interface", o instanceof Greeter);
    assertTrue("Returned connection is not a java.lang.reflect.Proxy instance", o instanceof Proxy);
    InvocationHandler handler = Proxy.getInvocationHandler(o);
    assertTrue("Asserting handler class: " + handler.getClass(), handler instanceof CXFInvocationHandler);
    Object assocMci = ((CXFInvocationHandler) handler).getData().getManagedConnection();
    assertTrue("Asserting associated ManagedConnection.", mci == assocMci);
    assertTrue("Asserting associated ManagedConnection.", mci2 != assocMci);
    mci2.associateConnection(o);
    assocMci = ((CXFInvocationHandler) handler).getData().getManagedConnection();
    assertTrue("Asserting associated ManagedConnection.", mci2 == assocMci);
    assertTrue("Asserting associated ManagedConnection.", mci != assocMci);
}
Also used : Proxy(java.lang.reflect.Proxy) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_soap_http.Greeter) Connection(org.apache.cxf.connector.Connection) InvocationHandler(java.lang.reflect.InvocationHandler) ProxyInvocationHandler(org.apache.cxf.jca.cxf.handlers.ProxyInvocationHandler) URL(java.net.URL) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Aggregations

Connection (org.apache.cxf.connector.Connection)3 Greeter (org.apache.hello_world_soap_http.Greeter)2 Test (org.junit.Test)2 InvocationHandler (java.lang.reflect.InvocationHandler)1 Proxy (java.lang.reflect.Proxy)1 URL (java.net.URL)1 ConnectionEvent (javax.resource.spi.ConnectionEvent)1 ManagedConnection (javax.resource.spi.ManagedConnection)1 Subject (javax.security.auth.Subject)1 QName (javax.xml.namespace.QName)1 Endpoint (javax.xml.ws.Endpoint)1 ProxyInvocationHandler (org.apache.cxf.jca.cxf.handlers.ProxyInvocationHandler)1