Java Code Examples for org.messaginghub.pooled.jms.JmsPoolConnectionFactory#stop()

The following examples show how to use org.messaginghub.pooled.jms.JmsPoolConnectionFactory#stop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PooledConnectionFactoryTest.java    From pooled-jms with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 60000)
public void testMaxConnectionsAreCreated() throws Exception {
    JmsPoolConnectionFactory cf = createPooledConnectionFactory();
    cf.setMaxConnections(3);

    JmsPoolConnection conn1 = (JmsPoolConnection) cf.createConnection();
    JmsPoolConnection conn2 = (JmsPoolConnection) cf.createConnection();
    JmsPoolConnection conn3 = (JmsPoolConnection) cf.createConnection();

    assertNotSame(conn1.getConnection(), conn2.getConnection());
    assertNotSame(conn1.getConnection(), conn3.getConnection());
    assertNotSame(conn2.getConnection(), conn3.getConnection());

    assertEquals(3, cf.getNumConnections());

    cf.stop();
}
 
Example 2
Source File: PooledConnectionFactoryTest.java    From pooled-jms with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 60000)
public void testConnectionsAreRotated() throws Exception {
    JmsPoolConnectionFactory cf = createPooledConnectionFactory();
    cf.setMaxConnections(10);

    Connection previous = null;

    // Front load the pool.
    for (int i = 0; i < 10; ++i) {
        cf.createConnection();
    }

    for (int i = 0; i < 100; ++i) {
        Connection current = ((JmsPoolConnection) cf.createConnection()).getConnection();
        assertNotSame(previous, current);
        previous = current;
    }

    cf.stop();
}
 
Example 3
Source File: PooledConnectionFactoryTest.java    From pooled-jms with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 60000)
public void testConnectionsArePooled() throws Exception {
    JmsPoolConnectionFactory cf = createPooledConnectionFactory();
    cf.setMaxConnections(1);

    JmsPoolConnection conn1 = (JmsPoolConnection) cf.createConnection();
    JmsPoolConnection conn2 = (JmsPoolConnection) cf.createConnection();
    JmsPoolConnection conn3 = (JmsPoolConnection) cf.createConnection();

    assertSame(conn1.getConnection(), conn2.getConnection());
    assertSame(conn1.getConnection(), conn3.getConnection());
    assertSame(conn2.getConnection(), conn3.getConnection());

    assertEquals(1, cf.getNumConnections());

    cf.stop();
}
 
Example 4
Source File: PooledConnectionFactoryTest.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void testInstanceOf() throws  Exception {
    JmsPoolConnectionFactory pcf = new JmsPoolConnectionFactory();
    assertTrue(pcf instanceof QueueConnectionFactory);
    assertTrue(pcf instanceof TopicConnectionFactory);
    pcf.stop();
}
 
Example 5
Source File: PooledConnectionFactoryTest.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void testClearAllConnections() throws Exception {
    JmsPoolConnectionFactory cf = createPooledConnectionFactory();
    cf.setMaxConnections(3);

    JmsPoolConnection conn1 = (JmsPoolConnection) cf.createConnection();
    JmsPoolConnection conn2 = (JmsPoolConnection) cf.createConnection();
    JmsPoolConnection conn3 = (JmsPoolConnection) cf.createConnection();

    assertNotSame(conn1.getConnection(), conn2.getConnection());
    assertNotSame(conn1.getConnection(), conn3.getConnection());
    assertNotSame(conn2.getConnection(), conn3.getConnection());

    assertEquals(3, cf.getNumConnections());

    cf.clear();

    assertEquals(0, cf.getNumConnections());

    conn1 = (JmsPoolConnection) cf.createConnection();
    conn2 = (JmsPoolConnection) cf.createConnection();
    conn3 = (JmsPoolConnection) cf.createConnection();

    assertNotSame(conn1.getConnection(), conn2.getConnection());
    assertNotSame(conn1.getConnection(), conn3.getConnection());
    assertNotSame(conn2.getConnection(), conn3.getConnection());

    cf.stop();
}
 
Example 6
Source File: PooledConnectionFactoryTest.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void testInstanceOf() throws  Exception {
    JmsPoolConnectionFactory pcf = new JmsPoolConnectionFactory();
    assertTrue(pcf instanceof QueueConnectionFactory);
    assertTrue(pcf instanceof TopicConnectionFactory);
    pcf.stop();
}
 
Example 7
Source File: PooledConnectionFactoryTest.java    From pooled-jms with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testFactoryStopStart() throws Exception {
    JmsPoolConnectionFactory cf = createPooledConnectionFactory();
    cf.setMaxConnections(1);

    JmsPoolConnection conn1 = (JmsPoolConnection) cf.createConnection();

    cf.stop();

    assertNull(cf.createConnection());

    cf.start();

    JmsPoolConnection conn2 = (JmsPoolConnection) cf.createConnection();

    assertNotSame(conn1.getConnection(), conn2.getConnection());

    assertEquals(1, cf.getNumConnections());

    cf.stop();
}