You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jg...@apache.org on 2018/07/18 16:37:18 UTC

[2/3] activemq git commit: [AMQ-7013] Adding unit test

[AMQ-7013] Adding unit test


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

Branch: refs/heads/activemq-5.15.x
Commit: 7ba7bfd9cd9d070840a35ed71422eb4d6e60ab1e
Parents: 3f83bfc
Author: jgoodyear <ja...@gmail.com>
Authored: Wed Jul 18 13:04:07 2018 -0230
Committer: jgoodyear <ja...@gmail.com>
Committed: Wed Jul 18 13:04:07 2018 -0230

----------------------------------------------------------------------
 .../org/apache/activemq/bugs/AMQ7013Test.java   | 55 ++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/7ba7bfd9/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7013Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7013Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7013Test.java
new file mode 100644
index 0000000..87e21a3
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7013Test.java
@@ -0,0 +1,55 @@
+/**
+ * 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.activemq.bugs;
+
+import org.apache.activemq.command.XATransactionId;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotEquals;
+
+public class AMQ7013Test {
+
+    @Test
+    public void hashTest() throws Exception{
+
+        byte[] globalId1 = hexStringToByteArray("00000000000000000000ffff0a970616dbbe2c3b5b42f94800002259");
+        byte[] branchQualifier1 = hexStringToByteArray("00000000000000000000ffff0a970616dbbe2c3b5b42f94800002259");
+        XATransactionId id1 = new XATransactionId();
+        id1.setGlobalTransactionId(globalId1);
+        id1.setBranchQualifier(branchQualifier1);
+        id1.setFormatId(131077);
+
+        byte[] globalId2 = hexStringToByteArray("00000000000000000000ffff0a970616dbbe2c3b5b42f948000021d2");
+        byte[] branchQualifier2 = hexStringToByteArray("00000000000000000000ffff0a970616dbbe2c3b5b42f948000021d2");
+        XATransactionId id2 = new XATransactionId();
+        id2.setGlobalTransactionId(globalId2);
+        id2.setBranchQualifier(branchQualifier2);
+        id2.setFormatId(131077);
+
+        assertNotEquals(id1.hashCode(), id2.hashCode());
+    }
+
+    public byte[] hexStringToByteArray(String s) {
+        int len = s.length();
+        byte[] data = new byte[len / 2];
+        for (int i = 0; i < len; i += 2) {
+            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+                    + Character.digit(s.charAt(i+1), 16));
+        }
+        return data;
+    }
+}
\ No newline at end of file