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();
}
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();
}
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);
}
Aggregations