All Downloads are FREE. Search and download functionalities are using the official Maven repository.

blended.itestsupport.TestContextProvider.scala Maven / Gradle / Ivy

Go to download

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)
  }
  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy