camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r744054 - 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 Fri, 13 Feb 2009 10:08:36 GMT
Author: gertv
Date: Fri Feb 13 10:08:35 2009
New Revision: 744054

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

Added:
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SLoopType.scala
    camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/LoopTest.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/SAbstractType.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=744054&r1=744053&r2=744054&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
Fri Feb 13 10:08:35 2009
@@ -33,6 +33,7 @@
   def inOnly(): SProcessorType
   def inOut(): SProcessorType
   def loadbalance : SLoadBalanceType
+  def loop(expression: Exchange => Any) : SLoopType
   def marshal(format : DataFormatType) : DSL
   def multicast : SMulticastType
   def otherwise : DSL

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractType.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractType.scala?rev=744054&r1=744053&r2=744054&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractType.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractType.scala
Fri Feb 13 10:08:35 2009
@@ -82,6 +82,8 @@
   def inOnly = new SProcessorType(target.inOnly.asInstanceOf[RawProcessorType])
   def inOut = new SProcessorType(target.inOut.asInstanceOf[RawProcessorType])
  
+  def loop(expression: Exchange => Any) = new SLoopType(target.loop(expression))
+  
   def marshal(format: DataFormatType) = {
     target.marshal(format)
     this

Added: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SLoopType.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SLoopType.scala?rev=744054&view=auto
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SLoopType.scala
(added)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SLoopType.scala
Fri Feb 13 10:08:35 2009
@@ -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.scala.dsl;
+
+import org.apache.camel.model.LoopType
+import org.apache.camel.scala.dsl.builder.RouteBuilder
+
+/**
+ * Scala enrichment for Camel's LoopType
+ */
+class SLoopType(val target: LoopType)(implicit val builder: RouteBuilder) extends SAbstractType
with Wrapper[LoopType] {
+ 
+  val unwrap = target
+  
+}

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=744054&r1=744053&r2=744054&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
Fri Feb 13 10:08:35 2009
@@ -68,6 +68,7 @@
   def idempotentconsumer(expression: Exchange => Any) = stack.top.idempotentconsumer(expression)
   def inOnly = stack.top.inOnly
   def inOut = stack.top.inOut
+  def loop(expression: Exchange => Any) = stack.top.loop(expression)
   def splitter(expression: Exchange => Any) = stack.top.splitter(expression)
   def otherwise = stack.top.otherwise
   def marshal(format: DataFormatType) = stack.top.marshal(format)

Added: camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/LoopTest.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/LoopTest.scala?rev=744054&view=auto
==============================================================================
--- camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/LoopTest.scala
(added)
+++ camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/LoopTest.scala
Fri Feb 13 10:08:35 2009
@@ -0,0 +1,67 @@
+/**
+ * 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 scala.dsl.builder.RouteBuilder
+
+/**
+ * Test for looping from the Scala DSL
+ */
+class LoopTest extends ScalaTestSupport {
+
+  def testSimpleStaticLoop() = doTestLoopStatic("direct:a", "mock:a")
+  def testSimpleDynamicLoop() = doTestLoopDynamic("direct:b", "mock:b")
+  def testBlockStaticLoop() = doTestLoopStatic("direct:c", "mock:c")
+  def testBlockDynamicLoop() = doTestLoopDynamic("direct:d", "mock:d")
+  
+  def doTestLoopStatic(from: String, mock: String) = {
+    mock expect {_.count = 5}
+    test {
+      from ! ("ping")
+    }    
+  }
+  
+  def doTestLoopDynamic(from: String, mock: String) = {
+    mock expect {_.count = 5}
+    test {
+      from ! ("5")
+    }    
+  }
+  
+    
+  val builder = new RouteBuilder {
+     //START SNIPPET: simple
+     "direct:a" loop(5) to "mock:a"
+     "direct:b" loop(_.in) to "mock:b"
+     //END SNIPPET: simple
+     
+     //START SNIPPET: block
+     "direct:c" ==> {
+       loop(5) {
+         to("mock:c")
+       }
+     }
+     "direct:d" ==> {
+       loop(_.in) {
+         to("mock:d")
+       }
+     }
+     //START SNIPPET: block
+   }
+}
+
+



Mime
View raw message