You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ro...@apache.org on 2009/08/06 11:49:01 UTC
svn commit: r801583 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/processor/BatchProcessor.java
test/java/org/apache/camel/processor/aggregator/AggregatorExceptionInPredicateTest.java
Author: romkal
Date: Thu Aug 6 09:49:01 2009
New Revision: 801583
URL: http://svn.apache.org/viewvc?rev=801583&view=rev
Log:
CAMEL-1882: Another test added that verifies exception thrown from correlation expression
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionInPredicateTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java?rev=801583&r1=801582&r2=801583&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java Thu Aug 6 09:49:01 2009
@@ -318,6 +318,8 @@
if (e != null) {
try {
collection.add(e);
+ } catch (Exception t) {
+ e.setException(t);
} catch (Throwable t) {
getExceptionHandler().handleException(t);
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionInPredicateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionInPredicateTest.java?rev=801583&r1=801582&r2=801583&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionInPredicateTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorExceptionInPredicateTest.java Thu Aug 6 09:49:01 2009
@@ -18,6 +18,8 @@
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.builder.ExpressionBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.aggregate.AggregationStrategy;
@@ -29,6 +31,14 @@
public class AggregatorExceptionInPredicateTest extends ContextTestSupport {
public void testExceptionInAggregationStrategy() throws Exception {
+ testExceptionInFlow("direct:start");
+ }
+
+ public void testExceptionInPredicate() throws Exception {
+ testExceptionInFlow("direct:predicate");
+ }
+
+ private void testExceptionInFlow(String startUri) throws Exception {
// failed first aggregation
// TODO Following assertion should be true while it is not. Instead
@@ -40,8 +50,8 @@
// second aggregated
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
- template.sendBodyAndHeader("direct:start", "Damn", "id", 1);
- template.sendBodyAndHeader("direct:start", "Hello World", "id", 1);
+ template.sendBodyAndHeader(startUri, "Damn", "id", 1);
+ template.sendBodyAndHeader(startUri, "Hello World", "id", 1);
assertMockEndpointsSatisfied();
}
@@ -68,6 +78,18 @@
})
.to("mock:result");
+ from("direct:predicate")
+ .aggregate(new Expression() {
+
+ public <T> T evaluate(Exchange exchange, Class<T> type) {
+ if (exchange.getIn().getBody().equals("Damn")) {
+ throw new IllegalArgumentException();
+ }
+ return ExpressionBuilder.headerExpression("id").evaluate(exchange, type);
+ }
+ })
+ .batchTimeout(500)
+ .to("mock:result");
}
};
}