VWOMessageQueue implements MessageQueue<Entry> { @Override @Nullable public Entry peek() { VWOLog.i(VWOLog.STORAGE_LOGS, String.format(Locale.ENGLISH, "Reading from queue %s", this.filename), true); try { byte[] data; synchronized (queueFile) { data = queueFile.peek(); } if (data == null) { return null; } return Serializer.unmarshall(data, Entry.class); } catch (IOException exception) { VWOLog.e(VWOLog.STORAGE_LOGS, "Entry corrupted. Removing..", exception, true, true); remove(); } catch (ClassNotFoundException exception) { VWOLog.e(VWOLog.STORAGE_LOGS, "Entry corrupted. Removing...", exception, true, true); remove(); } catch (Exception exception) { VWOLog.e(VWOLog.STORAGE_LOGS, "Entry corrupted. Removing...", exception, true, true); remove(); } return null; } private  VWOMessageQueue(Context context, String fileName); static VWOMessageQueue getInstance(Context context, String fileName); @Override void add(final Entry entry); @Override @Nullable Entry peek(); @Override void removeAll(); @Override void remove(); String getFilename(); void setFilename(String fileName); @Override int size(); @Override String toString(); @Override Entry poll();  }
@Test public void peekTest() throws InterruptedException { GoalEntry goalEntry = new GoalEntry("http: vwoMessageQueue.add(goalEntry); vwoMessageQueue.add(goalEntry); System.out.println("Added: " + goalEntry.getUrl()); synchronized (lock) { lock.wait(2000); } Entry entry = vwoMessageQueue.peek(); Assert.assertNotNull(entry); Assert.assertEquals(entry.getUrl(), goalEntry.getUrl()); System.out.println("Verified: " + entry.getUrl()); }