blended.itestsupport.jolokia.JolokiaChecker.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.jolokia
import akka.actor._
import akka.pattern._
import akka.util.Timeout
import blended.itestsupport.condition.{AsyncChecker, AsyncCondition}
import blended.jolokia.{JolokiaAddress, JolokiaClient}
trait JolokiaAssertion {
def jolokiaRequest : Any
def assertJolokia : Any => Boolean
}
class JolokiaChecker(url: String, userName: Option[String], password: Option[String]) extends AsyncChecker {
this: JolokiaAssertion =>
var jolokiaConnector : Option[ActorRef] = None
object JolokiaConnector {
def apply(url: String, userName: Option[String], userPwd: Option[String]) =
new JolokiaClient with JolokiaAddress {
override val jolokiaUrl = url
override val user = userName
override val password = userPwd
}
}
override def preStart() : Unit = {
jolokiaConnector = Some(context.actorOf(Props(JolokiaConnector(url, userName, password))))
}
override def performCheck(condition: AsyncCondition) = {
implicit val t = Timeout(condition.timeout)
(jolokiaConnector.get ? jolokiaRequest).map { result =>
assertJolokia(result)
}
}
}