camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r644754 - in /activemq/camel/trunk/components: ./ camel-scala/ camel-scala/src/ camel-scala/src/main/ camel-scala/src/main/scala/ camel-scala/src/main/scala/org/ camel-scala/src/main/scala/org/apache/ camel-scala/src/main/scala/org/apache/c...
Date Fri, 04 Apr 2008 16:17:13 GMT
Author: jstrachan
Date: Fri Apr  4 09:17:00 2008
New Revision: 644754

URL: http://svn.apache.org/viewvc?rev=644754&view=rev
Log:
applied patch https://issues.apache.org/activemq/browse/CAMEL-419 with huge thanks - this
is awesome! :)

Added:
    activemq/camel/trunk/components/camel-scala/
    activemq/camel/trunk/components/camel-scala/pom.xml   (with props)
    activemq/camel/trunk/components/camel-scala/src/
    activemq/camel/trunk/components/camel-scala/src/main/
    activemq/camel/trunk/components/camel-scala/src/main/scala/
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichExchange.scala
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala
    activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/WhenPredicate.scala
    activemq/camel/trunk/components/camel-scala/src/test/
    activemq/camel/trunk/components/camel-scala/src/test/scala/
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichMockEndpoint.scala
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichTestUri.scala
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala
    activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala
Modified:
    activemq/camel/trunk/components/pom.xml

Added: activemq/camel/trunk/components/camel-scala/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/pom.xml?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/pom.xml (added)
+++ activemq/camel/trunk/components/camel-scala/pom.xml Fri Apr  4 09:17:00 2008
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>1.3-SNAPSHOT</version>
+  </parent>
+  <artifactId>camel-scala</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: Scala</name>
+  <description>Camel Scala DSL</description>
+
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.scala.*</camel.osgi.export.pkg>
+  </properties>
+
+  <repositories>
+    <repository>
+      <id>scala-tools.org</id>
+      <name>Scala-tools Maven2 Repository</name>
+      <url>http://scala-tools.org/repo-releases</url>
+    </repository>
+  </repositories>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>scala-tools.org</id>
+      <name>Scala-tools Maven2 Repository</name>
+      <url>http://scala-tools.org/repo-releases</url>
+    </pluginRepository>
+  </pluginRepositories>
+
+  <build>
+    <sourceDirectory>src/main/scala</sourceDirectory>
+    <testSourceDirectory>src/test/scala</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.scala-tools</groupId>
+        <artifactId>maven-scala-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compile</goal>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <scalaVersion>2.7.0</scalaVersion>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <configuration>
+          <projectnatures>
+            <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
+            <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+          </projectnatures>
+          <buildcommands>
+            <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
+          </buildcommands>
+          <classpathContainers>
+            <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
+            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+          </classpathContainers>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-library</artifactId>
+      <version>2.7.0</version>
+    </dependency>
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>1.4.3</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: activemq/camel/trunk/components/camel-scala/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichChoice.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,29 @@
+package org.apache.camel.scala.dsl;
+
+import org.apache.camel.model.ChoiceType
+
+class RichChoiceType(val choice: ChoiceType, val builder:RouteBuilder) {
+  
+  def then(block: => Unit) : ChoiceType = {
+    builder.build(choice, block)
+    choice
+  }
+  
+  def when(test: Exchange => Boolean)(block: => Unit) : ChoiceType = {
+    choice
+  }
+  
+  def apply(block: => Unit) : RichChoiceType = {
+    builder.build(choice, block)
+    this
+  }
+  
+  def to(uri: String) = {
+    choice.to(uri)
+  }
+
+  def otherwise(block: => Unit) = {
+    choice.otherwise
+    builder.build(choice, block)
+  }
+}

Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichExchange.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichExchange.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichExchange.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichExchange.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,19 @@
+package org.apache.camel.scala.dsl
+
+import org.apache.camel.Exchange
+
+class RichExchange(val exchange : Exchange) {
+  
+  def in : Any = exchange.getIn().getBody()
+
+  def in(header:String) : Any = exchange.getIn().getHeader(header)
+  
+  def in(target:Class[Any]) : Any = exchange.getIn().getBody(target)  
+  
+  def out : Any = exchange.getOut().getBody()
+  
+  def out(header:String) : Any = exchange.getOut().getHeader(header) 
+  
+  def out_=(message:Any) = exchange.getOut().setBody(message)
+  
+}

Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichProcessor.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,9 @@
+package org.apache.camel.scala.dsl;
+
+import org.apache.camel.model.ProcessorType
+
+class RichProcessor(processor : ProcessorType[T] forSome {type T}) {
+   
+  def -->(uri: String) = processor.to(uri)
+  
+}

Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RichUriString.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,30 @@
+package org.apache.camel.scala.dsl;
+
+import org.apache.camel.model.FilterType
+import org.apache.camel.model.ProcessorType
+
+class RichUriString(uri:String, builder:RouteBuilder) {
+  
+  def to(targets: String*) : ProcessorType[T] forSome {type T} = {
+    targets.length match {
+      case 1 => builder.from(uri).to(targets(0))
+      case _ => {
+        val from = builder.from(uri)
+        val multicast = from.multicast
+        for (target <- targets) multicast.to(target)
+        from
+      }
+    }
+  }
+  def -->(targets: String*) : ProcessorType[T] forSome {type T} = to(targets:_*)
+  
+  def ==>(block: => Unit) = {
+    builder.build(builder.from(uri), block)
+  }
+  
+  def when(filter: Exchange => Boolean) : FilterType = 
+    builder.from(uri).filter(new WhenPredicate(filter))
+  
+  
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilder.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,68 @@
+package org.apache.camel.scala.dsl;
+
+import org.apache.camel.model.ProcessorType
+import org.apache.camel.model.ChoiceType
+
+import collection.mutable.Stack
+
+/**
+  Scala RouteBuilder implementation
+  */
+class RouteBuilder {
+  
+  val builder = new org.apache.camel.builder.RouteBuilder {
+    override def configure() =  {}
+  }
+  
+  val stack = new Stack[ProcessorType[T] forSome {type T}]; 
+  
+  implicit def stringToUri(uri:String) : RichUriString = new RichUriString(uri, this)
+  implicit def choiceWrapper(choice: ChoiceType) = new RichChoiceType(choice, this); 
+  implicit def processorWrapper(processor: ProcessorType[T] forSome {type T}) = new RichProcessor(processor)
+  implicit def exchangeWrapper(exchange: Exchange) = new RichExchange(exchange)
+  
+  def print() = {
+    println(builder)
+    this
+  }
+  
+  def build(context: ProcessorType[T] forSome {type T}, block: => Unit) {
+    stack.push(context)
+    block
+    stack.pop()
+  }
+  
+  def from(uri: String) = builder.from(uri)
+  
+  def -->(uris: String*) = to(uris:_*)  
+  def to(uris: String*) = {
+    uris.length match {
+      case 1 => stack.top.to(uris(0))
+      case _ => {
+        val multicast = stack.top.multicast
+        for (uri <- uris) multicast.to(uri)
+        stack.top
+      }        
+    }
+  }
+
+  var when = (filter: Exchange => Boolean) => { 
+    val choice = stack.top match {
+      case c: ChoiceType => c
+      case _  => stack.top.choice()
+    }
+    new RichChoiceType(choice.when(new WhenPredicate(filter)),  this) : RichChoiceType
+  }
+  
+  def choice(block: => Unit) = {
+    build(stack.top.choice(), block)
+  }
+  
+  def otherwise : ChoiceType = {
+    stack.top match {
+      case choice: ChoiceType => choice.otherwise
+      case _ => throw new Exception("otherwise is only supported in a choice block or
after a when statement")
+    }
+  }
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/RouteBuilderSupport.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,7 @@
+package org.apache.camel.scala.dsl;
+
+trait RouteBuilderSupport {
+
+  implicit def scalaToJavaBuilder(scalaBuilder: org.apache.camel.scala.dsl.RouteBuilder)
= scalaBuilder.builder
+  
+}

Added: activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/WhenPredicate.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/WhenPredicate.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/WhenPredicate.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/WhenPredicate.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,15 @@
+package org.apache.camel.scala.dsl;
+
+import org.apache.camel.Predicate
+
+class WhenPredicate(function: Exchange => Boolean) extends Predicate[Exchange]{
+  
+  override def matches(exchange: Exchange) = {
+    function(exchange)
+  }
+  
+  override def assertMatches(text: String, exchange: Exchange) = {
+    if (!matches(exchange)) throw new AssertionError(text + " : " + exchange + " doesn't
match Scala function")
+  }
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichMockEndpoint.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichMockEndpoint.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichMockEndpoint.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichMockEndpoint.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,14 @@
+package org.apache.camel.scala;
+
+import org.apache.camel.component.mock.MockEndpoint
+
+class RichMockEndpoint(endpoint: MockEndpoint) {
+  
+  def received(messages: AnyRef*) {
+    val list = new java.util.ArrayList[AnyRef](messages.length)
+    messages.foreach(list.add(_))
+    endpoint.expectedBodiesReceived(list)
+  }
+
+}
+ 

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichTestUri.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichTestUri.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichTestUri.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/RichTestUri.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,20 @@
+package org.apache.camel.scala;
+
+import org.apache.camel.component.mock.MockEndpoint
+
+class RichTestUri(uri: String, support: ScalaTestSupport) {
+  
+  def !(messages: Any*) = {
+    for (message <- messages) {
+      support.getTemplate().sendBody(uri, message)
+    }
+  }
+  
+  def expect(block: MockEndpoint => Unit) = {
+    val mock = support.mock(uri)
+    block(mock) 
+  }
+  
+  def assert() = support.mock(uri).assertIsSatisfied()
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/ScalaTestSupport.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,25 @@
+package org.apache.camel.scala;
+
+import org.apache.camel.ContextTestSupport
+import org.apache.camel.component.mock.MockEndpoint
+import org.apache.camel.scala.dsl._
+
+abstract class ScalaTestSupport extends ContextTestSupport with RouteBuilderSupport {
+
+  implicit def stringToUri(uri:String) = new RichTestUri(uri, this)
+  implicit def mockWrapper(endpoint: MockEndpoint) = new RichMockEndpoint(endpoint)
+  implicit def exchangeWrapper(exchange: Exchange[T] forSome {type T}) = new RichExchange(exchange)
+  
+  def assert(uri: String) = getMockEndpoint(uri).assertIsSatisfied
+  
+  protected[scala] def getTemplate() = template
+  
+  protected[scala] def mock(uri: String) = getMockEndpoint(uri)
+  
+  def in(message: Any) : Exchange = {
+    val exchange = createExchangeWithBody(message)
+    println(exchange)
+    exchange
+  }
+  
+}

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,24 @@
+package org.apache.camel.scala.dsl;
+
+import org.apache.camel.scala.ScalaTestSupport
+
+class BasicRouteBuilderTest extends ScalaTestSupport {
+  
+  def testBasicRouteArrowSyntax() = assertBasicRoute("direct:a", "mock:a")
+  def testBasicRouteTextSyntax() = assertBasicRoute("direct:b", "mock:b")
+    
+  def assertBasicRoute(from: String, to: String) = {
+    to expect {
+      _.expectedMessageCount(1)
+    }
+    from ! "<hello/>" 
+    to assert
+  }
+    
+  override protected def createRouteBuilder() = 
+    new RouteBuilder {
+       "direct:a" --> "mock:a"
+       "direct:b" to "mock:b"
+    }.print
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,29 @@
+package org.apache.camel.scala.dsl;
+
+class ContentBasedRouterTest extends ScalaTestSupport {
+  
+  def testSimpleContentBasedRouter = {
+    "mock:a" expect {_.expectedMessageCount(3)}
+    "mock:b" expect {_.received("<hello/>")}
+    "mock:c" expect {_.received("<hallo/>")}
+    "mock:d" expect {_.received("<hellos/>")}
+    "direct:a" ! ("<hello/>", "<hallo/>", "<hellos/>")
+    "mock:a" assert()
+    "mock:b" assert()
+    "mock:c" assert()
+    "mock:d" assert()
+  }
+  
+  override protected def createRouteBuilder() = 
+    new RouteBuilder {
+      "direct:a" ==> {
+        to ("mock:a")
+        choice {
+          when (_.in == "<hello/>") to ("mock:b")
+          when (_.in == "<hallo/>") to ("mock:c")
+          otherwise to ("mock:d")
+        }
+      }
+    }.print
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/FilterRouteBuilderTest.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,43 @@
+package org.apache.camel.scala.dsl;
+
+class FilterRouteBuilderTest extends ScalaTestSupport {
+
+  def testSimpleFilter() = {
+    "mock:a" expect {_.expectedMessageCount(1)}
+    "direct:a" ! ("<hello/>", "<hellos/>")
+    "mock:a" assert
+  }
+  
+  def testFilterWithAlternatives() = {
+    "mock:b" expect {_.expectedMessageCount(1)}
+    "mock:b" expect {_.expectedMessageCount(1)}
+    "mock:d" expect {_.expectedMessageCount(2)}
+    "mock:e" expect {_.expectedMessageCount(0)}
+    "mock:f" expect {_.expectedMessageCount(2)}
+    "direct:b" ! ("<hello/>", "<hellos/>")
+    "mock:b" assert()
+    "mock:c" assert()
+    "mock:d" assert()
+    "mock:e" assert()
+    "mock:f" assert()
+  }
+  
+  override protected def createRouteBuilder() = 
+    new RouteBuilder {
+       "direct:a" when(_.in == "<hello/>") to "mock:a"
+         
+       "direct:b" ==> {
+         when(_.in == "<hello/>") then {
+           to ("mock:b")
+           --> ("mock:c")
+         }
+         when(_.in == "<hallo/>") {
+           to ("mock:e")
+         } otherwise {
+           to ("mock:f")
+         }
+         to ("mock:d")  
+       }
+    }.print
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineAndMulticastTest.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,37 @@
+package org.apache.camel.scala.dsl;
+
+class PipelineAndMulticastTest extends ScalaTestSupport {
+  
+  def testArrowRoute = testRoute("direct:a", "mock:c", "mock:a", "mock:b")
+  def testToRoute = testRoute("direct:d", "mock:f", "mock:d", "mock:e")
+  def testArrowBlockRoute = testRoute("direct:g", "mock:i", "mock:g", "mock:h")
+  def testToBlockRoute = testRoute("direct:j", "mock:l", "mock:j", "mock:k")
+  
+  def testRoute(from: String, end: String, multis: String*) = {
+    multis.foreach ( _.expect { _.received("<hello/>")})
+    end expect { _.received("<olleh/>")}
+    
+    val exchange = in("<hello/>")
+    exchange.out = "<olleh/>"
+    getTemplate().send(from, exchange)
+    
+    multis.foreach( _.assert())
+    end assert()
+  }
+  
+  
+  override protected def createRouteBuilder() = 
+    new RouteBuilder {
+      "direct:a" --> ("mock:a", "mock:b") --> "mock:c"
+      "direct:d" to ("mock:d", "mock:e") to "mock:f"
+      "direct:g" ==> {
+        --> ("mock:g", "mock:h")
+        --> ("mock:i")
+      }
+      "direct:j" ==> {
+        to ("mock:j", "mock:k")
+        to ("mock:l")
+      }  
+    }.print
+
+}

Added: activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala?rev=644754&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala
(added)
+++ activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala
Fri Apr  4 09:17:00 2008
@@ -0,0 +1,36 @@
+package org.apache.camel.scala.dsl;
+
+class PipelineRouteBuilderTest extends ScalaTestSupport {
+  
+  def testPipelineWithArrows() = testPipeline("direct:a", "mock:a", "mock:b")
+  def testPipelineWithTos() = testPipeline("direct:c", "mock:c", "mock:d")
+  def testPipelineBlockWithArrows() = testPipeline("direct:e", "mock:e", "mock:f")
+  def testPipelineBlockWithTos() = testPipeline("direct:g", "mock:g", "mock:h")
+  
+  def testPipeline(from: String, to: String*) = {
+    to.foreach {
+      _.expect { _.expectedMessageCount(1) }
+    }
+    from ! "<hello/>"
+    to.foreach {
+      _.assert()
+    }
+  }
+  
+  override protected def createRouteBuilder() = 
+    new RouteBuilder {
+       "direct:a" --> "mock:a" --> "mock:b"
+       "direct:c" to "mock:c" to "mock:d"
+       
+       "direct:e" ==> {
+         --> ("mock:e")
+         --> ("mock:f")
+       }
+       
+       "direct:g" ==> {
+         to ("mock:g")
+         to ("mock:h")
+       }
+    }.print
+
+}

Modified: activemq/camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/pom.xml?rev=644754&r1=644753&r2=644754&view=diff
==============================================================================
--- activemq/camel/trunk/components/pom.xml (original)
+++ activemq/camel/trunk/components/pom.xml Fri Apr  4 09:17:00 2008
@@ -65,6 +65,7 @@
     <module>camel-rmi</module>
     <!--<module>camel-ruby</module>-->
     <module>camel-saxon</module>
+    <module>camel-scala</module>
     <module>camel-script</module>
     <module>camel-spring</module>
     <module>camel-sql</module>



Mime
View raw message