diff options
author | Adrian Goerler <adrian.goerler@sap.com> | 2011-07-07 23:16:40 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2011-07-07 23:16:40 +0200 |
commit | ad74bbf9c1744823e32c96a9de9d53576ddb7d9d (patch) | |
tree | b6cc940b59449c006d5a4a67f47045bef63de910 /org.eclipse.jgit.junit/src | |
parent | 172a9f05216394f243805844b446cc357dd6b943 (diff) | |
download | jgit-ad74bbf9c1744823e32c96a9de9d53576ddb7d9d.tar.gz jgit-ad74bbf9c1744823e32c96a9de9d53576ddb7d9d.zip |
Cleanup directories leftover by test.
Use the temporary file management from superclass.
Change-Id: I3042951dc21860b4b85dd72a6bf41ee7cfe2aba4
Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java index 6e74a04563..0c7ae7de72 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java @@ -307,6 +307,26 @@ public abstract class LocalDiskRepositoryTestCase { toClose.add(r); } + private String createUniqueTestFolderPrefix() { + return "test" + (System.currentTimeMillis() + "_" + (testCount++)); + } + + /** + * Creates a unique directory for a test + * + * @param name + * a subdirectory + * @return a unique directory for a test + * @throws IOException + */ + protected File createTempDirectory(String name) throws IOException { + String gitdirName = createUniqueTestFolderPrefix(); + File parent = new File(trash, gitdirName); + File directory = new File(parent, name); + FileUtils.mkdirs(directory); + return directory.getCanonicalFile(); + } + /** * Creates a new unique directory for a test repository * @@ -317,11 +337,12 @@ public abstract class LocalDiskRepositoryTestCase { * @throws IOException */ protected File createUniqueTestGitDir(boolean bare) throws IOException { - String uniqueId = System.currentTimeMillis() + "_" + (testCount++); - String gitdirName = "test" + uniqueId + (bare ? "" : "/") - + Constants.DOT_GIT; - File gitdir = new File(trash, gitdirName).getCanonicalFile(); - return gitdir; + String gitdirName = createUniqueTestFolderPrefix(); + if (!bare) + gitdirName += "/"; + gitdirName += Constants.DOT_GIT; + File gitdir = new File(trash, gitdirName); + return gitdir.getCanonicalFile(); } protected File createTempFile() throws IOException { @@ -453,4 +474,5 @@ public abstract class LocalDiskRepositoryTestCase { private String testId() { return getClass().getName() + "." + testCount; } + } |