mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 21:12:15 +00:00
[FIXED JENKINS-17271] Util.deleteFile should give a concrete reason for failure.
This commit is contained in:
1 parent
606a9e1de9
commit
78b263421f
3 files changed
+43
-1
No files matched your search
@@ -37,6 +37,9 @@ import org.junit.Test;
|
||||
import org.jvnet.hudson.test.Bug;
|
||||
|
||||
import hudson.util.StreamTaskListener;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import org.junit.internal.AssumptionViolatedException;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
@@ -230,6 +233,31 @@ public class UtilTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void deleteFile() throws Exception {
|
||||
Assume.assumeTrue(Functions.isWindows());
|
||||
Class<?> c;
|
||||
try {
|
||||
c = Class.forName("java.nio.file.FileSystemException");
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new AssumptionViolatedException("prior to JDK 7", x);
|
||||
}
|
||||
File d = Util.createTempDir();
|
||||
try {
|
||||
File f = new File(d, "f");
|
||||
OutputStream os = new FileOutputStream(f);
|
||||
try {
|
||||
Util.deleteFile(f);
|
||||
fail("should not have been deletable");
|
||||
} catch (IOException x) {
|
||||
assertEquals(c, x.getClass());
|
||||
} finally {
|
||||
os.close();
|
||||
}
|
||||
} finally {
|
||||
Util.deleteRecursive(d);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHtmlEscape() {
|
||||
assertEquals("<br>", Util.escape("\n"));
|
||||
|
||||
Reference in new issue
Block a user