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 2017/04/21 08:52:57 UTC

camel git commit: Added unit test based on user forum issue

Repository: camel
Updated Branches:
  refs/heads/master 0c55353b7 -> 9b3e7ebe5


Added unit 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/9b3e7ebe
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9b3e7ebe
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9b3e7ebe

Branch: refs/heads/master
Commit: 9b3e7ebe58ae3e569d3869c476642937c09d0a0c
Parents: 0c55353
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Apr 21 10:52:15 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Apr 21 10:52:50 2017 +0200

----------------------------------------------------------------------
 .../ThrottlerThreadPoolProfileTest.java         | 58 ++++++++++++++++++++
 .../SpringThrottlerThreadPoolProfileTest.java   | 30 ++++++++++
 .../ThrottlerThreadPoolProfileTest.xml          | 39 +++++++++++++
 3 files changed, 127 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9b3e7ebe/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java
new file mode 100644
index 0000000..7d5d5c5
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.ThreadPoolProfileBuilder;
+import org.apache.camel.spi.ThreadPoolProfile;
+
+public class ThrottlerThreadPoolProfileTest extends ContextTestSupport {
+
+    protected boolean canTest() {
+        // skip test on windows as it does not run well there
+        return !isPlatform("windows");
+    }
+
+    public void testThreadPool() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
+        getMockEndpoint("mock:result").expectedMessageCount(2);
+
+        template.sendBody("direct:start", "Hello");
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // create thread pool profile and register to camel
+                ThreadPoolProfile profile = new ThreadPoolProfileBuilder("myPool").poolSize(2).maxPoolSize(5).maxQueueSize(10).build();
+                context.getExecutorServiceManager().registerThreadPoolProfile(profile);
+
+                from("direct:start")
+                    .throttle(constant(2)).executorServiceRef("myPool")
+                        .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/9b3e7ebe/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlerThreadPoolProfileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlerThreadPoolProfileTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlerThreadPoolProfileTest.java
new file mode 100644
index 0000000..96ceeb8
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlerThreadPoolProfileTest.java
@@ -0,0 +1,30 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ThrottlerThreadPoolProfileTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringThrottlerThreadPoolProfileTest extends ThrottlerThreadPoolProfileTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this,
+                "org/apache/camel/spring/processor/ThrottlerThreadPoolProfileTest.xml");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/9b3e7ebe/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlerThreadPoolProfileTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlerThreadPoolProfileTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlerThreadPoolProfileTest.xml
new file mode 100644
index 0000000..0d8c9f5
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlerThreadPoolProfileTest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <threadPoolProfile id="myPool" poolSize="2" maxPoolSize="5" maxQueueSize="10"/>
+
+    <route>
+      <from uri="direct:start"/>
+      <throttle executorServiceRef="myPool">
+        <constant>2</constant>
+        <to uri="mock:result"/>
+      </throttle>
+    </route>
+
+  </camelContext>
+
+</beans>