activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r700838 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
Date Wed, 01 Oct 2008 16:58:08 GMT
Author: gtully
Date: Wed Oct  1 09:58:08 2008
New Revision: 700838

URL: http://svn.apache.org/viewvc?rev=700838&view=rev
Log:
fix DiscoveryTransportNoBrokerTest failure on slow host name resolution, reconnectAttempts
is not relevant when the multicast address cannot be resolved, modified test to reflect this

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

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java?rev=700838&r1=700837&r2=700838&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java
Wed Oct  1 09:58:08 2008
@@ -320,7 +320,9 @@
     public void stop() throws Exception {
         if (started.compareAndSet(true, false)) {
             doAdvertizeSelf();
-            mcast.close();
+            if (mcast != null) {
+                mcast.close();
+            }
         }
     }
 

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=700838&r1=700837&r2=700838&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
Wed Oct  1 09:58:08 2008
@@ -21,22 +21,22 @@
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.CombinationTestSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class DiscoveryTransportNoBrokerTest extends CombinationTestSupport {
 
+    private static final Log LOG = LogFactory.getLog(DiscoveryTransportNoBrokerTest.class);
+    
     public void testMaxReconnectAttempts() throws JMSException {
-        long start = System.currentTimeMillis();
         try {
-            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://doesNOTexist)?maxReconnectAttempts=1");
-            System.out.println("Connecting.");
+            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://doesNOTexist)");
+            LOG.info("Connecting.");
             Connection connection = factory.createConnection();
             connection.setClientID("test");
             fail("Did not fail to connect as expected.");
-        } catch ( JMSException expected ) {       
-            long duration = System.currentTimeMillis() - start;
-            // Should have failed fairly quickly since we are only giving it 1 reconnect
attempt.
-            assertTrue(duration < 1000*5 );
+        } catch ( JMSException expected ) {  
+            assertTrue("reason is  java.net.UnknownHostException", expected.getCause() instanceof
 java.net.UnknownHostException);
         }
     }
-
 }



Mime
View raw message