Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A5BA510B76 for ; Mon, 27 Jan 2014 16:11:03 +0000 (UTC) Received: (qmail 31438 invoked by uid 500); 27 Jan 2014 16:11:02 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 31344 invoked by uid 500); 27 Jan 2014 16:10:58 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 31332 invoked by uid 99); 27 Jan 2014 16:10:57 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Jan 2014 16:10:57 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AD243906985; Mon, 27 Jan 2014 16:10:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hekonsek@apache.org To: commits@camel.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: Added extra delayer test - using Bean binding in delay calculation. Date: Mon, 27 Jan 2014 16:10:56 +0000 (UTC) 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 Authored: Mon Jan 27 17:10:37 2014 +0100 Committer: Henryk Konsek 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", "world!", 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