diff options
Diffstat (limited to 'org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java | 35 |
1 files changed, 15 insertions, 20 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 dd143826ec..3917c487d7 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 @@ -45,6 +45,9 @@ package org.eclipse.jgit.junit; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -57,10 +60,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Repository; @@ -72,6 +71,8 @@ import org.eclipse.jgit.storage.file.WindowCacheConfig; import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.SystemReader; +import org.junit.After; +import org.junit.Before; /** * JUnit TestCase with specialized support for temporary local repository. @@ -90,7 +91,7 @@ import org.eclipse.jgit.util.SystemReader; * a test, or tests may fail altogether if there is insufficient file * descriptors or address space for the test process. */ -public abstract class LocalDiskRepositoryTestCase extends TestCase { +public abstract class LocalDiskRepositoryTestCase { private static Thread shutdownHook; private static int testCount; @@ -110,9 +111,8 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { private MockSystemReader mockSystemReader; - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { synchronized(this) { if (shutdownHook == null) { @@ -131,7 +131,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { Runtime.getRuntime().addShutdownHook(shutdownHook); } } - recursiveDelete(testName(), trash, true, false); + recursiveDelete(testId(), trash, true, false); mockSystemReader = new MockSystemReader(); mockSystemReader.userGitConfig = new FileBasedConfig(new File(trash, @@ -174,8 +174,8 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { return stringBuilder.toString(); } - @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { RepositoryCache.clear(); for (Repository r : toClose) r.close(); @@ -188,8 +188,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { if (useMMAP) System.gc(); - recursiveDelete(testName(), trash, false, true); - super.tearDown(); + recursiveDelete(testId(), trash, false, true); } /** Increment the {@link #author} and {@link #committer} times. */ @@ -210,7 +209,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { * the recursively directory to delete, if present. */ protected void recursiveDelete(final File dir) { - recursiveDelete(testName(), dir, false, true); + recursiveDelete(testId(), dir, false, true); } private static boolean recursiveDelete(final String testName, @@ -414,10 +413,6 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { return new String(body, 0, body.length, "UTF-8"); } - protected static void assertEquals(AnyObjectId exp, AnyObjectId act) { - Assert.assertEquals(exp, act); - } - private static String[] toEnvArray(final Map<String, String> env) { final String[] envp = new String[env.size()]; int i = 0; @@ -431,7 +426,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { return new HashMap<String, String>(System.getenv()); } - private String testName() { - return getClass().getName() + "." + getName(); + private String testId() { + return getClass().getName() + "." + testCount; } } |