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 2016/04/14 15:02:52 UTC
camel git commit: Add test based on user forum issue
Repository: camel
Updated Branches:
refs/heads/master 3c3341297 -> 244868166
Add test based on user forum issue
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/24486816
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/24486816
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/24486816
Branch: refs/heads/master
Commit: 244868166b2df472a7bfe34e8bfaea6e453e6217
Parents: 3c33412
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Apr 14 15:02:42 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Apr 14 15:02:42 2016 +0200
----------------------------------------------------------------------
...TwoSchedulerConcurrentTasksOneRouteTest.java | 67 ++++++++++++++++++++
.../TwoSchedulerConcurrentTasksTest.java | 2 +
2 files changed, 69 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/24486816/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksOneRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksOneRouteTest.java b/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksOneRouteTest.java
new file mode 100644
index 0000000..09251cb
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksOneRouteTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.scheduler;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version
+ */
+public class TwoSchedulerConcurrentTasksOneRouteTest extends ContextTestSupport {
+
+ private AtomicBoolean sleep = new AtomicBoolean(true);
+
+ public void testTwoScheduler() throws Exception {
+ getMockEndpoint("mock:done").expectedMinimumMessageCount(10);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // number of concurrent task a thread pool should have
+ SchedulerComponent comp = context.getComponent("scheduler", SchedulerComponent.class);
+ comp.setConcurrentTasks(2);
+
+ // let this route scheduler use all 2 concurrent tasks at the same time
+ from("scheduler://foo?delay=250&scheduler.concurrentTasks=2")
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ if (sleep.compareAndSet(true, false)) {
+ log.info("Thread is sleeping");
+ Thread.sleep(1000);
+ log.info("Thread is done sleeping");
+ }
+ }
+ })
+ .to("log:done")
+ .to("mock:done");
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/24486816/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksTest.java b/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksTest.java
index 30895fd..4512f36 100644
--- a/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/scheduler/TwoSchedulerConcurrentTasksTest.java
@@ -39,9 +39,11 @@ public class TwoSchedulerConcurrentTasksTest extends ContextTestSupport {
comp.setConcurrentTasks(2);
from("scheduler://foo?delay=100")
+ .to("log:a")
.to("mock:a");
from("scheduler://foo?delay=200")
+ .to("log:b")
.to("mock:b");
}
};