From b4f880a75c090be8166a77223d5ca70cef737ada Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Wed, 24 Jul 2013 15:13:53 +0000 Subject: [PATCH] Add more info to assert messages. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1506591 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/usecases/MemoryLimitTest.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java index 5bd7f79153..78f1b971e2 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MemoryLimitTest.java @@ -16,6 +16,16 @@ */ package org.apache.activemq.usecases; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Queue; +import javax.jms.Session; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.TestSupport; import org.apache.activemq.broker.BrokerService; @@ -34,11 +44,6 @@ import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.*; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - @RunWith(value = Parameterized.class) public class MemoryLimitTest extends TestSupport { private static final Logger LOG = LoggerFactory.getLogger(MemoryLimitTest.class); @@ -81,6 +86,7 @@ public class MemoryLimitTest extends TestSupport { return broker; } + @Override @Before public void setUp() throws Exception { if (broker == null) { @@ -90,6 +96,7 @@ public class MemoryLimitTest extends TestSupport { broker.waitUntilStarted(); } + @Override @After public void tearDown() throws Exception { if (broker != null) { @@ -122,7 +129,8 @@ public class MemoryLimitTest extends TestSupport { // assert we didn't break high watermark (70%) usage Destination dest = broker.getDestination((ActiveMQQueue) queue); LOG.info("Destination usage: " + dest.getMemoryUsage()); - assertTrue(dest.getMemoryUsage().getPercentUsage() <= 71); + int percentUsage = dest.getMemoryUsage().getPercentUsage(); + assertTrue("Should be less than 70% of limit but was: " + percentUsage, percentUsage <= 71); LOG.info("Broker usage: " + broker.getSystemUsage().getMemoryUsage()); assertTrue(broker.getSystemUsage().getMemoryUsage().getPercentUsage() <= 71); @@ -145,13 +153,10 @@ public class MemoryLimitTest extends TestSupport { assertNotNull("Didn't receive message " + i, msg); msg.acknowledge(); } - } /** - * * Handy test for manually checking what's going on - * */ @Ignore @Test(timeout = 120000) @@ -178,7 +183,6 @@ public class MemoryLimitTest extends TestSupport { }; producer2.setMessageCount(1000); - ConsumerThread consumer = new ConsumerThread(sess, sess.createQueue("STORE.1")); consumer.setBreakOnNull(false); consumer.setMessageCount(1000); @@ -196,6 +200,5 @@ public class MemoryLimitTest extends TestSupport { producer2.join(); assertEquals("consumer got all produced messages", producer.getMessageCount(), consumer.getReceived()); - } }