Ensure that connections created with vm Transport connections get

closed.
This commit is contained in:
Timothy Bish 2016-06-09 14:50:40 -04:00
parent 98d2000833
commit c9b208f0a3
3 changed files with 13 additions and 3 deletions

View File

@ -72,6 +72,8 @@ public class ActiveMQConnectionFactoryTest {
ActiveMQConnection connection = ((ActiveMQConnection) ((ManagedConnectionProxy) con).getManagedConnection().getPhysicalConnection());
assertEquals(100, connection.getPrefetchPolicy().getQueuePrefetch());
assertNotNull("Connection object returned by ActiveMQConnectionFactory.createConnection() is null", con);
connection.close();
}
@Test(timeout = 60000)
@ -92,6 +94,8 @@ public class ActiveMQConnectionFactoryTest {
con.start();
assertEquals(0, ((ActiveMQTopicSubscriber) sub).getPrefetchNumber());
con.close();
}
@Test(timeout = 60000)

View File

@ -51,7 +51,6 @@ public class ManagedConnectionTest {
@Before
public void setUp() throws Exception {
managedConnectionFactory = new ActiveMQManagedConnectionFactory();
managedConnectionFactory.setServerUrl(DEFAULT_HOST);
managedConnectionFactory.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
@ -60,7 +59,6 @@ public class ManagedConnectionTest {
connectionFactory = (ConnectionFactory)managedConnectionFactory.createConnectionFactory(connectionManager);
connection = (ManagedConnectionProxy)connectionFactory.createConnection();
managedConnection = connection.getManagedConnection();
}
@After
@ -106,7 +104,6 @@ public class ManagedConnectionTest {
session.commit();
assertTrue(test[0]);
}
@Test(timeout = 60000)
@ -254,6 +251,7 @@ public class ManagedConnectionTest {
public void testSamePropertiesButNotEqual() throws Exception {
ManagedConnectionProxy newConnection = (ManagedConnectionProxy)connectionFactory.createConnection();
assertNonEquality(managedConnection, newConnection.getManagedConnection());
newConnection.close();
}
private void assertEquality(ActiveMQManagedConnection leftCon, ActiveMQManagedConnection rightCon) {

View File

@ -29,6 +29,7 @@ import javax.resource.ResourceException;
import javax.transaction.xa.XAException;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -51,6 +52,13 @@ public class UnsubscribeResubscribeTest {
managedConnectionFactory.setClientid("clientId");
}
@After
public void tearDown() throws Exception {
if (connection != null) {
connection.close();
}
}
private void getConnection() throws ResourceException, JMSException {
connectionFactory = (ConnectionFactory)managedConnectionFactory.createConnectionFactory(connectionManager);
connection = (ManagedConnectionProxy)connectionFactory.createConnection();