### Question:
StoredObjectService { public void store(Object object) throws IOException { Files.createParentDirs(file); try (ObjectOutput out = new ObjectOutputStream(new FileOutputStream(file))) { out.writeObject(object); log.info("Stored object in {}", file); } catch (IOException e) { file.delete(); throw e; } }  boolean exists(); Object read(); void store(Object object);  }### Answer:
@Ignore @Test(expected = IOException.class) public void testFailedWrite() throws IOException { File file = folder.newFile(); file.delete(); StoredObjectService service = new StoredObjectService(file); try (RandomAccessFile raf = new RandomAccessFile(file, "rw"); FileChannel channel = raf.getChannel(); FileLock ignored = channel.lock()) { service.store("foo"); fail(); } }