CAMEL-7644: camel-scala, must use ScalaRouteBuilder to ensure a CamelContext is provided when creating routes. The old class is deprecated.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/01f08a62 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/01f08a62 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/01f08a62 Branch: refs/heads/master Commit: 01f08a6267232089adba90a380050ba5dc9c43d2 Parents: c469ad7 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Mar 3 10:10:37 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Mar 3 10:10:37 2015 +0100 ---------------------------------------------------------------------- .../camel/scala/dsl/ScalaRouteBuilderTest.scala | 49 ++++++++++++++++++++ .../camel/scala/dsl/ScalaTestSupport.scala | 5 +- 2 files changed, 53 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/01f08a62/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaRouteBuilderTest.scala ---------------------------------------------------------------------- diff --git a/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaRouteBuilderTest.scala b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaRouteBuilderTest.scala new file mode 100644 index 0000000..5afb77b --- /dev/null +++ b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaRouteBuilderTest.scala @@ -0,0 +1,49 @@ +/** + * 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 java.util.Properties + +import org.apache.camel.scala.dsl.builder.{ScalaRouteBuilder, RouteBuilder} +import org.junit.Test + +class ScalaRouteBuilderTest extends ScalaTestSupport { + + override def useOverridePropertiesWithPropertiesComponent(): Properties = { + val prop = new Properties() + prop.put("foo", "direct:foo") + prop.put("bar", "mock:bar") + prop + } + + @Test + def testScalaRouteBuilder() { + getMockEndpoint("mock:bar").expectedMessageCount(1) + + template().sendBody("{{foo}}", "Hello World") + + assertMockEndpointsSatisfied() + } + + // must use lazy as we want to evaluate this after CamelContext has been created + override lazy val builder: RouteBuilder = { + new ScalaRouteBuilder(context()) { + from("{{foo}}").to("{{bar}}") + } + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/01f08a62/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaTestSupport.scala ---------------------------------------------------------------------- diff --git a/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaTestSupport.scala b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaTestSupport.scala index e749f28..514f864 100644 --- a/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaTestSupport.scala +++ b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ScalaTestSupport.scala @@ -44,7 +44,10 @@ abstract class ScalaTestSupport extends CamelTestSupport with RouteBuilderSuppor def in(message: Any) : Exchange = createExchangeWithBody(message) val builder : RouteBuilder - + + /** + * Creates the route builder, make sure to use lazy modifier, and create a ScalaRouteBuilder instance + */ override protected def createRouteBuilder = builder override def setUp() {