out.abort(); } else {
out.abort(); throw e; } finally {
/** * Ensure the tmp file is cleaned up and dstFile is not created when * aborting a new file. */ @Test public void testAbortNewFile() throws IOException { AtomicFileOutputStream fos = new AtomicFileOutputStream(dstFile); fos.abort(); assertEquals(0, testDir.list().length); }
/** * Ensure the tmp file is cleaned up and dstFile is untouched when * aborting an existing file overwrite. */ @Test public void testAbortExistingFile() throws IOException { FileOutputStream fos1 = new FileOutputStream(dstFile); fos1.write(TEST_STRING.getBytes()); fos1.close(); AtomicFileOutputStream fos2 = new AtomicFileOutputStream(dstFile); fos2.abort(); // Should not have touched original file assertEquals(TEST_STRING, ClientBase.readFile(dstFile)); assertEquals(1, testDir.list().length); }
/** * Ensure the tmp file is cleaned up and dstFile is not created when * aborting a new file. */ @Test public void testAbortNewFileAfterFlush() throws IOException { AtomicFileOutputStream fos = new AtomicFileOutputStream(dstFile); fos.write(TEST_STRING.getBytes()); fos.flush(); fos.abort(); assertEquals(0, testDir.list().length); }
/** * Ensure the tmp file is cleaned up and dstFile is untouched when * aborting an existing file overwrite. */ @Test public void testAbortExistingFileAfterFlush() throws IOException { FileOutputStream fos1 = new FileOutputStream(dstFile); fos1.write(TEST_STRING.getBytes()); fos1.close(); AtomicFileOutputStream fos2 = new AtomicFileOutputStream(dstFile); fos2.write(TEST_STRING_2.getBytes()); fos2.flush(); fos2.abort(); // Should not have touched original file assertEquals(TEST_STRING, ClientBase.readFile(dstFile)); assertEquals(1, testDir.list().length); } }
out.abort(); throw e; } finally {