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
This commit is contained in:
Christian Posta 2013-01-28 14:22:47 +00:00
parent 9988fff773
commit 8e6ce9f7d7
1 changed files with 31 additions and 0 deletions

View File

@ -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;