You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/10/03 23:17:27 UTC

[1/2] git commit: Add some variations of anonymous send tests.

Repository: qpid-jms
Updated Branches:
  refs/heads/master 516d91087 -> 81fc1e5d2


Add some variations of anonymous send tests.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/263c93d8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/263c93d8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/263c93d8

Branch: refs/heads/master
Commit: 263c93d84958f51ae6cc1875edc15af6f5a49fad
Parents: 516d910
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Oct 3 16:38:17 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Oct 3 16:38:17 2014 -0400

----------------------------------------------------------------------
 .../jms/producer/JmsAnonymousProducerTest.java  | 62 +++++++++++++++-----
 1 file changed, 48 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/263c93d8/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/producer/JmsAnonymousProducerTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/producer/JmsAnonymousProducerTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/producer/JmsAnonymousProducerTest.java
index 04b954a..301018e 100644
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/producer/JmsAnonymousProducerTest.java
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/producer/JmsAnonymousProducerTest.java
@@ -20,6 +20,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.jms.Message;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
@@ -27,6 +30,7 @@ import javax.jms.Session;
 
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.qpid.jms.support.AmqpTestSupport;
+import org.apache.qpid.jms.util.StopWatch;
 import org.junit.Test;
 
 /**
@@ -66,28 +70,58 @@ public class JmsAnonymousProducerTest extends AmqpTestSupport {
     }
 
     @Test(timeout = 60000)
-    public void testAnonymousSendToMultipleDestinations() throws Exception {
+    public void testAnonymousSendToThreeDestinations() throws Exception {
+        StopWatch timer = new StopWatch();
+        doTestAnonymousProducerSendToMultipleDests(3, 1);
+        LOG.info("Time to send to three destinations: {} ms", timer.taken());
+    }
+
+    @Test(timeout = 60000)
+    public void testAnonymousSendToTenDestinations() throws Exception {
+        StopWatch timer = new StopWatch();
+        doTestAnonymousProducerSendToMultipleDests(10, 1);
+        LOG.info("Time to send to ten destinations: {} ms", timer.taken());
+    }
+
+    @Test(timeout = 60000)
+    public void testAnonymousSendToOneHundredDestinations() throws Exception {
+        StopWatch timer = new StopWatch();
+        doTestAnonymousProducerSendToMultipleDests(100, 1);
+        LOG.info("Time to send to one hundred destinations: {} ms", timer.taken());
+    }
+
+    @Test(timeout = 60000)
+    public void testAnonymousSendToTenDestinationsTenTimes() throws Exception {
+        StopWatch timer = new StopWatch();
+        doTestAnonymousProducerSendToMultipleDests(10, 10);
+        LOG.info("Time to send to ten destinations ten times: {} ms", timer.taken());
+    }
+
+    public void doTestAnonymousProducerSendToMultipleDests(int numDestinations, int numIterations) throws Exception {
         connection = createAmqpConnection();
         assertNotNull(connection);
         connection.start();
 
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        Queue queue1 = session.createQueue(name.getMethodName() + 1);
-        Queue queue2 = session.createQueue(name.getMethodName() + 2);
-        Queue queue3 = session.createQueue(name.getMethodName() + 3);
+
+        List<Queue> queues = new ArrayList<Queue>(numDestinations);
+        for (int i = 0; i < numDestinations; ++i) {
+            queues.add(session.createQueue(name.getMethodName() + i));
+        }
+
         assertNotNull(session);
         MessageProducer producer = session.createProducer(null);
 
-        Message message = session.createMessage();
-        producer.send(queue1, message);
-        producer.send(queue2, message);
-        producer.send(queue3, message);
+        for (int iteration = 1; iteration <= numIterations; ++iteration) {
+            Message message = session.createMessage();
+            for (int i = 0; i < numDestinations; ++i) {
+                producer.send(queues.get(i), message);
+            }
 
-        QueueViewMBean proxy = getProxyToQueue(name.getMethodName() + 1);
-        assertEquals(1, proxy.getQueueSize());
-        proxy = getProxyToQueue(name.getMethodName() + 2);
-        assertEquals(1, proxy.getQueueSize());
-        proxy = getProxyToQueue(name.getMethodName() + 3);
-        assertEquals(1, proxy.getQueueSize());
+            for (int i = 0; i < numDestinations; ++i) {
+                QueueViewMBean proxy = getProxyToQueue(queues.get(i).getQueueName());
+                assertEquals(iteration, proxy.getQueueSize());
+            }
+        }
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/2] git commit: More correct equals and hashCode

Posted by ta...@apache.org.
More correct equals and hashCode

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/81fc1e5d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/81fc1e5d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/81fc1e5d

Branch: refs/heads/master
Commit: 81fc1e5d2b77f370ce11b2cab82e198bb0a5c74e
Parents: 263c93d
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Oct 3 17:15:47 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Oct 3 17:15:47 2014 -0400

----------------------------------------------------------------------
 .../org/apache/qpid/jms/JmsDestination.java     | 23 +++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/81fc1e5d/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
index a86e0f7..a736ed6 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
@@ -136,14 +136,31 @@ public abstract class JmsDestination extends JNDIStorable implements JmsResource
             return false;
         }
 
-        JmsDestination d = (JmsDestination) o;
-        return getName().equals(d.getName());
+        JmsDestination other = (JmsDestination) o;
+        if (name == null && other.name != null) {
+            return false;
+        } else if (!name.equals(other.name)) {
+            return false;
+        }
+
+        if (temporary != other.temporary) {
+            return false;
+        }
+        if (topic != other.topic) {
+            return false;
+        }
+
+        return true;
     }
 
     @Override
     public int hashCode() {
         if (hashValue == 0) {
-            hashValue = getName().hashCode();
+            final int prime = 31;
+            hashValue = 1;
+            hashValue = prime * hashValue + ((name == null) ? 0 : name.hashCode());
+            hashValue = prime * hashValue + (temporary ? 1231 : 1237);
+            hashValue = prime * hashValue + (topic ? 1231 : 1237);
         }
         return hashValue;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org