StoredContent extends Content { @Override public boolean isAvailable() { try { getBytesUnsafe(); return true; } catch (BrokenStorageException e) { return false; } } StoredContent(Storage s, int id);  StoredContent(Stream s); @Override void write(Stream s); @Override byte[] getBytes(); @Override boolean isAvailable(); int getId(); @Override void purge(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testUnavailableIfExceptionOccurs() { Storage goodStorage = new InMemoryStorage() { @Override protected byte[] loadContentData(final int id) throws BrokenStorageException { return new byte[0]; } }; Storage brokenStorage = new InMemoryStorage() { @Override protected byte[] loadContentData(int id) throws BrokenStorageException { throw new BrokenStorageException(); } }; assertTrue(new StoredContent(goodStorage, 0).isAvailable()); assertFalse(new StoredContent(brokenStorage, 0).isAvailable()); }