camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1211558 - in /camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example: FilterRoute.scala FilterRouteTest.scala
Date Wed, 07 Dec 2011 17:38:34 GMT
Author: davsclaus
Date: Wed Dec  7 17:38:33 2011
New Revision: 1211558

URL: http://svn.apache.org/viewvc?rev=1211558&view=rev
Log:
Polished scala DSL example

Modified:
    camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRoute.scala
    camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRouteTest.scala

Modified: camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRoute.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRoute.scala?rev=1211558&r1=1211557&r2=1211558&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRoute.scala
(original)
+++ camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRoute.scala
Wed Dec  7 17:38:33 2011
@@ -16,16 +16,16 @@
  */
 package org.apache.camel.scala.example
 
-import org.apache.camel.scala.dsl.builder.{RouteBuilder, RouteBuilderSupport}
+import org.apache.camel.scala.dsl.builder.RouteBuilder
 
 /**
- * A Camel route which filters unwanted messages using Scala predicates.
+ * A Camel route, defined using the Scala DSL. The route filters unwanted messages using
Scala predicates.
  */
 // START SNIPPET: e1
-// the class should extend the RouteBuilderSupport from org.apache.camel.scala.dsl.builder
package
-class FilterRoute extends RouteBuilderSupport {
+class FilterRoute {
 
-  // then define any method which creates a new org.apache.camel.scala.dsl.builder.RouteBuilder
instance
+  // define any method which creates a new org.apache.camel.scala.dsl.builder.RouteBuilder
instance
+  // and within the scope of RouteBuilder we have the Scala DSL at our disposal
   def createMyFilterRoute = new RouteBuilder {
     // and here we can use the Scala DSL to define the routes
     from("direct:start")

Modified: camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRouteTest.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRouteTest.scala?rev=1211558&r1=1211557&r2=1211558&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRouteTest.scala
(original)
+++ camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/example/FilterRouteTest.scala
Wed Dec  7 17:38:33 2011
@@ -18,14 +18,17 @@ package org.apache.camel.scala.example
 
 import org.apache.camel.test.junit4.CamelTestSupport
 import org.junit.Test
+import org.apache.camel.scala.dsl.builder.RouteBuilderSupport
 
 // START SNIPPET: e1
-// we want to use the Camel test kit to test the FilterRouteExample which we can do by extending
+// we want to use the Camel test kit to test the FilterRoute which we can do by extending
 // the CamelTestSupport class from camel-test
-class FilterRouteTest extends CamelTestSupport {
+// to bridge the Scala DSL RouteBuilder with the Java DSL RouteBuilder, that the Camel test
kit
+// is using, we need to mixin the trait RouteBuilderSupport (using the with keyword)
+class FilterRouteTest extends CamelTestSupport with RouteBuilderSupport {
 
-  // then override this method to provide the RouteBuilder instance from camel-core
-  override def createRouteBuilder() = new FilterRoute().createMyFilterRoute.builder
+  // then override the createRouteBuilder method to provide the route we want to test
+  override def createRouteBuilder() = new FilterRoute().createMyFilterRoute
 
   // and here we just have regular JUnit test method which uses the API from camel-test
 



Mime
View raw message