camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/8] git commit: CAMEL-6510: Added unit test
Date Wed, 17 Jul 2013 11:39:41 GMT
Updated Branches:
  refs/heads/camel-2.10.x c48f06780 -> e9f2a1f86
  refs/heads/camel-2.11.x c66e94c3e -> 8bae7e645
  refs/heads/master c095e270f -> 3f1f901a0


CAMEL-6510: Added unit test


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6fbf115f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6fbf115f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6fbf115f

Branch: refs/heads/master
Commit: 6fbf115fadebf966c8b24894afa3e8fddae61892
Parents: c095e27
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jul 17 11:52:53 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jul 17 11:52:53 2013 +0200

----------------------------------------------------------------------
 .../AggregateStrategyServiceTest.java           | 46 +++++++++++++++++
 .../MyAggregationStrategyService.java           | 52 ++++++++++++++++++++
 2 files changed, 98 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6fbf115f/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateStrategyServiceTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateStrategyServiceTest.java
b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateStrategyServiceTest.java
new file mode 100644
index 0000000..06771f2
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateStrategyServiceTest.java
@@ -0,0 +1,46 @@
+/**
+ * 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.builder.RouteBuilder;
+
+public class AggregateStrategyServiceTest extends ContextTestSupport {
+
+    public void testAggregate() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("StartedStartedABC");
+
+        template.sendBody("direct:start", "A");
+        template.sendBody("direct:start", "B");
+        template.sendBody("direct:start", "C");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .aggregate(constant(true), new MyAggregationStrategyService())
+                        .completionSize(3)
+                        .to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/6fbf115f/camel-core/src/test/java/org/apache/camel/processor/aggregator/MyAggregationStrategyService.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/aggregator/MyAggregationStrategyService.java
b/camel-core/src/test/java/org/apache/camel/processor/aggregator/MyAggregationStrategyService.java
new file mode 100644
index 0000000..e1ad7cc
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/aggregator/MyAggregationStrategyService.java
@@ -0,0 +1,52 @@
+/**
+ * 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.Exchange;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.apache.camel.support.ServiceSupport;
+
+public class MyAggregationStrategyService extends ServiceSupport implements AggregationStrategy
{
+
+    private boolean started;
+
+    @Override
+    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+        if (oldExchange == null) {
+            return newExchange;
+        }
+
+        String body = oldExchange.getIn().getBody(String.class);
+        String newBody = newExchange.getIn().getBody(String.class);
+        body = body + newBody;
+        if (started) {
+            body = "Started" + body;
+        }
+        newExchange.getIn().setBody(body);
+        return newExchange;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        started = true;
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        started = false;
+    }
+}


Mime
View raw message