@Test public void testNoIoExceptionOnClose() { HashMap<String, ObjectInputStream> inputs = new HashMap<>(); HashMap<String, ObjectOutputStream> outputs = new HashMap<>(); try { FileOutputStream fos = new FileOutputStream("foo"); ObjectOutputStream oos = new ObjectOutputStream(fos) { @Override public void close() throws IOException { throw new IOException("Mock Exception"); } }; outputs.put("bad-store", oos); FileInputStream fis = new FileInputStream("foo"); ObjectInputStream ois = new ObjectInputStream(fis) { @Override public void close() throws IOException { throw new IOException("Mock Exception"); } }; inputs.put("bad-store", ois); } catch (IOException e) { fail("Should not be reachable."); } FilebasedStreamedStorageImpl badStore = new FilebasedStreamedStorageImpl(new InMemoryStorage(), inputs, outputs); badStore.shutdown(); assertTrue("Should be reachable. Shutdown should handle the exceptions for us.", true); }