Repository: activemq
Updated Branches:
  refs/heads/master 46160c7b7 -> 063d21f88


[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/063d21f8
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/063d21f8
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/063d21f8

Branch: refs/heads/master
Commit: 063d21f88062a09b7efc1669608cbbacdeb11aac
Parents: e9a64b1
Author: jgoodyear <[email protected]>
Authored: Wed Jul 18 13:04:07 2018 -0230
Committer: Jeff Genender <[email protected]>
Committed: Wed Jul 18 10:39:29 2018 -0600

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/063d21f8/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

Reply via email to