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()); - } }