Expand the test a bit 

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1454522 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-03-08 20:06:11 +00:00
parent f664be7461
commit 5795eb8b8b
1 changed files with 16 additions and 3 deletions

View File

@ -73,7 +73,7 @@ public class ConnectionExpiryEvictsFromPoolTest extends TestSupport {
assertTrue("not equal", !amq1.equals(amq2)); assertTrue("not equal", !amq1.equals(amq2));
} }
public void testRetainIdleWhenInUse() throws Exception { public void testNotIdledWhenInUse() throws Exception {
pooledFactory.setIdleTimeout(10); pooledFactory.setIdleTimeout(10);
PooledConnection connection = (PooledConnection) pooledFactory.createConnection(); PooledConnection connection = (PooledConnection) pooledFactory.createConnection();
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@ -81,8 +81,8 @@ public class ConnectionExpiryEvictsFromPoolTest extends TestSupport {
// let connection to get idle // let connection to get idle
TimeUnit.SECONDS.sleep(1); TimeUnit.SECONDS.sleep(1);
// get the same connection from pool again, it will get destroyed due to validation check // get a connection from pool again, it should be the same underlying connection
// it will be the same since maxIdle is set to 1 in implementation // as before and should not be idled out since an open session exists.
PooledConnection connection2 = (PooledConnection) pooledFactory.createConnection(); PooledConnection connection2 = (PooledConnection) pooledFactory.createConnection();
assertSame(connection.getConnection(), connection2.getConnection()); assertSame(connection.getConnection(), connection2.getConnection());
@ -93,6 +93,19 @@ public class ConnectionExpiryEvictsFromPoolTest extends TestSupport {
} catch (javax.jms.IllegalStateException e) { } catch (javax.jms.IllegalStateException e) {
assertTrue("Session should be fine, instead: " + e.getMessage(), false); assertTrue("Session should be fine, instead: " + e.getMessage(), false);
} }
ActiveMQConnection original = connection.getConnection();
connection.close();
connection2.close();
// let connection to get idle
TimeUnit.SECONDS.sleep(1);
// get a connection from pool again, it should be a new Connection instance as the
// old one should have been inactive and idled out.
PooledConnection connection3 = (PooledConnection) pooledFactory.createConnection();
assertNotSame(original, connection3.getConnection());
} }
@Override @Override