CAMEL-8966: Add toD to scala-dsl
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bfd3ff0f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bfd3ff0f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bfd3ff0f Branch: refs/heads/master Commit: bfd3ff0f8b12dfedbe8ab2572c983730bbc31bc1 Parents: 90f7fec Author: Claus Ibsen <davscl...@apache.org> Authored: Mon Jul 20 13:07:21 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Jul 20 13:07:21 2015 +0200 ---------------------------------------------------------------------- .../scala/org/apache/camel/scala/dsl/DSL.scala | 2 + .../camel/scala/dsl/SAbstractDefinition.scala | 2 + .../camel/scala/dsl/builder/RouteBuilder.scala | 2 + .../apache/camel/scala/dsl/ToDynamicTest.scala | 47 ++++++++++++++++++++ 4 files changed, 53 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/bfd3ff0f/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala ---------------------------------------------------------------------- diff --git a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala index cfce461..2e48581 100644 --- a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala +++ b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala @@ -105,6 +105,8 @@ trait DSL { def throwException(exception: Exception) : DSL def throwException(exceptionType: Class[_ <: Exception], message: String) : DSL def to(uris: String*) : DSL + def toD(uri: String) : DSL + def toD(uri: String, ignoreInvalidEndpoint: Boolean) : DSL def transacted : DSL def transacted(ref: String) : DSL def transform(expression: Exchange => Any) : DSL http://git-wip-us.apache.org/repos/asf/camel/blob/bfd3ff0f/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala ---------------------------------------------------------------------- diff --git a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala index 23914dd..7530227 100644 --- a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala +++ b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala @@ -174,5 +174,7 @@ abstract class SAbstractDefinition[P <: ProcessorDefinition[_]] extends DSL with } this } + def toD(uri: String) = wrap(target.toD(uri)) + def toD(uri: String, ignoreInvalidEndpoint: Boolean) = wrap(target.toD(uri, ignoreInvalidEndpoint)) } http://git-wip-us.apache.org/repos/asf/camel/blob/bfd3ff0f/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala ---------------------------------------------------------------------- diff --git a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala index 9faf2a4..cbaa426 100644 --- a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala +++ b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala @@ -212,6 +212,8 @@ class RouteBuilder extends Preamble with DSL with RoutesBuilder with Languages w def wireTap(uri: String, expression: Exchange => Any) = stack.top.wireTap(uri, expression) def to(uris: String*) = stack.top.to(uris: _*) + def toD(uri: String) = stack.top.toD(uri) + def toD(uri: String, ignoreInvalidEndpoint: Boolean) = stack.top.toD(uri, ignoreInvalidEndpoint) def -->(uris: String*) = stack.top.to(uris: _*) } http://git-wip-us.apache.org/repos/asf/camel/blob/bfd3ff0f/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ToDynamicTest.scala ---------------------------------------------------------------------- diff --git a/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ToDynamicTest.scala b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ToDynamicTest.scala new file mode 100644 index 0000000..ec3e8ba --- /dev/null +++ b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ToDynamicTest.scala @@ -0,0 +1,47 @@ +/** + * 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.scala.dsl + +import org.apache.camel.scala.dsl.builder.RouteBuilder +import org.junit.Test + +/** + * Test case for dynamic to + */ +class ToDynamicTest extends ScalaTestSupport { + + @Test + def testToD() { + val mock = getMockEndpoint("mock:b") + mock.expectedMessageCount(1) + + // send a string + template.sendBodyAndHeader("direct:b", "74", "foo", "b") + + assertMockEndpointsSatisfied() + } + + val builder = + //START SNIPPET: e1 + new RouteBuilder { + "direct:b" ==> { + toD("mock:${header.foo}") + } + } + //END SNIPPET: e1 + +}