ObjectQueue implements Iterable<T>, Closeable { public void remove() throws IOException { remove(1); }  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 testIteratorRemoveDisallowsConcurrentModification() throws IOException { Iterator<String> iterator = queue.iterator(); iterator.next(); queue.remove(); try { iterator.remove(); fail(); } catch (ConcurrentModificationException ignored) { } }
@Test public void testIteratorHasNextDisallowsConcurrentModification() throws IOException { Iterator<String> iterator = queue.iterator(); iterator.next(); queue.remove(); try { iterator.hasNext(); fail(); } catch (ConcurrentModificationException ignored) { } }
@Test public void testIteratorOnlyRemovesFromHead() throws IOException { Iterator<String> iterator = queue.iterator(); iterator.next(); iterator.next(); try { iterator.remove(); fail(); } catch (UnsupportedOperationException ex) { assertThat(ex).hasMessageThat().isEqualTo("Removal is only permitted from the head."); } }
@Test public void remove() throws IOException { queue.remove(); assertThat(queue.asList()).containsExactly("two", "three"); }