Ejemplo n.º 1
0
  @Test
  public void testDrain() {
    final int maxItems = 12;
    final IQueue q = client.getQueue(randomString());

    List offeredList = new LinkedList();
    for (int i = 0; i < maxItems; i++) {
      q.offer(i);
      offeredList.add(i);
    }
    List drainedList = new LinkedList();
    int totalDrained = q.drainTo(drainedList);

    assertEquals(maxItems, totalDrained);
    assertEquals(offeredList, drainedList);
  }
Ejemplo n.º 2
0
  @Test
  public void testPartialDrain() {
    final int maxItems = 15;
    final int itemsToDrain = maxItems / 2;

    final IQueue q = client.getQueue(randomString());

    List expectedList = new LinkedList();
    for (int i = 0; i < maxItems; i++) {
      q.offer(i);
      if (i < itemsToDrain) {
        expectedList.add(i);
      }
    }
    List drainedList = new LinkedList();
    int totalDrained = q.drainTo(drainedList, itemsToDrain);

    assertEquals(itemsToDrain, totalDrained);
    assertEquals(expectedList, drainedList);
  }