DiskQueue extends AbstractQueue<String> { @Override public Iterator<String> iterator() { return new Itr(); } DiskQueue(int maxInMemorySize);  DiskQueue(int maxInMemorySize, File tempDir); @Override Iterator<String> iterator(); @Override int size(); @Override boolean offer(String element); @Override String peek(); @Override String remove(); @Override String poll(); @Override void clear();  }
@Test public void testIterator() { Queue<String> instance = new DiskQueue<String>(1); Iterator<String> iterator = instance.iterator(); assertFalse(iterator.hasNext()); instance.add("1"); instance.add("2"); instance.add("3"); iterator = instance.iterator(); assertTrue(iterator.hasNext()); assertEquals("1", iterator.next()); assertTrue(iterator.hasNext()); assertEquals("2", iterator.next()); assertTrue(iterator.hasNext()); assertEquals("3", iterator.next()); assertFalse(iterator.hasNext()); }
@Test public void testIterator2() { Queue<String> instance = new DiskQueue<String>(3); Iterator<String> iterator = instance.iterator(); assertFalse(iterator.hasNext()); instance.add("1"); instance.add("2"); instance.add("3"); iterator = instance.iterator(); assertTrue(iterator.hasNext()); assertEquals("1", iterator.next()); assertTrue(iterator.hasNext()); assertEquals("2", iterator.next()); assertTrue(iterator.hasNext()); assertEquals("3", iterator.next()); assertFalse(iterator.hasNext()); }