From 8e6ce9f7d79c54c657fc458237d92de67886ea0d Mon Sep 17 00:00:00 2001 From: Christian Posta Date: Mon, 28 Jan 2013 14:22:47 +0000 Subject: [PATCH] Added a test to the QueueBrowser to browse "large number of messages (1000)" git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1439420 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/JmsQueueBrowserTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java b/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java index ae61fa06f5..c262c7d687 100755 --- a/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java @@ -25,6 +25,7 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; +import javax.jms.Connection; import javax.jms.TextMessage; import javax.management.ObjectName; import javax.management.openmbean.CompositeData; @@ -303,6 +304,36 @@ public class JmsQueueBrowserTest extends JmsTestSupport { producer.close(); } + + public void testLargeNumberOfMessages() throws Exception { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + ActiveMQQueue destination = new ActiveMQQueue("TEST"); + connection.start(); + + MessageProducer producer = session.createProducer(destination); + + for (int i = 0; i < 1000; i++) { + producer.send(session.createTextMessage("Message: " + i)); + } + + QueueBrowser browser = session.createBrowser(destination); + Enumeration enumeration = browser.getEnumeration(); + + assertTrue(enumeration.hasMoreElements()); + + int numberBrowsed = 0; + + while (enumeration.hasMoreElements()) { + enumeration.nextElement(); + numberBrowsed++; + } + + System.out.println("Number browsed: " + numberBrowsed); + assertEquals(1000, numberBrowsed); + browser.close(); + producer.close(); + + } public void testQueueBrowserWith2Consumers() throws Exception { final int numMessages = 1000;