git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: mr.gaffo@gmail.com
To: git@vger.kernel.org
Cc: "mike.gaffney" <mike.gaffney@asolutions.com>
Subject: [PATCH JGit 14/19] pulled out some helper functions that will be useful for other tests
Date: Sun, 13 Sep 2009 13:44:30 -0500	[thread overview]
Message-ID: <1252867475-858-15-git-send-email-mr.gaffo@gmail.com> (raw)
In-Reply-To: <1252867475-858-14-git-send-email-mr.gaffo@gmail.com>

From: mike.gaffney <mike.gaffney@asolutions.com>

---
 .../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

  reply	other threads:[~2009-09-13 18:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-13 18:44 [PATCH JGit] Adding update-server-info functionality mr.gaffo
2009-09-13 18:44 ` [PATCH JGit 01/19] adding tests for ObjectDirectory mr.gaffo
2009-09-13 18:44   ` [PATCH JGit 02/19] Create abstract method on ObjectDatabase for accessing the list of local pack files mr.gaffo
2009-09-13 18:44     ` [PATCH JGit 03/19] Add abstract method for updating the object db's info cache Implemented passthrough on Alternate for the update of infocache mr.gaffo
2009-09-13 18:44       ` [PATCH JGit 04/19] added utility that generates the contents of the objects/info/packs file as a string from a list of PackFiles mr.gaffo
2009-09-13 18:44         ` [PATCH JGit 05/19] Made tests for listLocalPacks function on ObjectDirectory and made them pass mr.gaffo
2009-09-13 18:44           ` [PATCH JGit 06/19] added utility for reading the contents of a file as a string mr.gaffo
2009-09-13 18:44             ` [PATCH JGit 07/19] implemented the packs file update functionality mr.gaffo
2009-09-13 18:44               ` [PATCH JGit 08/19] changed signature to allow a IOException mr.gaffo
2009-09-13 18:44                 ` [PATCH JGit 09/19] Didn't like the old name, this is more specific to it just updating the packs info cache mr.gaffo
2009-09-13 18:44                   ` [PATCH JGit 10/19] moved test up to a higher level to test actual functionality mr.gaffo
2009-09-13 18:44                     ` [PATCH JGit 11/19] removed unused import mr.gaffo
2009-09-13 18:44                       ` [PATCH JGit 12/19] moved info/packs into a constant mr.gaffo
2009-09-13 18:44                         ` [PATCH JGit 13/19] made the call update the object database's info cache mr.gaffo
2009-09-13 18:44                           ` mr.gaffo [this message]
2009-09-13 18:44                             ` [PATCH JGit 15/19] Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory mr.gaffo
2009-09-13 18:44                               ` [PATCH JGit 16/19] added tests for the file based info cache update and made pass mr.gaffo
2009-09-13 18:44                                 ` [PATCH JGit 17/19] added call to update the info refs file mr.gaffo
2009-09-13 18:44                                   ` [PATCH JGit 18/19] Added Copyright Notices mr.gaffo
2009-09-13 18:44                                     ` [PATCH JGit 19/19] changed \r to \n per compliance with real git mr.gaffo
2009-09-15 19:23                   ` [PATCH JGit 09/19] Didn't like the old name, this is more specific to it just updating the packs info cache Robin Rosenberg
2009-09-15 19:23               ` [PATCH JGit 07/19] implemented the packs file update functionality Robin Rosenberg
2009-09-15 16:13           ` [PATCH JGit 05/19] Made tests for listLocalPacks function on ObjectDirectory and made them pass Robin Rosenberg
2009-09-15 15:35         ` [PATCH JGit 04/19] added utility that generates the contents of the objects/info/packs file as a string from a list of PackFiles Robin Rosenberg
2009-09-15 15:38   ` [PATCH JGit 01/19] adding tests for ObjectDirectory Robin Rosenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1252867475-858-15-git-send-email-mr.gaffo@gmail.com \
    --to=mr.gaffo@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mike.gaffney@asolutions.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).