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

    stats.incrementProcessed();
    assertEquals("Wrong incremented value.", 1, stats.getProcessedItemCount());
    stats.incrementProcessed();
    assertEquals("Wrong incremented value.", 2, stats.getProcessedItemCount());
    stats.incrementProcessed();
    assertEquals("Wrong incremented value.", 3, stats.getProcessedItemCount());
  }
コード例 #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());
  }