TrackedPriorityBlockingQueue extends PriorityBlockingQueue<E> implements ITrackedQueue<E> { @Override public E poll() { E e = super.poll(); lastRemovedTime = System.currentTimeMillis(); return e; } TrackedPriorityBlockingQueue(); Long getOldestItemTime(); @Override boolean offer(E e); @Override E poll(); @Override boolean remove(Object o); Long getLastAddedTime(); Long getLastRemovedTime();  }
@Test public void expectedPollOrder() { assertEquals("expected poll order", item1, queue.poll()); assertEquals("expected poll order", item2, queue.poll()); assertEquals("expected poll order", item3, queue.poll()); assertEquals("expected poll order", item100, queue.poll()); assertEquals("expected poll order", item101, queue.poll()); assertEquals("expected poll order", item102, queue.poll()); assertEquals("expected poll order", item103, queue.poll()); }