Package org.jboss.internal.soa.esb.rosetta.pooling

Examples of org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool$JmsSessionPool


  }
   
    @Test
    public void testPoolAndConnectionCreation()  throws Exception
    {
        JmsConnectionPool jmsConnectionPool = null;
       
        jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment,"ConnectionFactory");
        assertEquals(0, jmsConnectionPool.getSessionsInPool());
        //Open 3 concurrent sessions
        JmsSession session1 = jmsConnectionPool.getSession();
        assertEquals(1, jmsConnectionPool.getSessionsInPool());
        JmsSession session2 = jmsConnectionPool.getSession();
        assertEquals(2, jmsConnectionPool.getSessionsInPool());
        JmsSession session3 = jmsConnectionPool.getSession();
        assertEquals(3, jmsConnectionPool.getSessionsInPool());
        //Close them
        jmsConnectionPool.closeSession(session1);
        jmsConnectionPool.closeSession(session2);
        jmsConnectionPool.closeSession(session3);
        assertEquals(3, jmsConnectionPool.getSessionsInPool());
        //destroy this pool
        jmsConnectionPool.removeSessionPool();
        assertEquals(0, jmsConnectionPool.getSessionsInPool());
        assertEquals(0, JmsConnectionPoolContainer.getNumberOfPools());
       
        jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment,"ConnectionFactory");
        jmsConnectionPool.getSession();
        assertEquals(1, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
        //I should be able to remove the entire pool and have it do closing
        //of the session.
        jmsConnectionPool.removeSessionPool();
    }
View Full Code Here


    }
   
    @Test
    public void testCreateSecondPool() throws Exception
    {
        JmsConnectionPool jmsConnectionPool1 = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory");
        jmsConnectionPool1 = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory");
        //This should be the same pool
        assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
   
        JmsConnectionPool jmsConnectionPool2 = JmsConnectionPoolContainer.getPool(null, "ConnectionFactory");
        //This should be a different pool, so now we should have 2.
        assertEquals(2, JmsConnectionPoolContainer.getNumberOfPools());
       
        //Now lets cleanup after ourselves
        jmsConnectionPool2.removeSessionPool();
        assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
       
        jmsConnectionPool1.removeSessionPool();
        assertEquals(0, JmsConnectionPoolContainer.getNumberOfPools());
    }
View Full Code Here

    }
   
    @Test
    public void testPoolAndSessionsWithAcknowledgeMode()  throws Exception
    {
        JmsConnectionPool jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment,"ConnectionFactory");
        assertEquals(0, jmsConnectionPool.getSessionsInPool());
       
        JmsSession autoAckSession1 = jmsConnectionPool.getSession(Session.AUTO_ACKNOWLEDGE);
        assertEquals(Session.AUTO_ACKNOWLEDGE, autoAckSession1.getAcknowledgeMode());
        assertEquals(1, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, jmsConnectionPool.getSessionsInPool(Session.AUTO_ACKNOWLEDGE));
       
        JmsSession autoAckSession2 = jmsConnectionPool.getSession(Session.AUTO_ACKNOWLEDGE);
        assertEquals(Session.AUTO_ACKNOWLEDGE, autoAckSession2.getAcknowledgeMode());
        assertEquals(2, jmsConnectionPool.getSessionsInPool());
        assertEquals(2, jmsConnectionPool.getSessionsInPool(Session.AUTO_ACKNOWLEDGE));
       
        JmsSession clientAckSession1 = jmsConnectionPool.getSession(Session.CLIENT_ACKNOWLEDGE);
        assertEquals(Session.CLIENT_ACKNOWLEDGE, clientAckSession1.getAcknowledgeMode());
        assertEquals(3, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, jmsConnectionPool.getSessionsInPool(Session.CLIENT_ACKNOWLEDGE));
       
        JmsSession clientAckSession2 = jmsConnectionPool.getSession(Session.CLIENT_ACKNOWLEDGE);
        assertEquals(Session.CLIENT_ACKNOWLEDGE, clientAckSession2.getAcknowledgeMode());
        assertEquals(4, jmsConnectionPool.getSessionsInPool());
        assertEquals(2, jmsConnectionPool.getSessionsInPool(Session.CLIENT_ACKNOWLEDGE));
       
        JmsSession dupsOkAcSession1 = jmsConnectionPool.getSession(Session.DUPS_OK_ACKNOWLEDGE);
        assertEquals(Session.DUPS_OK_ACKNOWLEDGE, dupsOkAcSession1.getAcknowledgeMode());
        assertEquals(5, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, jmsConnectionPool.getSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE));
       
        JmsSession dupsOkAcSession2 = jmsConnectionPool.getSession(Session.DUPS_OK_ACKNOWLEDGE);
        assertEquals(Session.DUPS_OK_ACKNOWLEDGE, dupsOkAcSession2.getAcknowledgeMode());
        assertEquals(6, jmsConnectionPool.getSessionsInPool());
        assertEquals(2, jmsConnectionPool.getSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE));
       
        //Close them
        jmsConnectionPool.closeSession(autoAckSession1);
        assertEquals(6, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, jmsConnectionPool.getFreeSessionsInPool(Session.AUTO_ACKNOWLEDGE));
        assertEquals(1, jmsConnectionPool.getInUseSessionsInPool(Session.AUTO_ACKNOWLEDGE));
       
        jmsConnectionPool.closeSession(autoAckSession2);
        assertEquals(6, jmsConnectionPool.getSessionsInPool());
        assertEquals(2, jmsConnectionPool.getFreeSessionsInPool(Session.AUTO_ACKNOWLEDGE));
        assertEquals(0, jmsConnectionPool.getInUseSessionsInPool(Session.AUTO_ACKNOWLEDGE));
       
        jmsConnectionPool.closeSession(clientAckSession1);
        assertEquals(6, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, jmsConnectionPool.getFreeSessionsInPool(Session.CLIENT_ACKNOWLEDGE));
        assertEquals(1, jmsConnectionPool.getInUseSessionsInPool(Session.CLIENT_ACKNOWLEDGE));
       
        jmsConnectionPool.closeSession(clientAckSession2);
        assertEquals(6, jmsConnectionPool.getSessionsInPool());
        assertEquals(2, jmsConnectionPool.getFreeSessionsInPool(Session.CLIENT_ACKNOWLEDGE));
        assertEquals(0, jmsConnectionPool.getInUseSessionsInPool(Session.CLIENT_ACKNOWLEDGE));
       
        jmsConnectionPool.closeSession(dupsOkAcSession1);
        assertEquals(6, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, jmsConnectionPool.getFreeSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE));
        assertEquals(1, jmsConnectionPool.getInUseSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE));
       
        jmsConnectionPool.closeSession(dupsOkAcSession2);
        assertEquals(6, jmsConnectionPool.getSessionsInPool());
        assertEquals(2, jmsConnectionPool.getFreeSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE));
        assertEquals(0, jmsConnectionPool.getInUseSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE));
       
        jmsConnectionPool.removeSessionPool();
        assertEquals(0, jmsConnectionPool.getSessionsInPool());
        assertEquals(0, JmsConnectionPoolContainer.getNumberOfPools());
       
        jmsConnectionPool = JmsConnectionPoolContainer.getPool(environment,"ConnectionFactory");
        jmsConnectionPool.getSession();
        assertEquals(1, jmsConnectionPool.getSessionsInPool());
        assertEquals(1, JmsConnectionPoolContainer.getNumberOfPools());
       
        jmsConnectionPool.removeSessionPool();
    }
View Full Code Here

TOP

Related Classes of org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool$JmsSessionPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.