Incrementor { public void incrementCount(int value) throws MaxCountExceededException { for (int i = 0; i < value; i++) { incrementCount(); } } Incrementor();  Incrementor(int max);  Incrementor(int max, MaxCountExceededCallback cb); void setMaximalCount(int max); int getMaximalCount(); int getCount(); boolean canIncrement(); void incrementCount(int value); void incrementCount(); void resetCount();  }
@Test(expected=TooManyEvaluationsException.class) public void testAlternateException() { final Incrementor.MaxCountExceededCallback cb = new Incrementor.MaxCountExceededCallback() { public void trigger(int max) { throw new TooManyEvaluationsException(max); } }; final Incrementor i = new Incrementor(0, cb); i.incrementCount(); }