camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r983988 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/ main/java/org/apache/camel/processor/ test/java/org/apache/camel/processor/
Date Tue, 10 Aug 2010 13:24:00 GMT
Author: davsclaus
Date: Tue Aug 10 13:24:00 2010
New Revision: 983988

URL: http://svn.apache.org/viewvc?rev=983988&view=rev
Log:
CAMEL-3039: Added FILTER_MATCHED exchange property in the Filter EIP so we know if the Exchange
was filtered or not.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java
      - copied, changed from r983928, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/FilterProcessor.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=983988&r1=983987&r2=983988&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Tue Aug 10 13:24:00
2010
@@ -69,6 +69,7 @@ public interface Exchange {
     String FILE_PATH            = "CamelFilePath";
     String FILE_PARENT          = "CamelFileParent";
     String FILE_LAST_MODIFIED   = "CamelFileLastModified";
+    String FILTER_MATCHED       = "CamelFilterMatched";
 
     String GROUPED_EXCHANGE = "CamelGroupedExchange";
     

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/FilterProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/FilterProcessor.java?rev=983988&r1=983987&r2=983988&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/FilterProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/FilterProcessor.java Tue
Aug 10 13:24:00 2010
@@ -52,6 +52,9 @@ public class FilterProcessor extends Del
             LOG.debug("Filter matches: " + matches + " for exchange: " + exchange);
         }
 
+        // set property whether the filter matches or not
+        exchange.setProperty(Exchange.FILTER_MATCHED, matches);
+
         if (matches) {
             return super.process(exchange, callback);
         } else {

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java
(from r983928, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java&r1=983928&r2=983988&rev=983988&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java
Tue Aug 10 13:24:00 2010
@@ -17,37 +17,48 @@
 package org.apache.camel.processor;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version $Revision$
  */
-public class FilterTest extends ContextTestSupport {
+public class FilterNotMatchedTest extends ContextTestSupport {
 
     public void testSendMatchingMessage() throws Exception {
-        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
-        resultEndpoint.expectedMessageCount(1);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).property(Exchange.FILTER_MATCHED).isEqualTo(true);
+
+        getMockEndpoint("mock:end").message(0).property(Exchange.FILTER_MATCHED).isNotNull();
+        getMockEndpoint("mock:end").message(0).property(Exchange.FILTER_MATCHED).isEqualTo(true);
 
         template.sendBodyAndHeader("direct:start", "<matched/>", "foo", "bar");
 
-        resultEndpoint.assertIsSatisfied();
+        assertMockEndpointsSatisfied();
     }
 
     public void testSendNotMatchingMessage() throws Exception {
-        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
-        resultEndpoint.expectedMessageCount(0);
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(0);
+
+        getMockEndpoint("mock:end").message(0).property(Exchange.FILTER_MATCHED).isNotNull();
+        getMockEndpoint("mock:end").message(0).property(Exchange.FILTER_MATCHED).isEqualTo(false);
 
         template.sendBodyAndHeader("direct:start", "<notMatched/>", "foo", "notMatchedHeaderValue");
 
-        resultEndpoint.assertIsSatisfied();
+        assertMockEndpointsSatisfied();
     }
 
-
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
+                from("direct:start")
+                    .filter(header("foo").isEqualTo("bar"))
+                        .to("mock:result")
+                    .end()
+                    .to("mock:end");
             }
         };
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java?rev=983988&r1=983987&r2=983988&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java Tue Aug
10 13:24:00 2010
@@ -17,6 +17,7 @@
 package org.apache.camel.processor;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
@@ -28,6 +29,7 @@ public class FilterTest extends ContextT
     public void testSendMatchingMessage() throws Exception {
         MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
         resultEndpoint.expectedMessageCount(1);
+        resultEndpoint.message(0).property(Exchange.FILTER_MATCHED).isEqualTo(true);
 
         template.sendBodyAndHeader("direct:start", "<matched/>", "foo", "bar");
 
@@ -43,7 +45,6 @@ public class FilterTest extends ContextT
         resultEndpoint.assertIsSatisfied();
     }
 
-
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {



Mime
View raw message