activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cepo...@apache.org
Subject svn commit: r1439420 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
Date Mon, 28 Jan 2013 14:22:47 GMT
Author: ceposta
Date: Mon Jan 28 14:22:47 2013
New Revision: 1439420

URL: http://svn.apache.org/viewvc?rev=1439420&view=rev
Log:
Added a test to the QueueBrowser to browse "large number of messages (1000)"

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java?rev=1439420&r1=1439419&r2=1439420&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
Mon Jan 28 14:22:47 2013
@@ -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
         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;



Mime
View raw message