Class WaitingConsumer

All Implemented Interfaces:
Consumer<OutputFrame>

public class WaitingConsumer extends BaseConsumer<WaitingConsumer>
A consumer for container output that buffers lines in a BlockingDeque and enables tests to wait for a matching condition.
  • Constructor Details

    • WaitingConsumer

      public WaitingConsumer()
  • Method Details

    • accept

      public void accept(OutputFrame frame)
    • getFrames

      public LinkedBlockingDeque<OutputFrame> 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

      public void waitUntil(Predicate<OutputFrame> predicate) 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 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 frame
      limit - maximum time to wait
      limitUnit - 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 frame
      limit - maximum time to wait
      limitUnit - 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

      public void waitUntilEnd(long limit, TimeUnit limitUnit) throws TimeoutException
      Wait until Docker closes the stream of output.
      Parameters:
      limit - maximum time to wait
      limitUnit - maximum time to wait (units)
      Throws:
      TimeoutException