camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r743724 - in /camel/trunk/components/camel-mail/src: main/java/org/apache/camel/component/mail/ test/java/org/apache/camel/component/mail/
Date Thu, 12 Feb 2009 13:15:31 GMT
Author: davsclaus
Date: Thu Feb 12 13:15:30 2009
New Revision: 743724

URL: http://svn.apache.org/viewvc?rev=743724&view=rev
Log:
CAMEL-1289: moved filter strategy from component to endpoint

Modified:
    camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
    camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
    camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java

Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java?rev=743724&r1=743723&r2=743724&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
(original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
Thu Feb 12 13:15:30 2009
@@ -23,10 +23,7 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
-import org.apache.camel.HeaderFilterStrategyAware;
 import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.impl.DefaultHeaderFilterStrategy;
-import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -34,9 +31,8 @@
  *
  * @version $Revision:520964 $
  */
-public class MailComponent extends DefaultComponent implements HeaderFilterStrategyAware
{
+public class MailComponent extends DefaultComponent {
     private MailConfiguration configuration;
-    private HeaderFilterStrategy headerFilterStrategy = new DefaultHeaderFilterStrategy();
 
     public MailComponent() {
         this.configuration = new MailConfiguration();
@@ -116,11 +112,4 @@
         return path;
     }
 
-    public HeaderFilterStrategy getHeaderFilterStrategy() {
-        return headerFilterStrategy;
-    }
-
-    public void setHeaderFilterStrategy(HeaderFilterStrategy strategy) {
-        headerFilterStrategy = strategy;
-    }
 }

Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java?rev=743724&r1=743723&r2=743724&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
(original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
Thu Feb 12 13:15:30 2009
@@ -25,6 +25,7 @@
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultHeaderFilterStrategy;
 import org.apache.camel.impl.ScheduledPollEndpoint;
+import org.apache.camel.spi.HeaderFilterStrategy;
 import org.springframework.mail.javamail.JavaMailSender;
 import org.springframework.mail.javamail.JavaMailSenderImpl;
 
@@ -36,15 +37,14 @@
 public class MailEndpoint extends ScheduledPollEndpoint {
     private MailBinding binding;
     private MailConfiguration configuration;
+    private HeaderFilterStrategy headerFilterStrategy = new DefaultHeaderFilterStrategy();
 
     public MailEndpoint() {
-        this.binding = new MailBinding();
     }
 
     public MailEndpoint(String uri, MailComponent component, MailConfiguration configuration)
{
         super(uri, component);
         this.configuration = configuration;
-        this.binding = new MailBinding(component.getHeaderFilterStrategy());
     }
 
     public MailEndpoint(String endpointUri, MailConfiguration configuration) {
@@ -102,20 +102,22 @@
         return new MailExchange(this, getExchangePattern(), getBinding(), message);
     }
 
+    public boolean isSingleton() {
+        return false;
+    }
+
     // Properties
     // -------------------------------------------------------------------------
+
     public MailBinding getBinding() {
         if (binding == null) {
-            binding = new MailBinding();
+            binding = new MailBinding(headerFilterStrategy);
         }
         return binding;
     }
 
     /**
-     * Sets the binding used to convert from a Camel message to and from a Mail
-     * message
-     *
-     * @param binding the binding to use
+     * Sets the binding used to convert from a Camel message to and from a Mail message
      */
     public void setBinding(MailBinding binding) {
         this.binding = binding;
@@ -129,7 +131,12 @@
         this.configuration = configuration;
     }
 
-    public boolean isSingleton() {
-        return false;
+    public HeaderFilterStrategy getHeaderFilterStrategy() {
+        return headerFilterStrategy;
     }
+
+    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
+        this.headerFilterStrategy = headerFilterStrategy;
+    }
+
 }

Modified: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java?rev=743724&r1=743723&r2=743724&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java
(original)
+++ camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailDefaultDelayForMailConsumeTest.java
Thu Feb 12 13:15:30 2009
@@ -37,18 +37,19 @@
         mock.reset();
         template.sendBody("smtp://bond@localhost", "Hello Paris");
         mock.expectedBodiesReceived("Hello Paris");
-        // poll next mail and that is should be done within the default delay + 2 sec slack
-        mock.setResultWaitTime(MailConsumer.DEFAULT_CONSUMER_DELAY + 2000L);
+        // poll next mail and that is should be done within the default delay (overrule to
5 sec) + 2 sec slack
+        mock.setResultWaitTime(5000L + 2000L);
         mock.assertIsSatisfied();
         long delta = System.currentTimeMillis() - start;
-        assertTrue("Camel should not default poll the mailbox to often", delta > MailConsumer.DEFAULT_CONSUMER_DELAY
- 1000L);
+        assertTrue("Camel should not default poll the mailbox to often", delta > 5000
- 1000L);
     }
 
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("pop3://bond@localhost").to("mock:result");
+                // we overrule the default of 60 sec to 5 so the unit test is faster
+                from("pop3://bond@localhost?delay=5000").to("mock:result");
             }
         };
     }



Mime
View raw message