@@ -0,0 +1,1853 @@
+package hudson.util;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.nio.charset.Charset;%0Aimport java.nio.file.Files;%0A%0Aimport static org.junit.Assert.*;%0A%0Apublic class AtomicFileWriterTest %7B%0A    File af;%0A    AtomicFileWriter afw;%0A    String expectedContent = %22hello world%22;%0A%0A%0A    @Before%0A    public void setUp() throws IOException %7B%0A        af = File.createTempFile(%22AtomicFileWriter%22, %22.tmp%22);%0A        afw = new AtomicFileWriter(af, Charset.defaultCharset());%0A    %7D%0A%0A    @After%0A    public void tearDown() throws IOException %7B%0A        Files.deleteIfExists(af.toPath());%0A        Files.deleteIfExists(afw.getTemporaryPath());%0A    %7D%0A%0A    @Test%0A    public void createFile() throws Exception %7B%0A        // Verify the file we created exists%0A        assertTrue(Files.exists(afw.getTemporaryPath()));%0A    %7D%0A%0A    @Test%0A    public void writeToAtomicFile() throws Exception %7B%0A        // Given%0A        afw.write(expectedContent, 0, expectedContent.length());%0A%0A        // When%0A        afw.flush();%0A%0A        // Then%0A        assertTrue(%22File writer did not properly flush to temporary file%22,%0A                Files.size(afw.getTemporaryPath()) == expectedContent.length());%0A    %7D%0A%0A    @Test%0A    public void commitToFile() throws Exception %7B%0A        // Given%0A        afw.write(expectedContent, 0, expectedContent.length());%0A%0A        // When%0A        afw.commit();%0A%0A        // Then%0A        System.err.println(Files.size(af.toPath()));%0A        assertTrue(Files.size(af.toPath()) == expectedContent.length());%0A    %7D%0A%0A    @Test%0A    public void abortDeletesTmpFile() throws Exception %7B%0A        // Given%0A        afw.write(expectedContent, 0, expectedContent.length());%0A%0A        // When%0A        afw.abort();%0A%0A        // Then%0A        assertTrue(Files.notExists(afw.getTemporaryPath()));%0A    %7D%0A%7D

Add unit test for atomic file writer.