From 485fcafcdfbb71b254977bbe5a670472aaaa4081 Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Tue, 12 Apr 2016 14:13:52 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-5923 Updating tests to check prioritized messages as well --- .../AbstractPendingMessageCursorTest.java | 27 +++++++++++++++++++ .../KahaDBPendingMessageCursorTest.java | 11 ++++++++ .../MemoryPendingMessageCursorTest.java | 8 ++++++ .../MultiKahaDBPendingMessageCursorTest.java | 7 +++++ 4 files changed, 53 insertions(+) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java index a31f402987..5e4d07a08c 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java @@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.net.URI; +import java.util.Arrays; +import java.util.Collection; import java.util.concurrent.atomic.AtomicLong; import javax.jms.Connection; @@ -48,6 +50,7 @@ import org.apache.activemq.util.Wait.Condition; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,6 +70,25 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat protected String defaultQueueName = "test.queue"; protected String defaultTopicName = "test.topic"; protected static int maxMessageSize = 1000; + protected boolean prioritizedMessages; + + @Parameters(name="prioritizedMessages={0}") + public static Collection data() { + return Arrays.asList(new Object[][] { + // use priority messages + {true}, + // don't use priority messages + {false} + }); + } + + /** + * @param prioritizedMessages + */ + public AbstractPendingMessageCursorTest(boolean prioritizedMessages) { + super(); + this.prioritizedMessages = prioritizedMessages; + } @Before public void startBroker() throws Exception { @@ -86,6 +108,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat PolicyEntry policy = new PolicyEntry(); policy.setTopicPrefetch(100); policy.setDurableTopicPrefetch(100); + policy.setPrioritizedMessages(isPrioritizedMessages()); PolicyMap pMap = new PolicyMap(); pMap.setDefaultEntry(policy); broker.setDestinationPolicy(pMap); @@ -114,6 +137,10 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat protected abstract void initPersistence(BrokerService brokerService) throws IOException; + protected boolean isPrioritizedMessages() { + return prioritizedMessages; + } + @Test public void testQueueMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java index 8a2c287d3d..5cefc1b778 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java @@ -33,6 +33,8 @@ import org.apache.commons.io.FileUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,6 +44,7 @@ import org.slf4j.LoggerFactory; * AMQ-5923 * */ +@RunWith(Parameterized.class) public class KahaDBPendingMessageCursorTest extends AbstractPendingMessageCursorTest { protected static final Logger LOG = LoggerFactory @@ -50,6 +53,13 @@ public class KahaDBPendingMessageCursorTest extends @Rule public TemporaryFolder dataFileDir = new TemporaryFolder(new File("target")); + /** + * @param prioritizedMessages + */ + public KahaDBPendingMessageCursorTest(boolean prioritizedMessages) { + super(prioritizedMessages); + } + @Override protected void setUpBroker(boolean clearDataDir) throws Exception { if (clearDataDir && dataFileDir.getRoot().exists()) @@ -159,4 +169,5 @@ public class KahaDBPendingMessageCursorTest extends verifyPendingStats(topic, subKey, 200, publishedMessageSize.get()); verifyStoreStats(topic, 0, 0); } + } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java index 16d1919502..257bbce251 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java @@ -27,6 +27,8 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.store.memory.MemoryPersistenceAdapter; import org.apache.activemq.util.SubscriptionKey; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,10 +38,16 @@ import org.slf4j.LoggerFactory; * AMQ-5748 * */ +@RunWith(Parameterized.class) public class MemoryPendingMessageCursorTest extends AbstractPendingMessageCursorTest { protected static final Logger LOG = LoggerFactory .getLogger(MemoryPendingMessageCursorTest.class); + + public MemoryPendingMessageCursorTest(boolean prioritizedMessages) { + super(prioritizedMessages); + } + @Override protected void initPersistence(BrokerService brokerService) throws IOException { broker.setPersistent(false); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MultiKahaDBPendingMessageCursorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MultiKahaDBPendingMessageCursorTest.java index 97689801ae..9d8755fbfc 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MultiKahaDBPendingMessageCursorTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MultiKahaDBPendingMessageCursorTest.java @@ -34,6 +34,13 @@ import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter; public class MultiKahaDBPendingMessageCursorTest extends KahaDBPendingMessageCursorTest { + /** + * @param prioritizedMessages + */ + public MultiKahaDBPendingMessageCursorTest(boolean prioritizedMessages) { + super(prioritizedMessages); + } + @Override protected void initPersistence(BrokerService brokerService) throws IOException {