activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: Convert the JUnit 4 test so that the ignore is honoered.
Date Mon, 09 Jun 2014 14:25:15 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk 736ffc9b9 -> 77713d9d1


Convert the JUnit 4 test so that the ignore is honoered.  

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/77713d9d
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/77713d9d
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/77713d9d

Branch: refs/heads/trunk
Commit: 77713d9d1a91ca711c4716617280ef33514d76a6
Parents: 736ffc9
Author: Timothy Bish <tabish121@gmail.com>
Authored: Mon Jun 9 10:24:58 2014 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Mon Jun 9 10:24:58 2014 -0400

----------------------------------------------------------------------
 .../jms/pool/PooledConnectionFactoryTest.java   | 56 +++++++++-----------
 1 file changed, 24 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/77713d9d/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
index 0ae2e4a..99b0ca8 100644
--- a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
+++ b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
@@ -16,6 +16,12 @@
  */
 package org.apache.activemq.jms.pool;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -28,10 +34,6 @@ import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Session;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.BrokerService;
@@ -39,6 +41,7 @@ import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.util.Wait;
 import org.apache.log4j.Logger;
 import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * Checks the behavior of the PooledConnectionFactory when the maximum amount of
@@ -49,27 +52,11 @@ import org.junit.Ignore;
  * don't block. This test succeeds if an exception is returned and fails if the
  * call to getSession() blocks.
  */
-public class PooledConnectionFactoryTest extends TestCase {
+public class PooledConnectionFactoryTest {
 
     public final static Logger LOG = Logger.getLogger(PooledConnectionFactoryTest.class);
 
-    /**
-     * Create the test case
-     *
-     * @param testName
-     *            name of the test case
-     */
-    public PooledConnectionFactoryTest(String testName) {
-        super(testName);
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite() {
-        return new TestSuite(PooledConnectionFactoryTest.class);
-    }
-
+    @Test
     public void testClearAllConnections() throws Exception {
 
         ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false");
@@ -100,6 +87,7 @@ public class PooledConnectionFactoryTest extends TestCase {
         assertNotSame(conn2.getConnection(), conn3.getConnection());
     }
 
+    @Test
     public void testMaxConnectionsAreCreated() throws Exception {
 
         ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false");
@@ -118,6 +106,7 @@ public class PooledConnectionFactoryTest extends TestCase {
         assertEquals(3, cf.getNumConnections());
     }
 
+    @Test
     public void testConnectionsAreRotated() throws Exception {
 
         ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false");
@@ -139,6 +128,7 @@ public class PooledConnectionFactoryTest extends TestCase {
         }
     }
 
+    @Test
     public void testConnectionsArePooled() throws Exception {
 
         ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false");
@@ -157,6 +147,7 @@ public class PooledConnectionFactoryTest extends TestCase {
         assertEquals(1, cf.getNumConnections());
     }
 
+    @Test
     public void testConnectionsArePooledAsyncCreate() throws Exception {
 
         final ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false");
@@ -193,7 +184,7 @@ public class PooledConnectionFactoryTest extends TestCase {
         executor.shutdown();
         assertTrue(executor.awaitTermination(5, TimeUnit.SECONDS));
 
-        for(PooledConnection connection : connections) {
+        for (PooledConnection connection : connections) {
             assertSame(primary.getConnection(), connection.getConnection());
         }
 
@@ -201,11 +192,13 @@ public class PooledConnectionFactoryTest extends TestCase {
         cf.stop();
     }
 
+    @Test
     public void testConcurrentCreateGetsUniqueConnectionCreateOnDemand() throws Exception
{
         doTestConcurrentCreateGetsUniqueConnection(false);
     }
 
     @Ignore("something up - don't know why the start call to createConnection does not cause
close - but that does not fix it either!")
+    @Test
     public void testConcurrentCreateGetsUniqueConnectionCreateOnStart() throws Exception
{
         doTestConcurrentCreateGetsUniqueConnection(true);
     }
@@ -216,6 +209,7 @@ public class PooledConnectionFactoryTest extends TestCase {
         brokerService.setPersistent(false);
         brokerService.addConnector("tcp://localhost:0");
         brokerService.start();
+        brokerService.waitUntilStarted();
 
         try {
             final int numConnections = 2;
@@ -227,8 +221,7 @@ public class PooledConnectionFactoryTest extends TestCase {
             cf.setCreateConnectionOnStartup(createOnStart);
             cf.start();
 
-            final ConcurrentHashMap<ConnectionId, Connection> connections =
-                    new ConcurrentHashMap<ConnectionId, Connection>();
+            final ConcurrentHashMap<ConnectionId, Connection> connections = new ConcurrentHashMap<ConnectionId,
Connection>();
             final ExecutorService executor = Executors.newFixedThreadPool(numConnections);
 
             for (int i = 0; i < numConnections; ++i) {
@@ -247,7 +240,7 @@ public class PooledConnectionFactoryTest extends TestCase {
             }
 
             executor.shutdown();
-            assertTrue(executor.awaitTermination(5, TimeUnit.SECONDS));
+            assertTrue(executor.awaitTermination(30, TimeUnit.SECONDS));
 
             assertEquals("Should have all unique connections", numConnections, connections.size());
 
@@ -277,9 +270,7 @@ public class PooledConnectionFactoryTest extends TestCase {
         if (!result.isDone() || !result.get().booleanValue()) {
             PooledConnectionFactoryTest.LOG.error("2nd call to createSession() " +
                                                   "is blocking but should have returned an
error instead.");
-
             executor.shutdownNow();
-
             fail("SessionPool inside PooledConnectionFactory is blocking if " +
                  "limit is exceeded but should return an exception instead.");
         }
@@ -312,8 +303,7 @@ public class PooledConnectionFactoryTest extends TestCase {
 
                 Session two = null;
                 try {
-                    // this should raise an exception as we called
-                    // setMaximumActive(1)
+                    // this should raise an exception as we called setMaximumActive(1)
                     two = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
                     two.close();
 
@@ -331,10 +321,12 @@ public class PooledConnectionFactoryTest extends TestCase {
                         return new Boolean(false);
                     }
                 } finally {
-                    if (one != null)
+                    if (one != null) {
                         one.close();
-                    if (conn != null)
+                    }
+                    if (conn != null) {
                         conn.close();
+                    }
                 }
             } catch (Exception ex) {
                 LOG.error(ex.getMessage());


Mime
View raw message