Package run.halo.gradle.docker
Class WaitingConsumer
- All Implemented Interfaces:
Consumer<OutputFrame>
A consumer for container output that buffers lines in a
BlockingDeque and enables tests
to wait for a matching condition.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(OutputFrame frame) Get access to the underlying frame buffer.voidwaitUntil(Predicate<OutputFrame> predicate) Wait until any frame (usually, line) of output matches the provided predicate.voidwaitUntil(Predicate<OutputFrame> predicate, int limit, TimeUnit limitUnit) Wait until any frame (usually, line) of output matches the provided predicate.voidwaitUntil(Predicate<OutputFrame> predicate, long limit, TimeUnit limitUnit, int times) Wait until any frame (usually, line) of output matches the provided predicate.voidWait until Docker closes the stream of output.voidwaitUntilEnd(long limit, TimeUnit limitUnit) Wait until Docker closes the stream of output.Methods inherited from class run.halo.gradle.docker.BaseConsumer
isRemoveColorCodes, setRemoveColorCodes, withRemoveAnsiCodes
-
Constructor Details
-
WaitingConsumer
public WaitingConsumer()
-
-
Method Details
-
accept
-
getFrames
Get access to the underlying frame buffer. Modifying the buffer contents is likely to cause problems if the waitUntil() methods are also being used, as they feed on the same data.- Returns:
- the collection of frames
-
waitUntil
Wait until any frame (usually, line) of output matches the provided predicate.Note that lines will often have a trailing newline character, and this is not stripped off before the predicate is tested.
- Parameters:
predicate- a predicate to test against each frame- Throws:
TimeoutException
-
waitUntil
public void waitUntil(Predicate<OutputFrame> predicate, int limit, TimeUnit limitUnit) throws TimeoutException Wait until any frame (usually, line) of output matches the provided predicate.Note that lines will often have a trailing newline character, and this is not stripped off before the predicate is tested.
- Parameters:
predicate- a predicate to test against each framelimit- maximum time to waitlimitUnit- maximum time to wait (units)- Throws:
TimeoutException
-
waitUntil
public void waitUntil(Predicate<OutputFrame> predicate, long limit, TimeUnit limitUnit, int times) throws TimeoutException Wait until any frame (usually, line) of output matches the provided predicate.Note that lines will often have a trailing newline character, and this is not stripped off before the predicate is tested.
- Parameters:
predicate- a predicate to test against each framelimit- maximum time to waitlimitUnit- maximum time to wait (units)times- number of times the predicate has to match- Throws:
TimeoutException
-
waitUntilEnd
public void waitUntilEnd()Wait until Docker closes the stream of output. -
waitUntilEnd
Wait until Docker closes the stream of output.- Parameters:
limit- maximum time to waitlimitUnit- maximum time to wait (units)- Throws:
TimeoutException
-