You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ha...@apache.org on 2014/12/16 23:09:57 UTC

[09/16] activemq git commit: Cleanup in ConnectTest to do two things: 1) connect/disconnect 500 (which still seems high) times instead of as many as possible in 25seconds. On fast machines, this is MUCH faster. 2) Actually call Thead.start(), not Thread

Cleanup in ConnectTest to do two things:
1) connect/disconnect 500 (which still seems high) times instead of as many as possible in 25seconds.  On fast machines, this is MUCH faster.
2) Actually call Thead.start(), not Thread.run() in cases where it should be on a background thread.


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

Branch: refs/heads/activemq-5.10.x
Commit: f8ccdfbfaa5ad588404f5d2b620351c34e9504cc
Parents: 569a677
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Jul 10 15:28:43 2014 -0400
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Mon Dec 15 19:26:25 2014 -0500

----------------------------------------------------------------------
 .../activemq/transport/stomp/ConnectTest.java   | 40 ++++++++------------
 1 file changed, 15 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/f8ccdfbf/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/ConnectTest.java
----------------------------------------------------------------------
diff --git a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/ConnectTest.java b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/ConnectTest.java
index 1e13143..e95fd92 100644
--- a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/ConnectTest.java
+++ b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/ConnectTest.java
@@ -29,9 +29,11 @@ import org.apache.activemq.broker.BrokerPlugin;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.security.JaasDualAuthenticationPlugin;
 import org.apache.activemq.util.Wait;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -62,28 +64,16 @@ public class ConnectTest {
         brokerService.addConnector("stomp://0.0.0.0:0?transport.soLinger=0");
         brokerService.start();
 
-        Thread t1 = new Thread() {
-            StompConnection connection = new StompConnection();
-
-            @Override
-            public void run() {
-                try {
-                    connection.open("localhost", brokerService.getTransportConnectors().get(0).getConnectUri().getPort());
-                    connection.connect("system", "manager");
-                    connection.disconnect();
-                } catch (Exception ex) {
-                    LOG.error("unexpected exception on connect/disconnect", ex);
-                    exceptions.add(ex);
-                }
-            }
-        };
-
-        int i = 0;
-        long done = System.currentTimeMillis() + (15 * 1000);
-        while (System.currentTimeMillis() < done) {
-            t1.run();
-            if (++i % 5000 == 0) {
-                LOG.info("connection count on stomp connector:" + brokerService.getTransportConnectors().get(0).connectionCount());
+        StompConnection connection = new StompConnection();
+        //test 500 connect/disconnects
+        for (int x = 0; x < 500; x++) {
+            try {
+                connection.open("localhost", brokerService.getTransportConnectors().get(0).getConnectUri().getPort());
+                connection.connect("system", "manager");
+                connection.disconnect();
+            } catch (Exception ex) {
+                LOG.error("unexpected exception on connect/disconnect", ex);
+                exceptions.add(ex);
             }
         }
 
@@ -119,7 +109,7 @@ public class ConnectTest {
             }
         };
 
-        t1.run();
+        t1.start();
 
         assertTrue("one connection", Wait.waitFor(new Wait.Condition() {
             @Override
@@ -143,7 +133,7 @@ public class ConnectTest {
     @Test
     public void testInactivityMonitor() throws Exception {
 
-        brokerService.addConnector("stomp://0.0.0.0:0?transport.defaultHeartBeat=5000,0&transport.useKeepAlive=false");
+        brokerService.addConnector("stomp://0.0.0.0:0?transport.defaultHeartBeat=1000,0&transport.useKeepAlive=false");
         brokerService.start();
 
         Thread t1 = new Thread() {
@@ -161,7 +151,7 @@ public class ConnectTest {
             }
         };
 
-        t1.run();
+        t1.start();
 
         assertTrue("one connection", Wait.waitFor(new Wait.Condition() {
                  @Override