Search in sources :

Example 1 with JCAConnectionRequestInfo

use of org.apache.jackrabbit.jca.JCAConnectionRequestInfo in project jackrabbit by apache.

the class ConnectionFactoryTest method testMatching.

/**
     * Test the connection matching.
     */
public void testMatching() throws Exception {
    // Create connection request infos
    JCAConnectionRequestInfo cri1 = new JCAConnectionRequestInfo(JCR_SUPERUSER, JCR_WORKSPACE);
    JCAConnectionRequestInfo cri2 = new JCAConnectionRequestInfo(JCR_ANONUSER, JCR_WORKSPACE);
    // Check if not same
    assertNotSame(cri1, cri2);
    // Create the connection factory
    mcf.createConnectionFactory();
    // Allocate connections
    ManagedConnection mc1 = mcf.createManagedConnection(null, cri1);
    ManagedConnection mc2 = mcf.createManagedConnection(null, cri2);
    // Check if not same
    assertTrue(mc1 != mc2);
    // Create a sef of connections
    HashSet connectionSet = new HashSet();
    connectionSet.add(mc1);
    connectionSet.add(mc2);
    // Match the first connection
    JCAConnectionRequestInfo cri3 = new JCAConnectionRequestInfo(cri1);
    assertTrue((cri1 != cri3) && cri1.equals(cri3));
    ManagedConnection mc3 = mcf.matchManagedConnections(connectionSet, null, cri3);
    assertTrue(mc1 == mc3);
    // Match the second connection
    JCAConnectionRequestInfo cri4 = new JCAConnectionRequestInfo(cri2);
    assertTrue((cri2 != cri4) && cri2.equals(cri4));
    ManagedConnection mc4 = mcf.matchManagedConnections(connectionSet, null, cri4);
    assertTrue(mc2 == mc4);
}
Also used : JCAConnectionRequestInfo(org.apache.jackrabbit.jca.JCAConnectionRequestInfo) ManagedConnection(javax.resource.spi.ManagedConnection) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 ManagedConnection (javax.resource.spi.ManagedConnection)1 JCAConnectionRequestInfo (org.apache.jackrabbit.jca.JCAConnectionRequestInfo)1