aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2010-12-31 11:44:54 +0100
committerShawn O. Pearce <spearce@spearce.org>2010-12-31 14:00:05 -0800
commitd9e07a574a946693e491668e0d94619bc5d886a5 (patch)
tree5bce4e9d47090d6b427986de4db30be17cc99c6d /org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
parent7cf8b8812f7baa1636c138113f4ed015eed8cc31 (diff)
downloadjgit-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/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java29
1 files changed, 24 insertions, 5 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
index da25f8d632..52da69ef52 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
@@ -43,16 +43,21 @@
package org.eclipse.jgit.treewalk;
-import java.io.ByteArrayOutputStream;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
-import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.util.RawParseUtils;
+import org.junit.Before;
+import org.junit.Test;
-public class CanonicalTreeParserTest extends TestCase {
+public class CanonicalTreeParserTest {
private final CanonicalTreeParser ctp = new CanonicalTreeParser();
private final FileMode m644 = FileMode.REGULAR_FILE;
@@ -74,9 +79,8 @@ public class CanonicalTreeParserTest extends TestCase {
private byte[] tree3;
+ @Before
public void setUp() throws Exception {
- super.setUp();
-
tree1 = mktree(entry(m644, "a", hash_a));
tree2 = mktree(entry(m644, "a", hash_a), entry(m644, "foo", hash_foo));
tree3 = mktree(entry(m644, "a", hash_a), entry(mt, "b_sometree",
@@ -106,11 +110,13 @@ public class CanonicalTreeParserTest extends TestCase {
ctp.pathOffset, ctp.pathLen);
}
+ @Test
public void testEmptyTree_AtEOF() throws Exception {
ctp.reset(new byte[0]);
assertTrue(ctp.eof());
}
+ @Test
public void testOneEntry_Forward() throws Exception {
ctp.reset(tree1);
@@ -125,6 +131,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertTrue(ctp.eof());
}
+ @Test
public void testTwoEntries_ForwardOneAtATime() throws Exception {
ctp.reset(tree2);
@@ -145,24 +152,28 @@ public class CanonicalTreeParserTest extends TestCase {
assertTrue(ctp.eof());
}
+ @Test
public void testOneEntry_Seek1IsEOF() throws Exception {
ctp.reset(tree1);
ctp.next(1);
assertTrue(ctp.eof());
}
+ @Test
public void testTwoEntries_Seek2IsEOF() throws Exception {
ctp.reset(tree2);
ctp.next(2);
assertTrue(ctp.eof());
}
+ @Test
public void testThreeEntries_Seek3IsEOF() throws Exception {
ctp.reset(tree3);
ctp.next(3);
assertTrue(ctp.eof());
}
+ @Test
public void testThreeEntries_Seek2() throws Exception {
ctp.reset(tree3);
@@ -177,6 +188,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertTrue(ctp.eof());
}
+ @Test
public void testOneEntry_Backwards() throws Exception {
ctp.reset(tree1);
ctp.next(1);
@@ -191,6 +203,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertEquals(hash_a, ctp.getEntryObjectId());
}
+ @Test
public void testTwoEntries_BackwardsOneAtATime() throws Exception {
ctp.reset(tree2);
ctp.next(2);
@@ -209,6 +222,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertEquals(hash_a, ctp.getEntryObjectId());
}
+ @Test
public void testTwoEntries_BackwardsTwo() throws Exception {
ctp.reset(tree2);
ctp.next(2);
@@ -230,6 +244,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertTrue(ctp.eof());
}
+ @Test
public void testThreeEntries_BackwardsTwo() throws Exception {
ctp.reset(tree3);
ctp.next(3);
@@ -251,6 +266,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertTrue(ctp.eof());
}
+ @Test
public void testBackwards_ConfusingPathName() throws Exception {
final String aVeryConfusingName = "confusing 644 entry 755 and others";
ctp.reset(mktree(entry(m644, "a", hash_a), entry(mt, aVeryConfusingName,
@@ -271,6 +287,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertEquals(hash_a, ctp.getEntryObjectId());
}
+ @Test
public void testBackwords_Prebuilts1() throws Exception {
// What is interesting about this test is the ObjectId for the
// "darwin-x86" path entry ends in an octal digit (37 == '7').
@@ -305,6 +322,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertEquals(windows, ctp.getEntryObjectId());
}
+ @Test
public void testBackwords_Prebuilts2() throws Exception {
// What is interesting about this test is the ObjectId for the
// "darwin-x86" path entry ends in an octal digit (37 == '7').
@@ -339,6 +357,7 @@ public class CanonicalTreeParserTest extends TestCase {
assertEquals(windows, ctp.getEntryObjectId());
}
+ @Test
public void testFreakingHugePathName() throws Exception {
final int n = AbstractTreeIterator.DEFAULT_PATH_SIZE * 4;
final StringBuilder b = new StringBuilder(n);