blended.itestsupport.condition.ConditionProvider.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.condition
import java.util.concurrent.atomic.AtomicInteger
import scala.concurrent.duration.FiniteDuration
class AlwaysTrue extends Condition {
val id = ConditionProvider.counter.incrementAndGet().toString
override def satisfied: Boolean = true
override val description = s"AlwaysTrueCondition[$id]"
}
class NeverTrue extends Condition {
val id = ConditionProvider.counter.incrementAndGet().toString
override def satisfied: Boolean = false
override val description = s"NeverTrueCondition[$id]"
}
class DelayedTrue(d: FiniteDuration) extends Condition {
private val id = ConditionProvider.counter.incrementAndGet().toString
private val created = System.currentTimeMillis()
override def satisfied: Boolean = (System.currentTimeMillis() - created) >= d.toMillis
override val description = s"DelayedTrue[$id]"
}
object ConditionProvider {
val counter = new AtomicInteger()
def alwaysTrue() = new AlwaysTrue
def neverTrue() = new NeverTrue
}