You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/08/08 20:01:11 UTC

svn commit: r1370865 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java

Author: tabish
Date: Wed Aug  8 18:01:11 2012
New Revision: 1370865

URL: http://svn.apache.org/viewvc?rev=1370865&view=rev
Log:
Add a shorter connectTimeout to ensure the tests don't fail because they are waiting on the reconnectMutex for to long.

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java?rev=1370865&r1=1370864&r2=1370865&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java Wed Aug  8 18:01:11 2012
@@ -16,6 +16,13 @@
  */
 package org.apache.activemq.transport.failover;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.URI;
+
 import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.command.ConnectionInfo;
 import org.apache.activemq.command.MessageAck;
@@ -30,24 +37,17 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.io.IOException;
-import java.net.URI;
-
-import static org.junit.Assert.*;
-
 public class FailoverTransportTest {
 
     protected Transport transport;
     protected FailoverTransport failoverTransport;
-    private int commandsReceived;
 
-	@Before
-	public void setUp() throws Exception {
-        commandsReceived = 0;
-	}
+    @Before
+    public void setUp() throws Exception {
+    }
 
-	@After
-	public void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         if (transport != null) {
             transport.stop();
         }
@@ -62,7 +62,6 @@ public class FailoverTransportTest {
         transport.setTransportListener(new TransportListener() {
 
             public void onCommand(Object command) {
-                commandsReceived++;
             }
 
             public void onException(IOException error) {
@@ -87,52 +86,51 @@ public class FailoverTransportTest {
     }
 
     @Test(timeout=30000)
-	public void testCommandsIgnoredWhenOffline() throws Exception {
-		this.transport = createTransport();
+    public void testCommandsIgnoredWhenOffline() throws Exception {
+        this.transport = createTransport();
 
-		assertNotNull(failoverTransport);
+        assertNotNull(failoverTransport);
 
-		ConnectionStateTracker tracker = failoverTransport.getStateTracker();
-		assertNotNull(tracker);
+        ConnectionStateTracker tracker = failoverTransport.getStateTracker();
+        assertNotNull(tracker);
 
-		ConnectionId id = new ConnectionId("1");
-		ConnectionInfo connection = new ConnectionInfo(id);
-
-		// Track a connection
-		tracker.track(connection);
-		try {
-			this.transport.oneway(new RemoveInfo(new ConnectionId("1")));
-		} catch(Exception e) {
-			fail("Should not have failed to remove this known connection");
-		}
-
-		try {
-			this.transport.oneway(new RemoveInfo(new ConnectionId("2")));
-		} catch(Exception e) {
-			fail("Should not have failed to remove this unknown connection");
-		}
-
-		this.transport.oneway(new MessageAck());
-		this.transport.oneway(new ShutdownInfo());
-	}
-
-	@Test(timeout=30000)
-	public void testResponsesSentWhenRequestForIgnoredCommands() throws Exception {
-		this.transport = createTransport();
-		assertNotNull(failoverTransport);
-		MessageAck ack = new MessageAck();
-		assertNotNull("Should have received a Response", this.transport.request(ack));
-		RemoveInfo info = new RemoveInfo(new ConnectionId("2"));
-		assertNotNull("Should have received a Response", this.transport.request(info));
-	}
+        ConnectionId id = new ConnectionId("1");
+        ConnectionInfo connection = new ConnectionInfo(id);
+
+        // Track a connection
+        tracker.track(connection);
+        try {
+            this.transport.oneway(new RemoveInfo(new ConnectionId("1")));
+        } catch(Exception e) {
+            fail("Should not have failed to remove this known connection");
+        }
+
+        try {
+            this.transport.oneway(new RemoveInfo(new ConnectionId("2")));
+        } catch(Exception e) {
+            fail("Should not have failed to remove this unknown connection");
+        }
+
+        this.transport.oneway(new MessageAck());
+        this.transport.oneway(new ShutdownInfo());
+    }
+
+    @Test(timeout=30000)
+    public void testResponsesSentWhenRequestForIgnoredCommands() throws Exception {
+        this.transport = createTransport();
+        assertNotNull(failoverTransport);
+        MessageAck ack = new MessageAck();
+        assertNotNull("Should have received a Response", this.transport.request(ack));
+        RemoveInfo info = new RemoveInfo(new ConnectionId("2"));
+        assertNotNull("Should have received a Response", this.transport.request(info));
+    }
 
     protected Transport createTransport() throws Exception {
-    	Transport transport = TransportFactory.connect(
-    			new URI("failover://(tcp://localhost:1234)"));
+        Transport transport = TransportFactory.connect(
+                new URI("failover://(tcp://localhost:1234?transport.connectTimeout=10000)"));
         transport.setTransportListener(new TransportListener() {
 
             public void onCommand(Object command) {
-            	commandsReceived++;
             }
 
             public void onException(IOException error) {