コード例 #1
0
  @Test
  public void testScheduledItems() throws Exception {
    RoundRobinSchedulerStats stats = new RoundRobinSchedulerStats();
    assertEquals("Wrong default value.", 0, stats.getScheduledItemCount());

    stats.incrementScheduled();
    assertEquals("Wrong incremented value.", 1, stats.getScheduledItemCount());
    stats.incrementScheduled();
    assertEquals("Wrong incremented value.", 2, stats.getScheduledItemCount());
    stats.incrementScheduled();
    assertEquals("Wrong incremented value.", 3, stats.getScheduledItemCount());

    stats.decrementScheduled();
    assertEquals("Wrong decremented value.", 2, stats.getScheduledItemCount());

    stats.decrementScheduled();
    assertEquals("Wrong decremented value.", 1, stats.getScheduledItemCount());

    stats.decrementScheduled();
    assertEquals("Wrong decremented value.", 0, stats.getScheduledItemCount());

    stats.decrementScheduled();
    assertEquals("Wrong decremented value.", 0, stats.getScheduledItemCount());
  }
コード例 #2
0
  @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());
  }