From: mike.gaffney <mike.gaffney@xxxxxxxxxxxxxx> --- .../org/spearce/jgit/lib/ObjectDirectoryTest.java | 21 ++----------------- .../tst/org/spearce/jgit/util/JGitTestUtil.java | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java index b27f2f8..4fecce7 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.UUID; import org.spearce.jgit.util.JGitTestUtil; @@ -19,13 +18,13 @@ @Override protected void setUp() throws Exception { - testDir = new File(new File(System.getProperty("java.io.tmpdir")), UUID.randomUUID().toString()); + testDir = JGitTestUtil.generateTempDirectoryFileObject(); } - + @Override protected void tearDown() throws Exception { if (testDir.exists()){ - deleteDir(testDir); + JGitTestUtil.deleteDir(testDir); } } @@ -93,20 +92,6 @@ public void testUpdateInfoCacheCreatesPacksAndRefsFile() throws Exception { assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile)); } - public boolean deleteDir(File dir) { - if (dir.isDirectory()) { - String[] children = dir.list(); - for (int i=0; i<children.length; i++) { - boolean success = deleteDir(new File(dir, children[i])); - if (!success) { - return false; - } - } - } - // The directory is now empty so delete it - return dir.delete(); - } - private void createTestDir(){ testDir.mkdir(); } diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java index b958282..7506553 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java @@ -40,7 +40,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; @@ -48,6 +47,7 @@ import java.io.OutputStream; import java.net.URISyntaxException; import java.net.URL; +import java.util.UUID; public abstract class JGitTestUtil { public static final String CLASSPATH_TO_RESOURCES = "org/spearce/jgit/test/resources/"; @@ -105,4 +105,22 @@ public static String readFileAsString(final File file) private static ClassLoader cl() { return JGitTestUtil.class.getClassLoader(); } + + public static boolean deleteDir(File dir) { + if (dir.isDirectory()) { + String[] children = dir.list(); + for (int i=0; i<children.length; i++) { + boolean success = deleteDir(new File(dir, children[i])); + if (!success) { + return false; + } + } + } + // The directory is now empty so delete it + return dir.delete(); + } + + public static File generateTempDirectoryFileObject() { + return new File(new File(System.getProperty("java.io.tmpdir")), UUID.randomUUID().toString()); + } } -- 1.6.4.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html