Created
March 2, 2017 15:03
-
-
Save tamland/61e145ddd01c51c9576db52e1ac7e4b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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