Skip to content

Instantly share code, notes, and snippets.

@tamland
Created March 2, 2017 15:03
Show Gist options
  • Save tamland/61e145ddd01c51c9576db52e1ac7e4b9 to your computer and use it in GitHub Desktop.
Save tamland/61e145ddd01c51c9576db52e1ac7e4b9 to your computer and use it in GitHub Desktop.
package utils
import java.util.function.Predicate
import org.testcontainers.containers.GenericContainer.AbstractWaitStrategy
import org.testcontainers.containers.output.OutputFrame.OutputType.STDOUT
import org.testcontainers.containers.output.{OutputFrame, WaitingConsumer}
class WaitForLogLine(val msg: String) extends AbstractWaitStrategy {
val consumer = new WaitingConsumer()
override def waitUntilReady(): Unit = {
container.followOutput(consumer, STDOUT)
consumer.waitUntil(new Predicate[OutputFrame]() {
override def test(frame: OutputFrame): Boolean = {
frame.getUtf8String().contains(msg)
}
})
}
}
object WaitForLogLine {
def apply(msg: String): WaitForLogLine = new WaitForLogLine(msg)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment