camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r755002 - in /camel/trunk/components/camel-scala/src: main/scala/org/apache/camel/scala/dsl/ main/scala/org/apache/camel/scala/dsl/builder/ test/scala/org/apache/camel/scala/dsl/
Date Mon, 16 Mar 2009 20:56:42 GMT
Author: gertv
Date: Mon Mar 16 20:56:42 2009
New Revision: 755002

URL: http://svn.apache.org/viewvc?rev=755002&view=rev
Log:
CAMEL-463: Adding wiretap to the Scala DSL

Added:
    camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/WiretapTest.scala
Modified:
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala?rev=755002&r1=755001&r2=755002&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/DSL.scala
Mon Mar 16 20:56:42 2009
@@ -48,6 +48,7 @@
   def to(uris: String*) : DSL
   def unmarshal(format: DataFormatDefinition) : DSL
   def when(filter: Exchange => Boolean) : SChoiceDefinition
+  def wiretap(uris: String) : DSL
   def -->(uris: String*) : DSL
 
 }

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala?rev=755002&r1=755001&r2=755002&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
Mon Mar 16 20:56:42 2009
@@ -115,6 +115,8 @@
     this
   }
   
+  def wiretap(uri: String) = new SProcessorDefinition(target.wireTap(uri).asInstanceOf[RawProcessorDefinition])
+  
   def aggregate(expression: Exchange => Any) = new SAggregateDefinition(target.aggregate(expression))
 
 }

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala?rev=755002&r1=755001&r2=755002&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
Mon Mar 16 20:56:42 2009
@@ -84,6 +84,7 @@
   def setheader(name: String, expression: Exchange => Any) = stack.top.setheader(name,
expression)
   def thread(count: Int) = stack.top.thread(count)
   def unmarshal(format: DataFormatDefinition) = stack.top.unmarshal(format)
+  def wiretap(uri: String) = stack.top.wiretap(uri)
   def aggregate(expression: Exchange => Any) = stack.top.aggregate(expression)
 
   // implementing the Routes interface to allow RouteBuilder to be discovered by Spring

Added: camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/WiretapTest.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/WiretapTest.scala?rev=755002&view=auto
==============================================================================
--- camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/WiretapTest.scala
(added)
+++ camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/WiretapTest.scala
Mon Mar 16 20:56:42 2009
@@ -0,0 +1,59 @@
+/**
+ * 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.test.Adult
+import org.w3c.dom.Document
+import scala.dsl.builder.RouteBuilder
+
+/**
+ * Test case for wiretap
+ */
+class WiretapTest extends ScalaTestSupport {
+  
+  def testSimpleTap = doTestWiretap("direct:a", "mock:a")
+  def testBlockTap = doTestWiretap("direct:b", "mock:b")
+  
+  def doTestWiretap(from: String, to: String) = {
+    to expect { _.received("Calling Elvis", "Calling Paul")}
+    "mock:tap" expect { _.received("Elvis is alive!", "Stop singing, you're not Elvis")}
+    test {
+      from ! (Adult("Elvis"), Adult("Paul"))
+    }
+  }
+  
+  val builder =
+    new RouteBuilder {
+       //START SNIPPET: simple
+       "direct:a" wiretap("direct:tap") setbody("Calling " + _.in(classOf[Adult]).name) to
("mock:a")
+       //END SNIPPET: simple
+       
+       //START SNIPPET: block
+       "direct:b" ==> {
+         wiretap("direct:tap")
+         setbody("Calling " + _.in(classOf[Adult]).name)
+         to ("mock:b")
+       }
+       //END SNIPPET: block
+       
+       "direct:tap" setbody(_.in match {
+          case Adult("Elvis") => "Elvis is alive!"
+          case Adult(_) => "Stop singing, you're not Elvis"
+        }) to "mock:tap"
+    }
+
+}



Mime
View raw message