activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1021328 - in /activemq/trunk/activemq-spring/src/test: java/org/apache/activemq/spring/Listener.java java/org/apache/activemq/spring/ListenerTest.java resources/spring/spring.xml
Date Mon, 11 Oct 2010 12:49:43 GMT
Author: dejanb
Date: Mon Oct 11 12:49:42 2010
New Revision: 1021328

URL: http://svn.apache.org/viewvc?rev=1021328&view=rev
Log:
improvement on the composite queue spring listener test

Modified:
    activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/Listener.java
    activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/ListenerTest.java
    activemq/trunk/activemq-spring/src/test/resources/spring/spring.xml

Modified: activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/Listener.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/Listener.java?rev=1021328&r1=1021327&r2=1021328&view=diff
==============================================================================
--- activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/Listener.java
(original)
+++ activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/Listener.java
Mon Oct 11 12:49:42 2010
@@ -17,6 +17,8 @@
 package org.apache.activemq.spring;
 
 import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -25,6 +27,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class Listener implements MessageListener {
+    private static final Log LOG = LogFactory.getLog(Listener.class);
 
 	List<Message> messages = new ArrayList<Message>();
 	long lastReceived = 0L;
@@ -33,7 +36,7 @@ public class Listener implements Message
 	public void onMessage(Message message)  {
 
         try {
-            System.out.println("LISTENER received " + message.getJMSDestination() + " " +
((ActiveMQTextMessage)message).getText());
+            LOG.info("LISTENER received " + message.getJMSDestination() + " " + ((ActiveMQTextMessage)message).getText());
             lastReceived = System.currentTimeMillis();
             synchronized (messages) {
                 messages.add(message);

Modified: activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/ListenerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/ListenerTest.java?rev=1021328&r1=1021327&r2=1021328&view=diff
==============================================================================
--- activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/ListenerTest.java
(original)
+++ activemq/trunk/activemq-spring/src/test/java/org/apache/activemq/spring/ListenerTest.java
Mon Oct 11 12:49:42 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.spring;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -32,6 +34,9 @@ import javax.jms.*;
 @ContextConfiguration(locations = {"classpath:spring/spring.xml"})
 @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
 public class ListenerTest {
+    private static final Log LOG = LogFactory.getLog(ListenerTest.class);
+
+    int msgNum = 10;
 
     protected String bindAddress = "vm://localhost";    
 
@@ -41,24 +46,24 @@ public class ListenerTest {
     @Test
     @DirtiesContext
     public void testSimple() throws Exception {
-        sendMessages("SIMPLE", 10);
+        sendMessages("SIMPLE", msgNum);
 
         Thread.sleep(3000);
 
-        System.out.println(listener.messages.size());
-        Assert.assertEquals(listener.messages.size(), 10);
+        LOG.info("messages received= " + listener.messages.size());
+        Assert.assertEquals(listener.messages.size(), msgNum);
     }
 
 
     @Test
     @DirtiesContext
     public void testComposite() throws Exception {
-        sendMessages("TEST.1,TEST.2,TEST.3,TEST.4,TEST.5,TEST.6", 10);
+        sendMessages("TEST.1,TEST.2,TEST.3,TEST.4,TEST.5,TEST.6", msgNum);
 
         Thread.sleep(3000);
 
-        System.out.println(listener.messages.size());
-        Assert.assertEquals(listener.messages.size(), 60);
+        LOG.info("messages received= " + listener.messages.size());
+        Assert.assertEquals(listener.messages.size(), 6 * msgNum);
     }
 
     public void sendMessages(String destName, int msgNum) throws Exception {
@@ -68,7 +73,9 @@ public class ListenerTest {
         Destination dest = sess.createQueue(destName);
         MessageProducer producer = sess.createProducer(dest);
         for (int i = 0; i < msgNum; i++) {
-            producer.send(sess.createTextMessage("test"));
+            String messageText = i +" test";
+            LOG.info("sending message '" + messageText + "'");
+            producer.send(sess.createTextMessage(messageText));
         }
     }
 

Modified: activemq/trunk/activemq-spring/src/test/resources/spring/spring.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-spring/src/test/resources/spring/spring.xml?rev=1021328&r1=1021327&r2=1021328&view=diff
==============================================================================
--- activemq/trunk/activemq-spring/src/test/resources/spring/spring.xml (original)
+++ activemq/trunk/activemq-spring/src/test/resources/spring/spring.xml Mon Oct 11 12:49:42
2010
@@ -59,7 +59,8 @@
         <property name="connectionFactory" ref="connectionFactory"/>
         <property name="messageListener" ref="messageListener"/>
         <property name="destinationName" value="TEST.>"/>
-        <property name="sessionTransacted" value="true"/>
+        <property name="transactionManager" ref="transactionManager"/>
+        <property name="cacheLevelName" value="CACHE_CONSUMER"/>
     </bean>
 
 </beans>   
\ No newline at end of file



Mime
View raw message