activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r534386 - in /activemq/camel/trunk/camel-mail/src: main/java/org/apache/camel/component/mail/MailConsumer.java test/java/org/apache/camel/component/mail/MailRouteTest.java
Date Wed, 02 May 2007 11:10:12 GMT
Author: jstrachan
Date: Wed May  2 04:10:09 2007
New Revision: 534386

URL: http://svn.apache.org/viewvc?view=rev&rev=534386
Log:
fixed test case - we were not ignoring deleted mails

Modified:
    activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
    activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java

Modified: activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java?view=diff&rev=534386&r1=534385&r2=534386
==============================================================================
--- activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
(original)
+++ activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
Wed May  2 04:10:09 2007
@@ -17,6 +17,12 @@
  */
 package org.apache.camel.component.mail;
 
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.PollingConsumer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import javax.mail.Flags;
 import javax.mail.Folder;
 import javax.mail.Message;
@@ -25,12 +31,6 @@
 import javax.mail.event.MessageCountEvent;
 import javax.mail.event.MessageCountListener;
 
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.impl.PollingConsumer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 /**
  * A {@link Consumer} which consumes messages from JavaMail using a {@link Transport} and
dispatches them
  * to the {@link Processor}
@@ -97,11 +97,9 @@
 
         int count = folder.getMessageCount();
         if (count > 0) {
-            Message message = folder.getMessage(1);
-
-            processMessage(message);
-
-            flagMessageDeleted(message);
+            Message[] messages = folder.getMessages();
+            MessageCountEvent event = new MessageCountEvent(folder, MessageCountEvent.ADDED,
true, messages);
+            messagesAdded(event);
         }
         else if (count == -1) {
             throw new MessagingException("Folder: " + folder.getFullName() + " is closed");
@@ -112,11 +110,12 @@
 
     protected void processMessage(Message message) {
         try {
-			MailExchange exchange = endpoint.createExchange(message);
-			getProcessor().process(exchange);
-		} catch (Throwable e) {
-			handleException(e);
-		}
+            MailExchange exchange = endpoint.createExchange(message);
+            getProcessor().process(exchange);
+        }
+        catch (Throwable e) {
+            handleException(e);
+        }
     }
 
     protected void ensureFolderIsOpen() throws MessagingException {

Modified: activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java?view=diff&rev=534386&r1=534385&r2=534386
==============================================================================
--- activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
(original)
+++ activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
Wed May  2 04:10:09 2007
@@ -46,8 +46,11 @@
         // lets test the first sent worked
         assertMailboxReceivedMessages("james@localhost");
 
+        // lets sleep to check that the mail poll does not redeliver duplicate mails
+        Thread.sleep(3000);
+
         // lets test the receive worked
-        resultEndpoint.assertIsSatisfied(10000);
+        resultEndpoint.assertIsSatisfied();
 
         assertMailboxReceivedMessages("copy@localhost");
     }
@@ -65,8 +68,8 @@
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("smtp://james@localhost").to("queue:a");
-                from("queue:a").to("smtp://result@localhost", "smtp://copy@localhost");
+                from("smtp://james@localhost").to("direct:a");
+                from("direct:a").to("smtp://result@localhost", "smtp://copy@localhost");
                 from("smtp://result@localhost").convertBodyTo(String.class).to("mock:result");
             }
         };



Mime
View raw message