camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-9697: Test component - Allow to receive in any order, or split using expression
Date Thu, 10 Mar 2016 16:53:48 GMT
CAMEL-9697: Test component - Allow to receive in any order, or split using expression


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

Branch: refs/heads/master
Commit: 6d8a73516e23db2d9f81562e4e3213b24698a175
Parents: 18fc064
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Mar 10 17:33:57 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Mar 10 17:53:38 2016 +0100

----------------------------------------------------------------------
 .../camel/component/test/TestEndpoint.java      | 25 ++++++++--
 .../camel/component/test/TestAnyOrderTest.java  | 48 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6d8a7351/camel-core/src/main/java/org/apache/camel/component/test/TestEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/test/TestEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/test/TestEndpoint.java
index 6882967..51f68a0 100644
--- a/camel-core/src/main/java/org/apache/camel/component/test/TestEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/test/TestEndpoint.java
@@ -45,10 +45,14 @@ import org.slf4j.LoggerFactory;
 @UriEndpoint(scheme = "test", title = "Test", syntax = "test:name", producerOnly = true,
label = "core,testing", lenientProperties = true)
 public class TestEndpoint extends MockEndpoint {
     private static final Logger LOG = LoggerFactory.getLogger(TestEndpoint.class);
+
     private Endpoint expectedMessageEndpoint;
+
     @UriPath(description = "Name of endpoint to lookup in the registry to use for polling
messages used for testing") @Metadata(required = "true")
     private String name;
-    @UriParam(label = "producer", defaultValue = "2000")
+    @UriPath
+    private boolean anyOrder;
+    @UriParam(defaultValue = "2000")
     private long timeout = 2000L;
 
     public TestEndpoint(String endpointUri, Component component) {
@@ -76,8 +80,12 @@ public class TestEndpoint extends MockEndpoint {
             }
         }, timeout);
 
-        LOG.debug("Received: {} expected message(s) from: {}", expectedBodies.size(), expectedMessageEndpoint);
-        expectedBodiesReceived(expectedBodies);
+        LOG.info("Received: {} expected message(s) from: {}", expectedBodies.size(), expectedMessageEndpoint);
+        if (anyOrder) {
+            expectedBodiesReceivedInAnyOrder(expectedBodies);
+        } else {
+            expectedBodiesReceived(expectedBodies);
+        }
     }
 
     /**
@@ -97,4 +105,15 @@ public class TestEndpoint extends MockEndpoint {
     public void setTimeout(long timeout) {
         this.timeout = timeout;
     }
+
+    public boolean isAnyOrder() {
+        return anyOrder;
+    }
+
+    /**
+     * Whether the expected messages should arrive in the same order or can be in any order.
+     */
+    public void setAnyOrder(boolean anyOrder) {
+        this.anyOrder = anyOrder;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/6d8a7351/camel-core/src/test/java/org/apache/camel/component/test/TestAnyOrderTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/test/TestAnyOrderTest.java
b/camel-core/src/test/java/org/apache/camel/component/test/TestAnyOrderTest.java
new file mode 100644
index 0000000..9555053
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/test/TestAnyOrderTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.component.test;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class TestAnyOrderTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    public void testAnyOrder() throws Exception {
+        template.sendBody("seda:testme", "Bye World");
+        template.sendBody("seda:testme", "Hello World");
+
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                        .to("test:seda:testme?anyOrder=true");
+            }
+        });
+        context.start();
+
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Bye World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}


Mime
View raw message