"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/test/java/hudson/util/AtomicFileWriterTest.java" between
jenkins-jenkins-2.302.tar.gz and jenkins-jenkins-2.303.tar.gz

About: Jenkins is a automation server (written in Java) which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software (for e.g. as Continuous Integration and Continuous Delivery server). Weekly release.

AtomicFileWriterTest.java  (jenkins-jenkins-2.302):AtomicFileWriterTest.java  (jenkins-jenkins-2.303)
skipping to change at line 28 skipping to change at line 28
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermission;
import java.util.Set; import java.util.Set;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString; import static org.hamcrest.core.StringContains.containsString;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeThat;
public class AtomicFileWriterTest { public class AtomicFileWriterTest {
private static final String PREVIOUS = "previous value \n blah"; private static final String PREVIOUS = "previous value \n blah";
/** /**
* Provides access to the default permissions given to a new file. (i.e. ind irect way to get umask settings). * Provides access to the default permissions given to a new file. (i.e. ind irect way to get umask settings).
* <p><strong>BEWARE: null on non posix systems</strong></p> * <p><strong>BEWARE: null on non posix systems</strong></p>
*/ */
@Nullable @Nullable
private static Set<PosixFilePermission> DEFAULT_GIVEN_PERMISSIONS; private static Set<PosixFilePermission> DEFAULT_GIVEN_PERMISSIONS;
skipping to change at line 138 skipping to change at line 138
afw.abort(); afw.abort();
// Then // Then
assertTrue(Files.notExists(afw.getTemporaryPath())); assertTrue(Files.notExists(afw.getTemporaryPath()));
assertEquals(PREVIOUS, FileUtils.readFileToString(af, Charset.defaultCha rset())); assertEquals(PREVIOUS, FileUtils.readFileToString(af, Charset.defaultCha rset()));
} }
@Test @Test
public void indexOutOfBoundsLeavesOriginalUntouched() throws Exception { public void indexOutOfBoundsLeavesOriginalUntouched() throws Exception {
// Given // Given
try { assertThrows(IndexOutOfBoundsException.class, () -> afw.write(expectedCo
afw.write(expectedContent, 0, expectedContent.length() + 10); ntent, 0, expectedContent.length() + 10));
fail("exception expected");
} catch (IndexOutOfBoundsException e) {
}
assertEquals(PREVIOUS, FileUtils.readFileToString(af, Charset.defaultCha rset())); assertEquals(PREVIOUS, FileUtils.readFileToString(af, Charset.defaultCha rset()));
} }
@Test @Test
public void badPath() throws Exception { public void badPath() throws Exception {
final File newFile = tmp.newFile(); final File newFile = tmp.newFile();
File parentExistsAndIsAFile = new File(newFile, "badChild"); File parentExistsAndIsAFile = new File(newFile, "badChild");
assertTrue(newFile.exists()); assertTrue(newFile.exists());
assertFalse(parentExistsAndIsAFile.exists()); assertFalse(parentExistsAndIsAFile.exists());
try { final IOException e = assertThrows(IOException.class,
new AtomicFileWriter(parentExistsAndIsAFile.toPath(), StandardCharse () -> new AtomicFileWriter(parentExistsAndIsAFile.toPath(), Stan
ts.UTF_8); dardCharsets.UTF_8));
fail("Expected a failure"); assertThat(e.getMessage(),
} catch (IOException e) { containsString("exists and is neither a directory nor a symli
assertThat(e.getMessage(), nk to a directory"));
containsString("exists and is neither a directory nor a s
ymlink to a directory"));
}
} }
@Issue("JENKINS-48407") @Issue("JENKINS-48407")
@Test @Test
public void checkPermissionsRespectUmask() throws IOException { public void checkPermissionsRespectUmask() throws IOException {
final File newFile = tmp.newFile(); final File newFile = tmp.newFile();
boolean posixSupported = isPosixSupported(newFile); boolean posixSupported = isPosixSupported(newFile);
assumeThat(posixSupported, is(true)); assumeThat(posixSupported, is(true));
 End of changes. 4 change blocks. 
16 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)