ObjectQueue implements Iterable<T>, Closeable { public void clear() throws IOException { remove(size()); }  static ObjectQueue<T> create(QueueFile qf, Converter<T> converter); static ObjectQueue<T> createInMemory(); abstract @Nullable QueueFile file(); abstract int size(); boolean isEmpty(); abstract void add(T entry); abstract @Nullable T peek(); List<T> peek(int max); List<T> asList(); void remove(); abstract void remove(int n); void clear();  }
@Test public void testIteratorNextThrowsWhenEmpty() throws IOException { queue.clear(); Iterator<String> iterator = queue.iterator(); try { iterator.next(); fail(); } catch (NoSuchElementException ignored) { } }
@Test public void testIteratorDisallowsConcurrentModificationWithClear() throws IOException { Iterator<String> iterator = queue.iterator(); iterator.next(); queue.clear(); try { iterator.hasNext(); fail(); } catch (ConcurrentModificationException ignored) { } }
@Test public void clear() throws IOException { queue.clear(); assertThat(queue.size()).isEqualTo(0); }