diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-12-31 11:44:54 +0100 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-12-31 14:00:05 -0800 |
commit | d9e07a574a946693e491668e0d94619bc5d886a5 (patch) | |
tree | 5bce4e9d47090d6b427986de4db30be17cc99c6d /org.eclipse.jgit.test/exttst/org | |
parent | 7cf8b8812f7baa1636c138113f4ed015eed8cc31 (diff) | |
download | jgit-d9e07a574a946693e491668e0d94619bc5d886a5.tar.gz jgit-d9e07a574a946693e491668e0d94619bc5d886a5.zip |
Convert all JGit unit tests to JUnit 4
Eclipse has some problem re-running single JUnit tests if
the tests are in Junit 3 format, but the JUnit 4 launcher
is used. This was quite unnecessary and the move was not
completed. We still have no JUnit4 test.
This completes the extermination of JUnit3. Most of the
work was global searce/replace using regular expression,
followed by numerous invocarions of quick-fix and organize
imports and verification that we had the same number of
tests before and after.
- Annotations were introduced.
- All references to JUnit3 classes removed
- Half-good replacement for getting the test name. This was
needed to make the TestRngs work. The initialization of
TestRngs was also made lazily since we can not longer find
out the test name in runtime in the @Before methods.
- Renamed test classes to end with Test, with the exception
of TestTranslateBundle, which fails from Maven
- Moved JGitTestUtil to the junit support bundle
Change-Id: Iddcd3da6ca927a7be773a9c63ebf8bb2147e2d13
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/exttst/org')
-rw-r--r-- | org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java | 21 | ||||
-rw-r--r-- | org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java | 11 |
2 files changed, 28 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java index c5591b9bfd..4c59d5a949 100644 --- a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java +++ b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java @@ -44,6 +44,11 @@ package org.eclipse.jgit.lib; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -53,6 +58,8 @@ import java.lang.reflect.Method; import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; import org.eclipse.jgit.lib.GitIndex.Entry; import org.eclipse.jgit.util.FS; +import org.junit.Before; +import org.junit.Test; public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { @@ -113,12 +120,14 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { private File trash; @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); db = createWorkRepository(); trash = db.getWorkTree(); } + @Test public void testCreateEmptyIndex() throws Exception { GitIndex index = new GitIndex(db); index.write(); @@ -130,12 +139,14 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals(0, indexr.getMembers().length); } + @Test public void testReadWithNoIndex() throws Exception { GitIndex index = new GitIndex(db); index.read(); assertEquals(0, index.getMembers().length); } + @Test public void testCreateSimpleSortTestIndex() throws Exception { GitIndex index = new GitIndex(db); writeTrashFile("a/b", "data:a/b"); @@ -163,6 +174,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals(0, system(trash, "git status")); } + @Test public void testUpdateSimpleSortTestIndex() throws Exception { GitIndex index = new GitIndex(db); writeTrashFile("a/b", "data:a/b"); @@ -178,6 +190,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals(0, system(trash, "git status")); } + @Test public void testWriteTree() throws Exception { GitIndex index = new GitIndex(db); writeTrashFile("a/b", "data:a/b"); @@ -198,6 +211,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals(0, system(trash, "git status")); } + @Test public void testReadTree() throws Exception { // Prepare tree GitIndex index = new GitIndex(db); @@ -236,6 +250,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals(0, system(trash, "git status")); } + @Test public void testReadTree2() throws Exception { // Prepare a larger tree to test some odd cases in tree writing GitIndex index = new GitIndex(db); @@ -281,6 +296,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals("a:b", membersr[5].getName()); } + @Test public void testDelete() throws Exception { GitIndex index = new GitIndex(db); writeTrashFile("a/b", "data:a/b"); @@ -305,6 +321,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals(0, system(trash, "git status")); } + @Test public void testCheckout() throws Exception { // Prepare tree, remote it and checkout GitIndex index = new GitIndex(db); @@ -336,6 +353,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { assertEquals(0, system(trash, "git status")); } + @Test public void test030_executeBit_coreModeTrue() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Error, Exception { if (!FS.DETECTED.supportsExecute()) { System.err.println("Test ignored since platform FS does not support the execute permission"); @@ -391,6 +409,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { } } + @Test public void test031_executeBit_coreModeFalse() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Error, Exception { if (!FS.DETECTED.supportsExecute()) { System.err.println("Test ignored since platform FS does not support the execute permission"); diff --git a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java index ff442b6188..dc5821b5cc 100644 --- a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java +++ b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java @@ -43,6 +43,11 @@ package org.eclipse.jgit.patch; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -50,14 +55,14 @@ import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.HashSet; -import junit.framework.TestCase; - import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.util.MutableInteger; import org.eclipse.jgit.util.RawParseUtils; import org.eclipse.jgit.util.TemporaryBuffer; +import org.junit.Test; -public class EGitPatchHistoryTest extends TestCase { +public class EGitPatchHistoryTest { + @Test public void testParseHistory() throws Exception { final NumStatReader numstat = new NumStatReader(); numstat.read(); |