@Test public void testLeasedItems() throws Exception { RoundRobinSchedulerStats stats = new RoundRobinSchedulerStats(); assertEquals("Wrong default value.", 0, stats.getLeasedItemCount()); stats.incrementLeased(); assertEquals("Wrong incremented value.", 1, stats.getLeasedItemCount()); stats.incrementLeased(); assertEquals("Wrong incremented value.", 2, stats.getLeasedItemCount()); stats.incrementLeased(); assertEquals("Wrong incremented value.", 3, stats.getLeasedItemCount()); stats.decrementLeased(); assertEquals("Wrong decremented value.", 2, stats.getLeasedItemCount()); stats.decrementLeased(); assertEquals("Wrong decremented value.", 1, stats.getLeasedItemCount()); stats.decrementLeased(); assertEquals("Wrong decremented value.", 0, stats.getLeasedItemCount()); stats.decrementLeased(); assertEquals("Wrong decremented value.", 0, stats.getLeasedItemCount()); }
@Test public void testItemConsumed() throws Exception { RoundRobinSchedulerStats stats = new RoundRobinSchedulerStats(); stats.incrementLeased(); stats.incrementLeased(); stats.incrementScheduled(); stats.incrementScheduled(); assertEquals("Wrong processed value.", 0, stats.getProcessedItemCount()); assertEquals("Wrong leased value.", 2, stats.getLeasedItemCount()); assertEquals("Wrong scheduled value.", 2, stats.getScheduledItemCount()); stats.itemConsumed(); assertEquals("Wrong processed value.", 1, stats.getProcessedItemCount()); assertEquals("Wrong leased value.", 1, stats.getLeasedItemCount()); assertEquals("Wrong scheduled value.", 1, stats.getScheduledItemCount()); stats.itemConsumed(); assertEquals("Wrong processed value.", 2, stats.getProcessedItemCount()); assertEquals("Wrong leased value.", 0, stats.getLeasedItemCount()); assertEquals("Wrong scheduled value.", 0, stats.getScheduledItemCount()); }