activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r737703 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
Date Mon, 26 Jan 2009 14:30:47 GMT
Author: gtully
Date: Mon Jan 26 14:30:46 2009
New Revision: 737703

URL: http://svn.apache.org/viewvc?rev=737703&view=rev
Log:
test for https://issues.apache.org/activemq/browse/AMQ-2080 that shows use of reconnectDelay

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java?rev=737703&r1=737702&r2=737703&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
Mon Jan 26 14:30:46 2009
@@ -35,8 +35,32 @@
             Connection connection = factory.createConnection();
             connection.setClientID("test");
             fail("Did not fail to connect as expected.");
+        }
+        catch ( JMSException expected ) { 
+            assertTrue("reason is java.io.IOException, was: " + expected.getCause(), expected.getCause()
instanceof java.io.IOException);
+        }
+    }
+    
+    public void testInitialConnectDelayWithNoBroker() throws Exception {
+        // the initialReconnectDelay only kicks in once a set of connect URL have
+        // been returned from the discovery agent.
+        // Up to that point the reconnectDelay is used which has a default value of 10
+        //
+        long initialReconnectDelay = 4000;
+        long startT = System.currentTimeMillis();
+        String groupId = "WillNotMatch" + startT;
+        try {
+            String urlStr = "discovery:(multicast://default?group=" + groupId + 
+                ")?useExponentialBackOff=false&maxReconnectAttempts=2&reconnectDelay="
+ initialReconnectDelay;          
+            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlStr);
+            LOG.info("Connecting.");
+            Connection connection = factory.createConnection();
+            connection.setClientID("test");
+            fail("Did not fail to connect as expected.");
         } catch ( JMSException expected ) { 
             assertTrue("reason is java.io.IOException, was: " + expected.getCause(), expected.getCause()
instanceof java.io.IOException);
+            long duration = System.currentTimeMillis() - startT;
+            assertTrue("took at least initialReconnectDelay time: " + duration, duration
>= initialReconnectDelay);
         }
     }
 }



Mime
View raw message