camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hekon...@apache.org
Subject git commit: Added extra delayer test - using Bean binding in delay calculation.
Date Mon, 27 Jan 2014 16:10:56 GMT
Updated Branches:
  refs/heads/master 0c12c4531 -> 3bed3b3b9


Added extra delayer test - using Bean binding in delay calculation.


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

Branch: refs/heads/master
Commit: 3bed3b3b9ee11ae900d08f21a60b5125a09c1803
Parents: 0c12c45
Author: Henryk Konsek <hekonsek@gmail.com>
Authored: Mon Jan 27 17:10:37 2014 +0100
Committer: Henryk Konsek <hekonsek@gmail.com>
Committed: Mon Jan 27 17:10:37 2014 +0100

----------------------------------------------------------------------
 .../org/apache/camel/processor/DelayerTest.java | 15 ++++++++++
 .../processor/ExchangeAwareDelayCalcBean.java   | 29 ++++++++++++++++++++
 2 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3bed3b3b/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java b/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java
index a4f1d14..b846001 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java
@@ -20,6 +20,8 @@ import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
+import static org.apache.camel.processor.ExchangeAwareDelayCalcBean.BEAN_DELAYER_HEADER;
+
 /**
  * @version 
  */
@@ -27,6 +29,8 @@ public class DelayerTest extends ContextTestSupport {
 
     private MyDelayCalcBean bean = new MyDelayCalcBean();
 
+    private ExchangeAwareDelayCalcBean exchangeAwareBean = new ExchangeAwareDelayCalcBean();
+
     public void testSendingMessageGetsDelayed() throws Exception {
         MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
 
@@ -61,6 +65,15 @@ public class DelayerTest extends ContextTestSupport {
         resultEndpoint.assertIsSatisfied();
     }
 
+    public void testExchangeAwareDelayBean() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectedMessageCount(1);
+        // should at least take 1 sec to complete
+        resultEndpoint.setMinimumResultWaitTime(900);
+        template.sendBodyAndHeader("seda:d", "<hello>world!</hello>", BEAN_DELAYER_HEADER,
1000);
+        resultEndpoint.assertIsSatisfied();
+    }
+
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
@@ -75,6 +88,8 @@ public class DelayerTest extends ContextTestSupport {
                 // START SNIPPET: ex3
                 from("seda:c").delay().method(bean, "delayMe").to("mock:result");
                 // END SNIPPET: ex3
+
+                from("seda:d").delay().method(exchangeAwareBean, "delayMe").to("mock:result");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/3bed3b3b/camel-core/src/test/java/org/apache/camel/processor/ExchangeAwareDelayCalcBean.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ExchangeAwareDelayCalcBean.java
b/camel-core/src/test/java/org/apache/camel/processor/ExchangeAwareDelayCalcBean.java
new file mode 100644
index 0000000..59fd498
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/ExchangeAwareDelayCalcBean.java
@@ -0,0 +1,29 @@
+/**
+ * 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.Exchange;
+
+public class ExchangeAwareDelayCalcBean {
+
+    static final String BEAN_DELAYER_HEADER = "BEAN_DELAYER_HEADER";
+
+    public long delayMe(Exchange exchange) {
+        return exchange.getIn().getHeader("BEAN_DELAYER_HEADER", Long.class);
+    }
+
+}
\ No newline at end of file


Mime
View raw message