You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/10/23 10:19:52 UTC

svn commit: r828961 - /camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java

Author: davsclaus
Date: Fri Oct 23 08:19:52 2009
New Revision: 828961

URL: http://svn.apache.org/viewvc?rev=828961&view=rev
Log:
Added unit test based on user forum issue

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java   (with props)

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java?rev=828961&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java Fri Oct 23 08:19:52 2009
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.aggregator;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+
+/**
+ * Based on user forum issue
+ *
+ * @version $Revision$
+ */
+public class AggregateLostGroupIssueTest extends ContextTestSupport {
+
+    private int messageIndex = 0;
+
+    public void testAggregateLostGroupIssue() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(2);
+        mock.message(0).body().isEqualTo("0,1,2,3,4,5,6,7,8,9");
+        mock.message(1).body().isEqualTo("10,11,12,13,14,15,16,17,18,19");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("timer://foo?period=100")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                exchange.getOut().setBody(messageIndex++);
+                                exchange.getOut().setHeader("aggregateGroup", "group1");
+                            }
+                        }).to("direct:aggregator");
+
+                from("direct:aggregator").aggregate(header("aggregateGroup"), new AggregationStrategy() {
+                    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+                        if (oldExchange == null) {
+                            return newExchange;
+                        }
+
+                        String oldBody = oldExchange.getIn().getBody(String.class);
+                        String newBody = newExchange.getIn().getBody(String.class);
+
+                        oldExchange.getIn().setBody(oldBody + "," + newBody);
+                        return oldExchange;
+                    }
+                }).batchSize(10).batchTimeout(2000L)
+                        .to("log:aggregated")
+                        .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateLostGroupIssueTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date