From e937c9903f9fa429c23fe50a3fd49e99ad2de0b9 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 26 Apr 2018 21:16:38 -0400 Subject: [PATCH] NO-JIRA Fixing Test only no feature or semantic changes on this commit, hence no JIRA --- .../openwire/BasicOpenWireTest.java | 6 ++-- .../openwire/amq/RedeliveryPolicyTest.java | 30 +++++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java index bc4829e4c1..0a079f2377 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java @@ -66,11 +66,11 @@ public class BasicOpenWireTest extends OpenWireTestBase { System.setProperty("org.apache.activemq.transport.AbstractInactivityMonitor.keepAliveTime", "5"); createFactories(); SimpleString coreQueue = new SimpleString(queueName); - this.server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, false, false, -1, false, true); + this.server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, true, false, -1, false, true); testQueues.put(queueName, coreQueue); SimpleString coreQueue2 = new SimpleString(queueName2); - this.server.createQueue(coreQueue2, RoutingType.ANYCAST, coreQueue2, null, false, false, -1, false, true); + this.server.createQueue(coreQueue2, RoutingType.ANYCAST, coreQueue2, null, true, false, -1, false, true); testQueues.put(queueName2, coreQueue2); SimpleString durableQueue = new SimpleString(durableQueueName); @@ -151,7 +151,7 @@ public class BasicOpenWireTest extends OpenWireTestBase { SimpleString coreQ = testQueues.get(qname); if (coreQ == null) { coreQ = new SimpleString(qname); - this.server.createQueue(coreQ, RoutingType.ANYCAST, coreQ, null, false, false, -1, false, true); + this.server.createQueue(coreQ, RoutingType.ANYCAST, coreQ, null, true, false, -1, false, true); testQueues.put(qname, coreQ); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java index 030d5223d5..7ee0eb9d39 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.tests.integration.openwire.amq; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; @@ -34,6 +37,13 @@ import org.junit.Test; */ public class RedeliveryPolicyTest extends BasicOpenWireTest { + @Override + public void setUp() throws Exception { + // making data persistent makes it easier to debug it with print-data + this.realStore = true; + super.setUp(); + } + @Test public void testGetNext() throws Exception { @@ -506,6 +516,12 @@ public class RedeliveryPolicyTest extends BasicOpenWireTest { session.commit(); } + private void send(Session session, MessageProducer producer, Destination destination, String text) throws Exception { + Message message = session.createTextMessage(text); + message.setStringProperty("texto", text); + producer.send(destination, message); + } + @Test public void testRedeliveryPolicyPerDestination() throws Exception { RedeliveryPolicy queuePolicy = new RedeliveryPolicy(); @@ -525,22 +541,24 @@ public class RedeliveryPolicyTest extends BasicOpenWireTest { map.put(new ActiveMQTopic(">"), topicPolicy); map.put(new ActiveMQQueue(">"), queuePolicy); + connection.setClientID("id1"); connection.start(); Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); ActiveMQQueue queue = new ActiveMQQueue("TEST"); - ActiveMQTopic topic = new ActiveMQTopic("TEST"); + ActiveMQTopic topic = new ActiveMQTopic("TESTTOPIC"); this.makeSureCoreQueueExist("TEST"); MessageProducer producer = session.createProducer(null); + producer.setDeliveryMode(DeliveryMode.PERSISTENT); MessageConsumer queueConsumer = session.createConsumer(queue); - MessageConsumer topicConsumer = session.createConsumer(topic); + MessageConsumer topicConsumer = session.createDurableSubscriber(topic, "tp1"); // Send the messages - producer.send(queue, session.createTextMessage("1st")); - producer.send(queue, session.createTextMessage("2nd")); - producer.send(topic, session.createTextMessage("1st")); - producer.send(topic, session.createTextMessage("2nd")); + send(session, producer, queue,"1st"); + send(session, producer, queue,"2nd"); + send(session, producer, topic,"1st"); + send(session, producer, topic,"2nd"); session.commit();