private WaveletOperation[] makeOps(int howMany) { WaveletOperation[] ops = new WaveletOperation[howMany]; for (int i = 0; i < howMany; ++i) { ops[i] = makeOp(); } return ops; }
private WaveletOperation[] makeOps(int howMany) { WaveletOperation[] ops = new WaveletOperation[howMany]; for (int i = 0; i < howMany; ++i) { ops[i] = makeOp(); } return ops; }
/** * Tests that the sucker doesn't touch the operation channel after being * shut down while consuming ops. */ public void testStopsSuckingAfterShutdown() { // Set expectations. WaveletOperation op = makeOp(); channel.expectPeek(op); sink.expectFlush(op, true); channel.expectPeek(op); channel.expectReceive(op); // Shut down the sucker when consuming the op. sink.expectConsume(op, new Runnable() { @Override public void run() { sucker.shutdown(); } }); // No more expectations of peek() or receive(). sucker.onOperationReceived(); }
/** * Tests that the sucker doesn't touch the operation channel after being * shut down while consuming ops. */ public void testStopsSuckingAfterShutdown() { // Set expectations. WaveletOperation op = makeOp(); channel.expectPeek(op); sink.expectFlush(op, true); channel.expectPeek(op); channel.expectReceive(op); // Shut down the sucker when consuming the op. sink.expectConsume(op, new Runnable() { @Override public void run() { sucker.shutdown(); } }); // No more expectations of peek() or receive(). sucker.onOperationReceived(); }
/** * 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(); }
/** * 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(); }