summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/test
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2012-07-01 20:00:59 +0000
committerRobert Gemmell <robbie@apache.org>2012-07-01 20:00:59 +0000
commit56bf10cb7a1ac41f84c26e938d8b9f8fb019fc2a (patch)
treecb59e06902dc6bc68338fbbc9c8020ff5c3a8801 /qpid/java/broker/src/test
parentd5bb4ce2383ef2ed9a9f3c00b087f8f98bc02e5d (diff)
downloadqpid-python-56bf10cb7a1ac41f84c26e938d8b9f8fb019fc2a.tar.gz
QPID-3923: update ID generation to be consistent across all queues/exchanges/bindings as opposed to deterministic for some and not for others
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1355994 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src/test')
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java111
1 files changed, 111 insertions, 0 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java
new file mode 100644
index 0000000000..e99ac1f063
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/model/UUIDGeneratorTest.java
@@ -0,0 +1,111 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model;
+
+import java.util.UUID;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class UUIDGeneratorTest extends QpidTestCase
+{
+ private static final String VIRTUAL_HOST_NAME_1 = "virtualHost1";
+ private static final String VIRTUAL_HOST_NAME_2 = "virtualHost2";
+ private static final String QUEUE_NAME_1 = "queue1";
+ private static final String QUEUE_NAME_2 = "queue2";
+ private static final String EXCHANGE_NAME_1 = "exchange1";
+ private static final String EXCHANGE_NAME_2 = "exchange2";
+ private static final String BINDING_KEY_1 = "bindingKey1";
+ private static final String BINDING_KEY_2 = "bindingKey2";
+
+ public void testDifferentObjectTypeReturnDifferentIdFromSameValues() throws Exception
+ {
+ UUID id1 = UUIDGenerator.generateQueueUUID("name", "vhost");
+ UUID id2 = UUIDGenerator.generateExchangeUUID("name", "vhost");
+ UUID id3 = UUIDGenerator.generateBindingUUID("name", "name", "name", "vhost");
+
+ assertFalse("IDs should not be equal", id1.equals(id2));
+ assertFalse("IDs should not be equal", id2.equals(id3));
+ assertFalse("IDs should not be equal", id1.equals(id3));
+ }
+
+ public void testRepeatedQueueIdGenerationIsDeterministic() throws Exception
+ {
+ UUID queueIdIteration1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+ UUID queueIdIteration2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+ assertEquals("Queue IDs should be equal", queueIdIteration1, queueIdIteration2);
+ }
+
+ public void testRepeatedExchangeIdGenerationIsDeterministic() throws Exception
+ {
+ UUID exchangeIdIteration1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+ UUID exchangeIdIteration2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+ assertEquals("Exchange IDs should be equal", exchangeIdIteration1, exchangeIdIteration2);
+ }
+
+ public void testRepeatedBindingIdGenerationIsDeterministic() throws Exception
+ {
+ UUID bindingIdIteration1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+ UUID bindingIdIteration2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+ assertEquals("Binding IDs should be equal", bindingIdIteration1, bindingIdIteration2);
+ }
+
+ public void testDifferentQueueNameGivesDifferentQueueId() throws Exception
+ {
+ UUID queue1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+ UUID queue2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_2, VIRTUAL_HOST_NAME_1);
+ assertFalse("Queue IDs should not be equal", queue1.equals(queue2));
+ }
+
+ public void testDifferentExchangeNameGivesDifferentExchangeId() throws Exception
+ {
+ UUID exchange1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+ UUID exchange2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_2, VIRTUAL_HOST_NAME_1);
+ assertFalse("Exchange IDs should not be equal", exchange1.equals(exchange2));
+ }
+
+ public void testDifferentBindingNameGivesDifferentBindingId() throws Exception
+ {
+ UUID binding1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+ UUID binding2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_2, VIRTUAL_HOST_NAME_1);
+ assertFalse("Binding IDs should not be equal", binding1.equals(binding2));
+ }
+
+ public void testDifferentVirtualHostNameGivesDifferentQueueId() throws Exception
+ {
+ UUID queue1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
+ UUID queue2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_2);
+ assertFalse("Queue IDs should not be equal", queue1.equals(queue2));
+ }
+
+ public void testDifferentVirtualHostNameGivesDifferentExchangeId() throws Exception
+ {
+ UUID exchange1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
+ UUID exchange2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_2);
+ assertFalse("Exchange IDs should not be equal", exchange1.equals(exchange2));
+ }
+
+ public void testDifferentVirtualHostNameGivesDifferentBindingId() throws Exception
+ {
+ UUID binding1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
+ UUID binding2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_2);
+ assertFalse("Binding IDs should not be equal", binding1.equals(binding2));
+ }
+}