@Test
  public void testSingleThreaded() {
    final ARingBuffer<Long> rb = new ARingBuffer<Long>(Long.class, 100);

    assertFalse(rb.iterator().hasNext());
    try {
      rb.iterator().next();
      fail("exception expected");
    } catch (Exception exc) {
    }

    for (long i = 1; i < 2000; i++) {
      rb.put(i);

      final Iterator<Long> iter = rb.iterator();
      for (long j = Math.max(1, i - 99); j <= i; j++) {
        assertTrue(iter.hasNext());
        assertEquals(Long.valueOf(j), iter.next());
      }
      assertFalse(iter.hasNext());
    }
  }
  @Test
  public void testClear() {
    final ARingBuffer<Long> rb = new ARingBuffer<Long>(Long.class, 100);
    assertFalse(rb.iterator().hasNext());

    rb.clear();
    assertFalse(rb.iterator().hasNext());

    rb.put(1L);
    assertTrue(rb.iterator().hasNext());
    rb.clear();
    assertFalse(rb.iterator().hasNext());

    for (long i = 0; i < 12345; i++) {
      rb.put(i);
    }
    assertTrue(rb.iterator().hasNext());
    rb.clear();
    assertFalse(rb.iterator().hasNext());
  }