use of javax.resource.spi.ManagedConnection in project cxf by apache.
the class DummyManagedConnectionFactoryImpl method testMatchConnectionInvalidatedWithSameConnectioRequestInfo.
@Test
public void testMatchConnectionInvalidatedWithSameConnectioRequestInfo() throws Exception {
Subject subject = null;
Set<AbstractManagedConnectionImpl> connectionSet = new HashSet<>();
ConnectionRequestInfo cri = new DummyConnectionRequestInfo();
DummyManagedConnectionImpl con1 = new DummyManagedConnectionImpl(mcf, cri, subject);
con1.setBound(true);
con1.setCon(connectionSet);
connectionSet.add(con1);
ManagedConnection mcon = mcf.matchManagedConnections(connectionSet, subject, cri);
assertTrue("Connection must be null", mcon == null);
}
use of javax.resource.spi.ManagedConnection in project cxf by apache.
the class DummyManagedConnectionFactoryImpl method testMatchConnectionDifferentConnectioRequestInfoNotBound.
@Test
public void testMatchConnectionDifferentConnectioRequestInfoNotBound() throws Exception {
ConnectionRequestInfo cri1 = new DummyConnectionRequestInfo();
ConnectionRequestInfo cri2 = new DummyConnectionRequestInfo();
Subject subject = null;
assertTrue("request info object are differnt", cri1 != cri2);
Set<AbstractManagedConnectionImpl> connectionSet = new HashSet<>();
DummyManagedConnectionImpl con1 = new DummyManagedConnectionImpl(mcf, cri1, subject);
connectionSet.add(con1);
ManagedConnection mcon = mcf.matchManagedConnections(connectionSet, subject, cri2);
assertEquals("incorrect connection returned", con1, mcon);
}
use of javax.resource.spi.ManagedConnection in project cxf by apache.
the class DummyManagedConnectionFactoryImpl method testMatchConnectionDifferentConnectioRequestInfoBound.
@Test
public void testMatchConnectionDifferentConnectioRequestInfoBound() throws Exception {
ConnectionRequestInfo cri1 = new DummyConnectionRequestInfo();
ConnectionRequestInfo cri2 = new DummyConnectionRequestInfo();
Subject subject = null;
assertTrue("request info object are differnt", cri1 != cri2);
Set<AbstractManagedConnectionImpl> connectionSet = new HashSet<>();
DummyManagedConnectionImpl con1 = new DummyManagedConnectionImpl(mcf, cri1, subject);
con1.setBound(true);
connectionSet.add(con1);
ManagedConnection mcon = mcf.matchManagedConnections(connectionSet, subject, cri2);
assertTrue("should not get a match", mcon == null);
}
use of javax.resource.spi.ManagedConnection in project cxf by apache.
the class DummyManagedConnectionFactoryImpl method testMatchConnectionSameConnectioRequestInfoBound.
@Test
public void testMatchConnectionSameConnectioRequestInfoBound() throws Exception {
Subject subject = null;
Set<AbstractManagedConnectionImpl> connectionSet = new HashSet<>();
ConnectionRequestInfo cri = new DummyConnectionRequestInfo();
DummyManagedConnectionImpl con1 = new DummyManagedConnectionImpl(mcf, cri, subject);
con1.setBound(true);
connectionSet.add(con1);
ManagedConnection mcon = mcf.matchManagedConnections(connectionSet, subject, cri);
assertEquals(con1, mcon);
}
use of javax.resource.spi.ManagedConnection in project cxf by apache.
the class ManagedConnectionFactoryImplTester method testMatchManagedConnectionsWithBoundConnections.
@Test
public void testMatchManagedConnectionsWithBoundConnections() throws Exception {
Subject subj = new Subject();
BusFactory bf = BusFactory.newInstance();
Bus bus = bf.createBus();
BusFactory.setDefaultBus(bus);
ManagedConnectionFactoryImpl factory = EasyMock.createMock(ManagedConnectionFactoryImpl.class);
factory.getBus();
// In ManagedConnectionImpl:
// one for getCXFServiceFromBus , another for createInvocationHandler
EasyMock.expectLastCall().andReturn(bus).times(4);
EasyMock.replay(factory);
ManagedConnectionImpl mc1 = new ManagedConnectionImpl(factory, cri, subj);
Object connection = mc1.getConnection(subj, cri);
assertNotNull("connection must not be null.", connection);
/*
ManagedConnectionImpl mc2 = new ManagedConnectionImpl(factory, cri2, subj);
connection = mc2.getConnection(subj, cri2);
assertNotNull("connection must not be null.", connection);
*/
// EasyMock.verify(factory);
Set<ManagedConnection> mcSet = new HashSet<>();
mcSet.add(mc1);
// mcSet.add(mc2);
assertSame("MC1 must be selected.", mci.matchManagedConnections(mcSet, subj, cri), mc1);
// assertSame("MC2 must be selected.", mci.matchManagedConnections(mcSet, subj, cri2), mc2);
// assertNull("No connection must be selected.", mci.matchManagedConnections(mcSet, subj, cri3));
bus.shutdown(true);
}
Aggregations