blended.itestsupport.TestContextProvider.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blended.itestsupport Show documentation
Show all versions of blended.itestsupport Show documentation
Define an integration test API for collaborating blended container(s) using docker as a runtime
for the container(s) under test and an Akka based Camel framework to perform the integration tests
as pure blackbox tests. Container(s) may be prestarted and discovered (for execution speed) or
started by the integration test (for reproducability).
The newest version!
package blended.itestsupport
import akka.actor.{Actor, ActorLogging}
import akka.camel.CamelExtension
import akka.event.LoggingReceive
import blended.itestsupport.protocol._
import org.apache.camel.CamelContext
trait TestContextConfigurator {
def configure(cuts : Map[String, ContainerUnderTest], context: CamelContext) : CamelContext
}
class TestContextCreator extends Actor with ActorLogging { this : TestContextConfigurator =>
val camel = CamelExtension(context.system)
def receive = LoggingReceive {
case r : TestContextRequest =>
log.info(s"Creating TestCamelContext for CUT's [${r.cuts}]")
val result = try
Right(configure(r.cuts, camel.context))
catch {
case t : Throwable => Left(t)
}
log debug s"Created TestCamelContext [$result]"
sender ! TestContextResponse(result)
context.stop(self)
}
}