Search in sources :

Example 1 with ConnectionRequestInfo

use of javax.resource.spi.ConnectionRequestInfo 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);
    assertNull("Connection must be null", mcon);
}
Also used : ManagedConnection(javax.resource.spi.ManagedConnection) Subject(javax.security.auth.Subject) ConnectionRequestInfo(javax.resource.spi.ConnectionRequestInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ConnectionRequestInfo

use of javax.resource.spi.ConnectionRequestInfo 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);
}
Also used : ManagedConnection(javax.resource.spi.ManagedConnection) ConnectionRequestInfo(javax.resource.spi.ConnectionRequestInfo) Subject(javax.security.auth.Subject) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with ConnectionRequestInfo

use of javax.resource.spi.ConnectionRequestInfo 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);
}
Also used : ManagedConnection(javax.resource.spi.ManagedConnection) Subject(javax.security.auth.Subject) ConnectionRequestInfo(javax.resource.spi.ConnectionRequestInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ConnectionRequestInfo

use of javax.resource.spi.ConnectionRequestInfo 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);
    assertNull("should not get a match", mcon);
}
Also used : ManagedConnection(javax.resource.spi.ManagedConnection) ConnectionRequestInfo(javax.resource.spi.ConnectionRequestInfo) Subject(javax.security.auth.Subject) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with ConnectionRequestInfo

use of javax.resource.spi.ConnectionRequestInfo in project cxf by apache.

the class ManagedConnectionImplTest method testGetSetConnectionRequestInfo.

@Test
public void testGetSetConnectionRequestInfo() {
    ConnectionRequestInfo ri = new ConnectionRequestInfo() {
    };
    mc.setConnectionRequestInfo(ri);
    assertEquals("Got back what we set", ri, mc.getConnectionRequestInfo());
}
Also used : ConnectionRequestInfo(javax.resource.spi.ConnectionRequestInfo) Test(org.junit.Test)

Aggregations

ConnectionRequestInfo (javax.resource.spi.ConnectionRequestInfo)7 Test (org.junit.Test)6 HashSet (java.util.HashSet)5 ManagedConnection (javax.resource.spi.ManagedConnection)5 Subject (javax.security.auth.Subject)5 ResourceException (javax.resource.ResourceException)1 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)1