/**
   * Tests that the sucker stops sucking if a flush is required, and resumes when the flush is done.
   */
  public void testFlushPausesSucking() {
    // Set expectations.
    WaveletOperation op = makeOp();
    channel.expectPeek(op);
    sink.expectFlush(op, false);

    // Go!
    sucker.onOperationReceived();

    channel.checkExpectationsSatisfied();
    sink.checkExpectationsSatisfied();
    Runnable resume = sink.getLastResumeCommand();
    assertNotNull(resume);

    // Another op received should not cause any action
    sucker.onOperationReceived();
    channel.checkExpectationsSatisfied();
    sink.checkExpectationsSatisfied();

    // Set expectations for the resume command.
    channel.expectPeek(op);
    sink.expectFlush(op, true);
    channel.expectPeek(op);
    channel.expectReceive(op);
    sink.expectConsume(op, null);

    channel.expectPeek(null);

    // Go!
    resume.run();
  }
 @Override
 protected void tearDown() throws Exception {
   channel.checkExpectationsSatisfied();
   sink.checkExpectationsSatisfied();
   super.tearDown();
 }