[hornetq-commits] JBoss hornetq SVN: r9964 - trunk/tests/src/org/hornetq/tests/integration/jms/cluster.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Dec 1 09:45:01 EST 2010


Author: ataylor
Date: 2010-12-01 09:45:00 -0500 (Wed, 01 Dec 2010)
New Revision: 9964

Modified:
   trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java
Log:
tidy up resoucres correctly

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java	2010-12-01 14:39:17 UTC (rev 9963)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java	2010-12-01 14:45:00 UTC (rev 9964)
@@ -119,16 +119,28 @@
 
       jbcf.setReconnectAttempts(-1);
 
-      Connection conn = JMSUtil.createConnectionAndWaitForTopology(jbcf, 2, 5);
+      Connection conn = null;
 
-      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      try
+      {
+         conn = JMSUtil.createConnectionAndWaitForTopology(jbcf, 2, 5);
 
-      ClientSession coreSession = ((HornetQSession)sess).getCoreSession();
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
-      JMSUtil.crash(liveService, coreSession);
+         ClientSession coreSession = ((HornetQSession)sess).getCoreSession();
 
+         JMSUtil.crash(liveService, coreSession);
 
-      assertNotNull(ctx2.lookup("/queue/queue1"));
+
+         assertNotNull(ctx2.lookup("/queue/queue1"));
+      }
+      finally
+      {
+         if(conn != null)
+         {
+            conn.close();
+         }
+      }
    }
 
 
@@ -141,15 +153,27 @@
 
       jbcf.setReconnectAttempts(-1);
 
-      Connection conn = JMSUtil.createConnectionAndWaitForTopology(jbcf, 2, 5);
+      Connection conn = null;
 
-      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      try
+      {
+         conn = JMSUtil.createConnectionAndWaitForTopology(jbcf, 2, 5);
 
-      ClientSession coreSession = ((HornetQSession)sess).getCoreSession();
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
-      JMSUtil.crash(liveService, coreSession);
+         ClientSession coreSession = ((HornetQSession)sess).getCoreSession();
 
-      assertNotNull(ctx2.lookup("/topic/t1"));
+         JMSUtil.crash(liveService, coreSession);
+
+         assertNotNull(ctx2.lookup("/topic/t1"));
+      }
+      finally
+      {
+         if(conn != null)
+         {
+            conn.close();
+         }
+      }
    }
 
    public void testAutomaticFailover() throws Exception



More information about the hornetq-commits mailing list