Hey,
I am playing with the scala code of the book source code. I also downloaded camel-scala sources from svn. I use IntelliJ IDEA as IDE. Probably all of you do use it too, because it is the only one with good Scala support yet?
I have created several Scala routes, beans, processors. Everything works fine. But I cannot manage to get a simple Camel test running. First I tried to use CamelTestSupport. After asking google I found out, that I should use "extends ContextTestSupport with RouteBuilderSupport". Everything compiles fine. But I cannot start the test (using run configuration as scala test).
The error in IntelliJ IDEA is: "Error running RunFileToFileTest: Not found suite class"
How can I start these tests? Do I need a specific Runner when I start it? Or do I need another Run Configuration in IntelliJ IDEA when I start it?
I also looked at the camel-scala component, there you have a class ScalaTestSupport which uses ContextTestSupport. Do I have to compile and use it?
Here is my example:
package test
import org.apache.camel.scala.dsl.builder.{RouteBuilderSupport, RouteBuilder}
import org.apache.camel.{ContextTestSupport, Exchange}
class FileToFileTest extends ContextTestSupport with RouteBuilderSupport {
override def createRouteBuilder = new RouteBuilder {
"direct:start" ==> {
onCompletion(containsHello(_)) {
to("mock:sync")
}
to("mock:result")
}
def containsHello(exchange: Exchange) = exchange.getIn().getBody(classOf[String]).contains("Hello");
}
}
I also tried out another simple ScalaTest example. This one works perfectly:
package test
import java.lang.StringBuilder
import collection.mutable.ListBuffer
import org.junit.{Test, Before}
import org.junit.Assert._
import org.scalatest.junit.JUnitSuite
class UsingScalaTest extends JUnitSuite {
var sb: StringBuilder = _
var lb: ListBuffer[String] = _
@Before def init {
sb = new StringBuilder("ScalaTest is ")
lb = new ListBuffer[String]
}
@Test def verifyEasy() { // Uses JUnit-style assertions
sb.append("easy!")
assertEquals("ScalaTest is easy!", sb.toString)
assertTrue(lb.isEmpty)
lb += "sweet"
try {
"verbose".charAt(-1)
fail()
}
catch {
case e: StringIndexOutOfBoundsException => // Expected
}
}
@Test def verifyFun() { // Uses ScalaTest assertions
sb.append("fun!")
assert(sb.toString === "ScalaTest is fun!")
assert(lb.isEmpty)
lb += "sweeter"
intercept[StringIndexOutOfBoundsException] {
"concise".charAt(-1)
}
}
}
So my question is: How can I run a real Camel-Test? Or does there exists any downloadable Scala-Camel example which also uses CamelTestSupport or ContextTestSupport? I only found some examples at github which do not use these classes
Thanks for some hints...
Best regards,
Kai