aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2010-12-10 21:58:05 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2011-01-28 01:11:12 +0100
commit38eec8f4a26935ba9e75bfbdde8a5682e05f338d (patch)
treee609e5e005fed86ef245b1646010312eaa0a3a61 /org.eclipse.jgit.test
parentf5fe2dca3cb9f57891e1a4b18832fcc158d0c490 (diff)
downloadjgit-38eec8f4a26935ba9e75bfbdde8a5682e05f338d.tar.gz
jgit-38eec8f4a26935ba9e75bfbdde8a5682e05f338d.zip
[findbugs] Do not ignore exceptional return value of mkdir
java.io.File.mkdir() and mkdirs() report failure as an exceptional return value false. Fix the code which silently ignored this exceptional return value. Change-Id: I41244f4b9d66176e68e2c07e2329cf08492f8619 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java58
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java13
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java7
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RepositorySetupWorkDirTest.java5
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java5
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java5
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java12
12 files changed, 60 insertions, 60 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
index 33f305d487..61b099d61d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
@@ -90,7 +90,7 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddExistingSingleFile() throws IOException, NoFilepatternException {
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
@@ -106,9 +106,9 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddExistingSingleFileInSubDir() throws IOException, NoFilepatternException {
- new File(db.getWorkTree(), "sub").mkdir();
+ FileUtils.mkdir(new File(db.getWorkTree(), "sub"));
File file = new File(db.getWorkTree(), "sub/a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
@@ -125,7 +125,7 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddExistingSingleFileTwice() throws IOException, NoFilepatternException {
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
@@ -149,7 +149,7 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddExistingSingleFileTwiceWithCommit() throws Exception {
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
@@ -175,7 +175,7 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddRemovedFile() throws Exception {
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
@@ -197,7 +197,7 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddRemovedCommittedFile() throws Exception {
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
@@ -223,13 +223,13 @@ public class AddCommandTest extends RepositoryTestCase {
// prepare conflict
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
File file2 = new File(db.getWorkTree(), "b.txt");
- file2.createNewFile();
+ FileUtils.createNewFile(file2);
writer = new PrintWriter(file2);
writer.print("content b");
writer.close();
@@ -275,13 +275,13 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddTwoFiles() throws Exception {
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
File file2 = new File(db.getWorkTree(), "b.txt");
- file2.createNewFile();
+ FileUtils.createNewFile(file2);
writer = new PrintWriter(file2);
writer.print("content b");
writer.close();
@@ -296,15 +296,15 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddFolder() throws Exception {
- new File(db.getWorkTree(), "sub").mkdir();
+ FileUtils.mkdir(new File(db.getWorkTree(), "sub"));
File file = new File(db.getWorkTree(), "sub/a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
File file2 = new File(db.getWorkTree(), "sub/b.txt");
- file2.createNewFile();
+ FileUtils.createNewFile(file2);
writer = new PrintWriter(file2);
writer.print("content b");
writer.close();
@@ -319,21 +319,21 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddIgnoredFile() throws Exception {
- new File(db.getWorkTree(), "sub").mkdir();
+ FileUtils.mkdir(new File(db.getWorkTree(), "sub"));
File file = new File(db.getWorkTree(), "sub/a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
File ignoreFile = new File(db.getWorkTree(), ".gitignore");
- ignoreFile.createNewFile();
+ FileUtils.createNewFile(ignoreFile);
writer = new PrintWriter(ignoreFile);
writer.print("sub/b.txt");
writer.close();
File file2 = new File(db.getWorkTree(), "sub/b.txt");
- file2.createNewFile();
+ FileUtils.createNewFile(file2);
writer = new PrintWriter(file2);
writer.print("content b");
writer.close();
@@ -348,15 +348,15 @@ public class AddCommandTest extends RepositoryTestCase {
@Test
public void testAddWholeRepo() throws Exception {
- new File(db.getWorkTree(), "sub").mkdir();
+ FileUtils.mkdir(new File(db.getWorkTree(), "sub"));
File file = new File(db.getWorkTree(), "sub/a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
File file2 = new File(db.getWorkTree(), "sub/b.txt");
- file2.createNewFile();
+ FileUtils.createNewFile(file2);
writer = new PrintWriter(file2);
writer.print("content b");
writer.close();
@@ -375,15 +375,15 @@ public class AddCommandTest extends RepositoryTestCase {
// file c exists in workdir but not in index -> added
@Test
public void testAddWithoutParameterUpdate() throws Exception {
- new File(db.getWorkTree(), "sub").mkdir();
+ FileUtils.mkdir(new File(db.getWorkTree(), "sub"));
File file = new File(db.getWorkTree(), "sub/a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
File file2 = new File(db.getWorkTree(), "sub/b.txt");
- file2.createNewFile();
+ FileUtils.createNewFile(file2);
writer = new PrintWriter(file2);
writer.print("content b");
writer.close();
@@ -400,7 +400,7 @@ public class AddCommandTest extends RepositoryTestCase {
// new unstaged file sub/c.txt
File file3 = new File(db.getWorkTree(), "sub/c.txt");
- file3.createNewFile();
+ FileUtils.createNewFile(file3);
writer = new PrintWriter(file3);
writer.print("content c");
writer.close();
@@ -429,15 +429,15 @@ public class AddCommandTest extends RepositoryTestCase {
// file c exists in workdir but not in index -> unchanged
@Test
public void testAddWithParameterUpdate() throws Exception {
- new File(db.getWorkTree(), "sub").mkdir();
+ FileUtils.mkdir(new File(db.getWorkTree(), "sub"));
File file = new File(db.getWorkTree(), "sub/a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
File file2 = new File(db.getWorkTree(), "sub/b.txt");
- file2.createNewFile();
+ FileUtils.createNewFile(file2);
writer = new PrintWriter(file2);
writer.print("content b");
writer.close();
@@ -454,7 +454,7 @@ public class AddCommandTest extends RepositoryTestCase {
// new unstaged file sub/c.txt
File file3 = new File(db.getWorkTree(), "sub/c.txt");
- file3.createNewFile();
+ FileUtils.createNewFile(file3);
writer = new PrintWriter(file3);
writer.print("content c");
writer.close();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
index 67a9a1b3f3..bc313e87e5 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
@@ -66,6 +66,7 @@ import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.treewalk.TreeWalk;
+import org.eclipse.jgit.util.FileUtils;
public class CommitAndLogCommandTests extends RepositoryTestCase {
public void testSomeCommits() throws NoHeadException, NoMessageException,
@@ -169,7 +170,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
JGitInternalException, WrongRepositoryStateException,
NoFilepatternException {
File file = new File(db.getWorkTree(), "a.txt");
- file.createNewFile();
+ FileUtils.createNewFile(file);
PrintWriter writer = new PrintWriter(file);
writer.print("content");
writer.close();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java
index 755370c92d..15aafc9060 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java
@@ -51,6 +51,7 @@ import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryTestCase;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.Before;
import org.junit.Test;
@@ -93,16 +94,8 @@ public class InitCommandTest extends RepositoryTestCase {
public static File createTempDirectory(String name) throws IOException {
final File temp;
temp = File.createTempFile(name, Long.toString(System.nanoTime()));
-
- if (!(temp.delete())) {
- throw new IOException("Could not delete temp file: "
- + temp.getAbsolutePath());
- }
-
- if (!(temp.mkdir())) {
- throw new IOException("Could not create temp directory: "
- + temp.getAbsolutePath());
- }
+ FileUtils.delete(temp);
+ FileUtils.mkdir(temp);
return temp;
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
index 80b853ee7c..c25ee4c04a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
@@ -53,6 +53,7 @@ import java.util.TreeSet;
import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.FileTreeIteratorWithTimeControl;
import org.eclipse.jgit.treewalk.NameConflictTreeWalk;
+import org.eclipse.jgit.util.FileUtils;
public class RacyGitTests extends RepositoryTestCase {
public void testIterator() throws IllegalStateException, IOException,
@@ -61,19 +62,19 @@ public class RacyGitTests extends RepositoryTestCase {
File lastFile = null;
for (int i = 0; i < 10; i++) {
lastFile = new File(db.getWorkTree(), "0." + i);
- lastFile.createNewFile();
+ FileUtils.createNewFile(lastFile);
if (i == 5)
fsTick(lastFile);
}
modTimes.add(fsTick(lastFile));
for (int i = 0; i < 10; i++) {
lastFile = new File(db.getWorkTree(), "1." + i);
- lastFile.createNewFile();
+ FileUtils.createNewFile(lastFile);
}
modTimes.add(fsTick(lastFile));
for (int i = 0; i < 10; i++) {
lastFile = new File(db.getWorkTree(), "2." + i);
- lastFile.createNewFile();
+ FileUtils.createNewFile(lastFile);
if (i % 4 == 0)
fsTick(lastFile);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java
index 2f989e32cf..cfb526d63b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/AbbreviationTest.java
@@ -68,6 +68,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.transport.PackedObjectInfo;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -176,7 +177,7 @@ public class AbbreviationTest extends LocalDiskRepositoryTestCase {
File packDir = new File(db.getObjectDatabase().getDirectory(), "pack");
File idxFile = new File(packDir, packName + ".idx");
File packFile = new File(packDir, packName + ".pack");
- packDir.mkdir();
+ FileUtils.mkdir(packDir, true);
OutputStream dst = new BufferedOutputStream(new FileOutputStream(
idxFile));
try {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java
index 385c8531c4..80e0f1a920 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java
@@ -48,6 +48,7 @@ import static org.junit.Assert.assertEquals;
import java.io.File;
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
@@ -55,7 +56,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
public void testShouldAutomagicallyDetectGitDirectory() throws Exception {
FileRepository r = createWorkRepository();
File d = new File(r.getDirectory(), "sub-dir");
- d.mkdir();
+ FileUtils.mkdir(d);
assertEquals(r.getDirectory(), new FileRepositoryBuilder()
.findGitDir(d).getGitDir());
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RepositorySetupWorkDirTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RepositorySetupWorkDirTest.java
index 99d99a5e5c..1781c3d62d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RepositorySetupWorkDirTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RepositorySetupWorkDirTest.java
@@ -59,6 +59,7 @@ import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.util.FS;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
/**
@@ -182,12 +183,12 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
}
}
- private File getFile(String... pathComponents) {
+ private File getFile(String... pathComponents) throws IOException {
String rootPath = new File(new File("target"), "trash").getPath();
for (String pathComponent : pathComponents)
rootPath = rootPath + File.separatorChar + pathComponent;
File result = new File(rootPath);
- result.mkdir();
+ FileUtils.mkdirs(result, true);
return result;
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java
index 7f0436b83e..ec5c8848fd 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java
@@ -81,6 +81,7 @@ import org.eclipse.jgit.lib.TreeFormatter;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
public class T0003_BasicTest extends SampleDataRepositoryTestCase {
@@ -202,7 +203,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
throws IOException {
File repo1Parent = new File(trash.getParentFile(), "r1");
File workdir = new File(trash.getParentFile(), "rw");
- workdir.mkdir();
+ FileUtils.mkdir(workdir);
FileRepository repo1initial = new FileRepository(new File(repo1Parent,
Constants.DOT_GIT));
repo1initial.create();
@@ -231,7 +232,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
throws IOException {
File repo1Parent = new File(trash.getParentFile(), "r1");
File workdir = new File(trash.getParentFile(), "rw");
- workdir.mkdir();
+ FileUtils.mkdir(workdir);
FileRepository repo1initial = new FileRepository(new File(repo1Parent,
Constants.DOT_GIT));
repo1initial.create();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java
index c6199c3423..0e6881ef91 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java
@@ -71,6 +71,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.lib.ObjectStream;
+import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.IO;
import org.junit.After;
import org.junit.Before;
@@ -567,7 +568,7 @@ public class UnpackedObjectTest extends LocalDiskRepositoryTestCase {
private void write(ObjectId id, byte[] data) throws IOException {
File path = path(id);
- path.getParentFile().mkdirs();
+ FileUtils.mkdirs(path.getParentFile());
FileOutputStream out = new FileOutputStream(path);
try {
out.write(data);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
index 966cd98127..67123a44b3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
@@ -54,6 +54,7 @@ import java.io.OutputStreamWriter;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.transport.OpenSshConfig.Host;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.Before;
import org.junit.Test;
@@ -69,10 +70,10 @@ public class OpenSshConfigTest extends RepositoryTestCase {
super.setUp();
home = new File(trash, "home");
- home.mkdir();
+ FileUtils.mkdir(home);
configFile = new File(new File(home, ".ssh"), "config");
- configFile.getParentFile().mkdir();
+ FileUtils.mkdir(configFile.getParentFile());
System.setProperty("user.name", "jex_junit");
osc = new OpenSshConfig(home, configFile);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
index ad8917a926..0b12058c88 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
@@ -110,8 +110,7 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
public void testEmptyIfRootIsEmpty() throws Exception {
final File r = new File(trash, "not-existing-file");
assertFalse(r.exists());
- r.mkdir();
- assertTrue(r.isDirectory());
+ FileUtils.mkdir(r);
final FileTreeIterator fti = new FileTreeIterator(r, db.getFS(),
db.getConfig().get(WorkingTreeOptions.KEY));
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java
index d81e686c14..08e755752b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java
@@ -71,7 +71,7 @@ public class FileUtilTest {
@Test
public void testDeleteFile() throws IOException {
File f = new File(trash, "test");
- assertTrue(f.createNewFile());
+ FileUtils.createNewFile(f);
FileUtils.delete(f);
assertFalse(f.exists());
@@ -92,10 +92,10 @@ public class FileUtilTest {
@Test
public void testDeleteRecursive() throws IOException {
File f1 = new File(trash, "test/test/a");
- f1.mkdirs();
- f1.createNewFile();
+ FileUtils.mkdirs(f1.getParentFile());
+ FileUtils.createNewFile(f1);
File f2 = new File(trash, "test/test/b");
- f2.createNewFile();
+ FileUtils.createNewFile(f2);
File d = new File(trash, "test");
FileUtils.delete(d, FileUtils.RECURSIVE);
assertFalse(d.exists());
@@ -132,7 +132,7 @@ public class FileUtilTest {
assertTrue(d.delete());
File f = new File(trash, "test");
- assertTrue(f.createNewFile());
+ FileUtils.createNewFile(f);
try {
FileUtils.mkdir(d);
fail("creation of directory having same path as existing file must"
@@ -164,7 +164,7 @@ public class FileUtilTest {
FileUtils.delete(root, FileUtils.RECURSIVE);
File f = new File(trash, "test");
- assertTrue(f.createNewFile());
+ FileUtils.createNewFile(f);
try {
FileUtils.mkdirs(d);
fail("creation of directory having path conflicting with existing"