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

blended.itestsupport.condition.AsyncCondition.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.condition

import java.util.concurrent.atomic.AtomicBoolean

import akka.actor.{ActorRef, ActorSystem, Props}
import blended.itestsupport.protocol.CheckAsyncCondition

import scala.concurrent.duration.FiniteDuration

object AsyncCondition{
  def apply(asyncChecker: Props, desc: String, t: Option[FiniteDuration] = None)(implicit system: ActorSystem) = t match {
    case None => new AsyncCondition(asyncChecker, desc)
    case Some(d) => new AsyncCondition(asyncChecker, desc) {
      override def timeout = d
    }
  }
}

class AsyncCondition(asyncChecker: Props, desc: String)(implicit val system: ActorSystem) extends Condition {

  var checker : Option[ActorRef] = None

  val isSatisfied = new AtomicBoolean(false)

  override def satisfied = {
    checker match {
      case None =>
        checker = Some(system.actorOf(asyncChecker))
        checker.get ! CheckAsyncCondition(this)
      case _ =>
    }
    isSatisfied.get()
  }

  override val description: String = desc
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy