camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rom...@apache.org
Subject svn commit: r614847 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/processor/TryProcessor.java test/java/org/apache/camel/processor/ValidationTest.java
Date Thu, 24 Jan 2008 11:32:41 GMT
Author: romkal
Date: Thu Jan 24 03:32:37 2008
New Revision: 614847

URL: http://svn.apache.org/viewvc?rev=614847&view=rev
Log:
CAMEL-297: Results from handle() block propagated to the main flow

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java?rev=614847&r1=614846&r2=614847&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TryProcessor.java
Thu Jan 24 03:32:37 2008
@@ -22,6 +22,7 @@
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.ServiceSupport;
+import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.ServiceHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -113,6 +114,7 @@
                 localExchange.setException(null);
                 try {
                     catchClause.process(localExchange);
+                    ExchangeHelper.copyResults(exchange, localExchange);
                 } catch (Exception e1) {
                     LOG.warn("Caught exception inside catch clause: " + e1, e1);
                     throw e1;

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java?rev=614847&r1=614846&r2=614847&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java
Thu Jan 24 03:32:37 2008
@@ -17,10 +17,15 @@
 package org.apache.camel.processor;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.ValidationException;
+import org.apache.camel.builder.Builder;
+import org.apache.camel.builder.ProcessorBuilder;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.ValueBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.language.SimpleExpression;
 
 /**
  * @version $Revision: 1.1 $
@@ -34,27 +39,34 @@
         validEndpoint.expectedMessageCount(1);
         invalidEndpoint.expectedMessageCount(0);
 
-        template.sendBodyAndHeader("direct:start", "<valid/>", "foo", "bar");
+        Object result = template.sendBodyAndHeader("direct:start", "<valid/>", "foo",
"bar");
 
         MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
+        assertEquals("validResult", result);
     }
 
     public void testInvalidMessage() throws Exception {
         invalidEndpoint.expectedMessageCount(1);
         validEndpoint.expectedMessageCount(0);
 
-        template.sendBodyAndHeader("direct:start", "<invalid/>", "foo", "notMatchedHeaderValue");
+        Object result = template.sendBodyAndHeader("direct:start", "<invalid/>", "foo",
"notMatchedHeaderValue");
 
         MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
+        assertEquals("invalidResult", result);
     }
 
     public void testinvalidThenValidMessage() throws Exception {
         validEndpoint.expectedMessageCount(2);
         invalidEndpoint.expectedMessageCount(1);
 
-        template.sendBodyAndHeader("direct:start", "<invalid/>", "foo",  "notMatchedHeaderValue");
-        template.sendBodyAndHeader("direct:start", "<valid/>", "foo",   "bar");
-        template.sendBodyAndHeader("direct:start", "<valid/>", "foo",   "bar");
+        Object result;
+        
+        result = template.sendBodyAndHeader("direct:start", "<invalid/>", "foo",  "notMatchedHeaderValue");
+        assertEquals("invalidResult", result);
+        result = template.sendBodyAndHeader("direct:start", "<valid/>", "foo",   "bar");
+        assertEquals("validResult", result);
+        result = template.sendBodyAndHeader("direct:start", "<valid/>", "foo",   "bar");
+        assertEquals("validResult", result);
 
         MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
     }
@@ -65,6 +77,9 @@
 
         validEndpoint = resolveMandatoryEndpoint("mock:valid", MockEndpoint.class);
         invalidEndpoint = resolveMandatoryEndpoint("mock:invalid", MockEndpoint.class);
+        
+        validEndpoint.whenAnyExchangeReceived(ProcessorBuilder.setOutBody(Builder.constant("validResult")));
+        invalidEndpoint.whenAnyExchangeReceived(ProcessorBuilder.setOutBody(Builder.constant("invalidResult")));
     }
 
     protected RouteBuilder createRouteBuilder() {



Mime
View raw message