activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [01/13] git commit: Added test to reproduce AMQ-4887
Date Thu, 13 Mar 2014 15:49:01 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.9 687aa9265 -> 88959d5c6


Added test to reproduce AMQ-4887


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

Branch: refs/heads/activemq-5.9
Commit: bbf5c67489057dacfc7127dd69a0cf5584291f13
Parents: 687aa92
Author: Kevin Earls <kevin@kevinearls.com>
Authored: Thu Dec 5 10:45:38 2013 +0100
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Thu Mar 13 11:04:43 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/bbf5c674/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java
new file mode 100644
index 0000000..f29f605
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java
@@ -0,0 +1,81 @@
+/**
+ * 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.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.BytesMessage;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import static org.junit.Assert.*;
+
+public class AMQ4887Test {
+    private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4887Test.class);
+    private static final Integer ITERATIONS = 10;
+    @Rule
+    public TestName name = new TestName();
+
+    @Test
+    public void testSetPropertyBeforeCopy() throws Exception {
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
+        ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
+        connection.start();
+
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination destination = session.createQueue(name.toString());
+        MessageConsumer consumer = session.createConsumer(destination);
+        MessageProducer producer = session.createProducer(destination);
+
+        byte[] messageContent = "bytes message".getBytes();
+        BytesMessage bytesMessage = session.createBytesMessage();
+        bytesMessage.writeBytes(messageContent);
+
+        for (int i=0; i < ITERATIONS; i++) {
+            long sendTime = System.currentTimeMillis();
+            bytesMessage.setLongProperty("sendTime", sendTime);
+            producer.send(bytesMessage);
+
+            LOG.debug("Receiving message " + i);
+            Message receivedMessage =  consumer.receive(5000);
+            assertNotNull("On message " + i, receivedMessage);
+            assertTrue("On message " + i, receivedMessage instanceof BytesMessage);
+
+            BytesMessage receivedBytesMessage = (BytesMessage) receivedMessage;
+            byte[] receivedBytes = new byte[(int) receivedBytesMessage.getBodyLength()];
+            receivedBytesMessage.readBytes(receivedBytes);
+            LOG.debug("Message " + i + " content [" + new String(receivedBytes) + "]");
+            assertEquals("On message " + i, messageContent.length, receivedBytes.length);
+            assertArrayEquals("On message " + i, messageContent, receivedBytes);
+
+            long receivedSendTime = receivedBytesMessage.getLongProperty("sendTime");
+            assertEquals("On message " + i, receivedSendTime, sendTime);
+
+            Thread.sleep(10);
+        }
+    }
+
+}


Mime
View raw message