CounterSwitchPipe extends FixedForwardPipe { @Override public PipeRunResult doPipe(Message message, IPipeLineSession session) throws PipeRunException { String forward = ""; PipeForward pipeForward = null; StatisticsKeeper sk = getPipeLine().getPipeStatistics(this); if (sk != null) { long count = sk.getCount(); forward = "" + (getDivisor() - (count % getDivisor())); } log.debug(getLogPrefix(session) + "determined forward [" + forward + "]"); pipeForward = findForward(forward); if (pipeForward == null) { throw new PipeRunException(this, getLogPrefix(null) + "cannot find forward or pipe named [" + forward + "]"); } log.debug(getLogPrefix(session) + "resolved forward [" + forward + "] to path [" + pipeForward.getPath() + "]"); return new PipeRunResult(pipeForward, message); }  @Override void configure(); @Override PipeRunResult doPipe(Message message, IPipeLineSession session); int getDivisor(); @IbisDoc({" ", "2"}) void setDivisor(int i);  }
@Test(expected = PipeRunException.class) public void testLegitimateDivisor() throws Exception { configureAndStartPipe(); doPipe(pipe, "dummy", session); }