diff options
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk')
18 files changed, 243 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/AlwaysEmptyRevQueueTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/AlwaysEmptyRevQueueTest.java index d752501c12..366e0ccec1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/AlwaysEmptyRevQueueTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/AlwaysEmptyRevQueueTest.java @@ -43,9 +43,18 @@ package org.eclipse.jgit.revwalk; +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 static org.junit.Assert.fail; + +import org.junit.Test; + public class AlwaysEmptyRevQueueTest extends RevWalkTestCase { private final AbstractRevQueue q = AbstractRevQueue.EMPTY_QUEUE; + @Test public void testEmpty() throws Exception { assertNull(q.next()); assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING)); @@ -53,11 +62,13 @@ public class AlwaysEmptyRevQueueTest extends RevWalkTestCase { assertEquals(0, q.outputType()); } + @Test public void testClear() throws Exception { q.clear(); testEmpty(); } + @Test public void testAddFails() throws Exception { try { q.add(commit()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/DateRevQueueTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/DateRevQueueTest.java index ee9c81cbdd..766a279867 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/DateRevQueueTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/DateRevQueueTest.java @@ -43,22 +43,31 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + public class DateRevQueueTest extends RevQueueTestCase<DateRevQueue> { protected DateRevQueue create() { return new DateRevQueue(); } + @Test public void testEmpty() throws Exception { super.testEmpty(); assertNull(q.peek()); assertEquals(Generator.SORT_COMMIT_TIME_DESC, q.outputType()); } + @Test public void testCloneEmpty() throws Exception { q = new DateRevQueue(AbstractRevQueue.EMPTY_QUEUE); assertNull(q.next()); } + @Test public void testInsertOutOfOrder() throws Exception { final RevCommit a = parseBody(commit()); final RevCommit b = parseBody(commit(10, a)); @@ -77,6 +86,7 @@ public class DateRevQueueTest extends RevQueueTestCase<DateRevQueue> { assertNull(q.next()); } + @Test public void testInsertTie() throws Exception { final RevCommit a = parseBody(commit()); final RevCommit b = parseBody(commit(0, a)); @@ -100,6 +110,7 @@ public class DateRevQueueTest extends RevQueueTestCase<DateRevQueue> { } } + @Test public void testCloneFIFO() throws Exception { final RevCommit a = parseBody(commit()); final RevCommit b = parseBody(commit(200, a)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FIFORevQueueTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FIFORevQueueTest.java index 3f4daab9f6..8877c380dc 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FIFORevQueueTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FIFORevQueueTest.java @@ -43,23 +43,32 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + import java.util.ArrayList; +import org.junit.Test; + public class FIFORevQueueTest extends RevQueueTestCase<FIFORevQueue> { protected FIFORevQueue create() { return new FIFORevQueue(); } + @Test public void testEmpty() throws Exception { super.testEmpty(); assertEquals(0, q.outputType()); } + @Test public void testCloneEmpty() throws Exception { q = new FIFORevQueue(AbstractRevQueue.EMPTY_QUEUE); assertNull(q.next()); } + @Test public void testAddLargeBlocks() throws Exception { final ArrayList<RevCommit> lst = new ArrayList<RevCommit>(); for (int i = 0; i < 3 * BlockRevQueue.Block.BLOCK_SIZE; i++) { @@ -71,6 +80,7 @@ public class FIFORevQueueTest extends RevQueueTestCase<FIFORevQueue> { assertSame(lst.get(i), q.next()); } + @Test public void testUnpopAtFront() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FooterLineTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FooterLineTest.java index 9538a06b48..7f440df22a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FooterLineTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FooterLineTest.java @@ -43,13 +43,21 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.List; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.RepositoryTestCase; +import org.junit.Test; public class FooterLineTest extends RepositoryTestCase { + @Test public void testNoFooters_EmptyBody() { final RevCommit commit = parse(""); final List<FooterLine> footers = commit.getFooterLines(); @@ -57,6 +65,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals(0, footers.size()); } + @Test public void testNoFooters_NewlineOnlyBody1() { final RevCommit commit = parse("\n"); final List<FooterLine> footers = commit.getFooterLines(); @@ -64,6 +73,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals(0, footers.size()); } + @Test public void testNoFooters_NewlineOnlyBody5() { final RevCommit commit = parse("\n\n\n\n\n"); final List<FooterLine> footers = commit.getFooterLines(); @@ -71,6 +81,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals(0, footers.size()); } + @Test public void testNoFooters_OneLineBodyNoLF() { final RevCommit commit = parse("this is a commit"); final List<FooterLine> footers = commit.getFooterLines(); @@ -78,6 +89,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals(0, footers.size()); } + @Test public void testNoFooters_OneLineBodyWithLF() { final RevCommit commit = parse("this is a commit\n"); final List<FooterLine> footers = commit.getFooterLines(); @@ -85,6 +97,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals(0, footers.size()); } + @Test public void testNoFooters_ShortBodyNoLF() { final RevCommit commit = parse("subject\n\nbody of commit"); final List<FooterLine> footers = commit.getFooterLines(); @@ -92,6 +105,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals(0, footers.size()); } + @Test public void testNoFooters_ShortBodyWithLF() { final RevCommit commit = parse("subject\n\nbody of commit\n"); final List<FooterLine> footers = commit.getFooterLines(); @@ -99,6 +113,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals(0, footers.size()); } + @Test public void testSignedOffBy_OneUserNoLF() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "\n" + "Signed-off-by: A. U. Thor <a@example.com>"); @@ -114,6 +129,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals("a@example.com", f.getEmailAddress()); } + @Test public void testSignedOffBy_OneUserWithLF() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "\n" + "Signed-off-by: A. U. Thor <a@example.com>\n"); @@ -129,6 +145,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals("a@example.com", f.getEmailAddress()); } + @Test public void testSignedOffBy_IgnoreWhitespace() { // We only ignore leading whitespace on the value, trailing // is assumed part of the value. @@ -147,6 +164,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals("a@example.com", f.getEmailAddress()); } + @Test public void testEmptyValueNoLF() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "\n" + "Signed-off-by:"); @@ -162,6 +180,7 @@ public class FooterLineTest extends RepositoryTestCase { assertNull(f.getEmailAddress()); } + @Test public void testEmptyValueWithLF() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "\n" + "Signed-off-by:\n"); @@ -177,6 +196,7 @@ public class FooterLineTest extends RepositoryTestCase { assertNull(f.getEmailAddress()); } + @Test public void testShortKey() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "\n" + "K:V\n"); @@ -192,6 +212,7 @@ public class FooterLineTest extends RepositoryTestCase { assertNull(f.getEmailAddress()); } + @Test public void testNonDelimtedEmail() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "\n" + "Acked-by: re@example.com\n"); @@ -207,6 +228,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals("re@example.com", f.getEmailAddress()); } + @Test public void testNotEmail() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "\n" + "Acked-by: Main Tain Er\n"); @@ -222,6 +244,7 @@ public class FooterLineTest extends RepositoryTestCase { assertNull(f.getEmailAddress()); } + @Test public void testSignedOffBy_ManyUsers() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "Not-A-Footer-Line: this line must not be read as a footer\n" @@ -257,6 +280,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals("mte@example.com", f.getEmailAddress()); } + @Test public void testSignedOffBy_SkipNonFooter() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "Not-A-Footer-Line: this line must not be read as a footer\n" @@ -289,6 +313,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals("Main Tain Er <mte@example.com>", f.getValue()); } + @Test public void testFilterFootersIgnoreCase() { final RevCommit commit = parse("subject\n\nbody of commit\n" + "Not-A-Footer-Line: this line must not be read as a footer\n" @@ -306,6 +331,7 @@ public class FooterLineTest extends RepositoryTestCase { assertEquals("Main Tain Er <mte@example.com>", footers.get(1)); } + @Test public void testMatchesBugId() { final RevCommit commit = parse("this is a commit subject for test\n" + "\n" // paragraph break, now footers appear in final block diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/LIFORevQueueTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/LIFORevQueueTest.java index 7676a71503..1b2c5e2f6a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/LIFORevQueueTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/LIFORevQueueTest.java @@ -43,24 +43,33 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + import java.util.ArrayList; import java.util.Collections; +import org.junit.Test; + public class LIFORevQueueTest extends RevQueueTestCase<LIFORevQueue> { protected LIFORevQueue create() { return new LIFORevQueue(); } + @Test public void testEmpty() throws Exception { super.testEmpty(); assertEquals(0, q.outputType()); } + @Test public void testCloneEmpty() throws Exception { q = new LIFORevQueue(AbstractRevQueue.EMPTY_QUEUE); assertNull(q.next()); } + @Test public void testAddLargeBlocks() throws Exception { final ArrayList<RevCommit> lst = new ArrayList<RevCommit>(); for (int i = 0; i < 3 * BlockRevQueue.Block.BLOCK_SIZE; i++) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java index 840bee8466..f183e02987 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java @@ -43,11 +43,16 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileTreeEntry; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.Tree; +import org.junit.Test; public class ObjectWalkTest extends RevWalkTestCase { protected ObjectWalk objw; @@ -57,11 +62,13 @@ public class ObjectWalkTest extends RevWalkTestCase { return objw = new ObjectWalk(db); } + @Test public void testNoCommits() throws Exception { assertNull(objw.next()); assertNull(objw.nextObject()); } + @Test public void testTwoCommitsEmptyTree() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -75,6 +82,7 @@ public class ObjectWalkTest extends RevWalkTestCase { assertNull(objw.nextObject()); } + @Test public void testOneCommitOneTreeTwoBlob() throws Exception { final RevBlob f0 = blob("0"); final RevBlob f1 = blob("1"); @@ -91,6 +99,7 @@ public class ObjectWalkTest extends RevWalkTestCase { assertNull(objw.nextObject()); } + @Test public void testTwoCommitTwoTreeTwoBlob() throws Exception { final RevBlob f0 = blob("0"); final RevBlob f1 = blob("1"); @@ -115,6 +124,7 @@ public class ObjectWalkTest extends RevWalkTestCase { assertNull(objw.nextObject()); } + @Test public void testTwoCommitDeepTree1() throws Exception { final RevBlob f0 = blob("0"); final RevBlob f1 = blob("0v2"); @@ -141,6 +151,7 @@ public class ObjectWalkTest extends RevWalkTestCase { assertNull(objw.nextObject()); } + @Test public void testTwoCommitDeepTree2() throws Exception { final RevBlob f1 = blob("1"); final RevTree ta = tree(file("a/b/0", f1), file("a/c/q", f1)); @@ -166,6 +177,7 @@ public class ObjectWalkTest extends RevWalkTestCase { assertNull(objw.nextObject()); } + @Test public void testCull() throws Exception { final RevBlob f1 = blob("1"); final RevBlob f2 = blob("2"); @@ -201,6 +213,7 @@ public class ObjectWalkTest extends RevWalkTestCase { assertNull(objw.nextObject()); } + @Test public void testEmptyTreeCorruption() throws Exception { ObjectId bId = ObjectId .fromString("abbbfafe3129f85747aba7bfac992af77134c607"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java index 2f27847347..02a78a5baf 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java @@ -43,6 +43,11 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.util.TimeZone; @@ -53,8 +58,10 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.RepositoryTestCase; +import org.junit.Test; public class RevCommitParseTest extends RepositoryTestCase { + @Test public void testParse_NoParents() throws Exception { final ObjectId treeId = id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); final String authorName = "A U. Thor"; @@ -139,6 +146,7 @@ public class RevCommitParseTest extends RepositoryTestCase { return c; } + @Test public void testParse_WeirdHeaderOnlyCommit() throws Exception { final StringBuilder b = new StringBuilder(); b.append("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"); @@ -153,6 +161,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals("", c.getShortMessage()); } + @Test public void testParse_implicit_UTF8_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); @@ -172,6 +181,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); } + @Test public void testParse_implicit_mixed_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); @@ -196,6 +206,7 @@ public class RevCommitParseTest extends RepositoryTestCase { * * @throws Exception */ + @Test public void testParse_explicit_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("EUC-JP")); @@ -225,6 +236,7 @@ public class RevCommitParseTest extends RepositoryTestCase { * * @throws Exception */ + @Test public void testParse_explicit_bad_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); @@ -255,6 +267,7 @@ public class RevCommitParseTest extends RepositoryTestCase { * * @throws Exception */ + @Test public void testParse_explicit_bad_encoded2() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); @@ -275,6 +288,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage()); } + @Test public void testParse_NoMessage() throws Exception { final String msg = ""; final RevCommit c = create(msg); @@ -282,12 +296,14 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals(msg, c.getShortMessage()); } + @Test public void testParse_OnlyLFMessage() throws Exception { final RevCommit c = create("\n"); assertEquals("\n", c.getFullMessage()); assertEquals("", c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyNoLF() throws Exception { final String shortMsg = "This is a short message."; final RevCommit c = create(shortMsg); @@ -295,6 +311,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyEndLF() throws Exception { final String shortMsg = "This is a short message."; final String fullMsg = shortMsg + "\n"; @@ -303,6 +320,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyEmbeddedLF() throws Exception { final String fullMsg = "This is a\nshort message."; final String shortMsg = fullMsg.replace('\n', ' '); @@ -311,6 +329,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyEmbeddedAndEndingLF() throws Exception { final String fullMsg = "This is a\nshort message.\n"; final String shortMsg = "This is a short message."; @@ -319,6 +338,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_GitStyleMessage() throws Exception { final String shortMsg = "This fixes a bug."; final String body = "We do it with magic and pixie dust and stuff.\n" @@ -329,6 +349,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_PublicParseMethod() throws UnsupportedEncodingException { ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java index 13f1cfc4cc..021795eef4 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java @@ -43,10 +43,19 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.Iterator; +import org.junit.Test; + public class RevFlagSetTest extends RevWalkTestCase { + @Test public void testEmpty() { final RevFlagSet set = new RevFlagSet(); assertEquals(0, set.mask); @@ -55,6 +64,7 @@ public class RevFlagSetTest extends RevWalkTestCase { assertFalse(set.iterator().hasNext()); } + @Test public void testAddOne() { final String flagName = "flag"; final RevFlag flag = rw.newFlag(flagName); @@ -72,6 +82,7 @@ public class RevFlagSetTest extends RevWalkTestCase { assertFalse(i.hasNext()); } + @Test public void testAddTwo() { final RevFlag flag1 = rw.newFlag("flag_1"); final RevFlag flag2 = rw.newFlag("flag_2"); @@ -84,6 +95,7 @@ public class RevFlagSetTest extends RevWalkTestCase { assertEquals(2, set.size()); } + @Test public void testContainsAll() { final RevFlag flag1 = rw.newFlag("flag_1"); final RevFlag flag2 = rw.newFlag("flag_2"); @@ -100,6 +112,7 @@ public class RevFlagSetTest extends RevWalkTestCase { assertFalse(set1.containsAll(set2)); } + @Test public void testEquals() { final RevFlag flag1 = rw.newFlag("flag_1"); final RevFlag flag2 = rw.newFlag("flag_2"); @@ -112,6 +125,7 @@ public class RevFlagSetTest extends RevWalkTestCase { .equals(set)); } + @Test public void testRemove() { final RevFlag flag1 = rw.newFlag("flag_1"); final RevFlag flag2 = rw.newFlag("flag_2"); @@ -125,6 +139,7 @@ public class RevFlagSetTest extends RevWalkTestCase { assertFalse(set.contains(flag1)); } + @Test public void testContains() { final RevFlag flag1 = rw.newFlag("flag_1"); final RevFlag flag2 = rw.newFlag("flag_2"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevObjectTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevObjectTest.java index 052d390033..a768bef19e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevObjectTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevObjectTest.java @@ -43,15 +43,24 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; +import org.junit.Test; public class RevObjectTest extends RevWalkTestCase { + @Test public void testId() throws Exception { final RevCommit a = commit(); assertSame(a, a.getId()); } + @Test public void testEquals() throws Exception { final RevCommit a1 = commit(); final RevCommit b1 = commit(); @@ -80,6 +89,7 @@ public class RevObjectTest extends RevWalkTestCase { assertTrue(AnyObjectId.equals(b1, b2)); } + @Test public void testRevObjectTypes() throws Exception { assertEquals(Constants.OBJ_TREE, tree().getType()); assertEquals(Constants.OBJ_COMMIT, commit().getType()); @@ -87,6 +97,7 @@ public class RevObjectTest extends RevWalkTestCase { assertEquals(Constants.OBJ_TAG, tag("emptyTree", tree()).getType()); } + @Test public void testHasRevFlag() throws Exception { final RevCommit a = commit(); assertFalse(a.has(RevFlag.UNINTERESTING)); @@ -94,6 +105,7 @@ public class RevObjectTest extends RevWalkTestCase { assertTrue(a.has(RevFlag.UNINTERESTING)); } + @Test public void testHasAnyFlag() throws Exception { final RevCommit a = commit(); final RevFlag flag1 = rw.newFlag("flag1"); @@ -107,6 +119,7 @@ public class RevObjectTest extends RevWalkTestCase { assertTrue(a.hasAny(s)); } + @Test public void testHasAllFlag() throws Exception { final RevCommit a = commit(); final RevFlag flag1 = rw.newFlag("flag1"); @@ -122,6 +135,7 @@ public class RevObjectTest extends RevWalkTestCase { assertTrue(a.hasAll(s)); } + @Test public void testAddRevFlag() throws Exception { final RevCommit a = commit(); final RevFlag flag1 = rw.newFlag("flag1"); @@ -135,6 +149,7 @@ public class RevObjectTest extends RevWalkTestCase { assertEquals(flag1.mask | flag2.mask, a.flags); } + @Test public void testAddRevFlagSet() throws Exception { final RevCommit a = commit(); final RevFlag flag1 = rw.newFlag("flag1"); @@ -149,6 +164,7 @@ public class RevObjectTest extends RevWalkTestCase { assertEquals(flag1.mask | flag2.mask, a.flags); } + @Test public void testRemoveRevFlag() throws Exception { final RevCommit a = commit(); final RevFlag flag1 = rw.newFlag("flag1"); @@ -160,6 +176,7 @@ public class RevObjectTest extends RevWalkTestCase { assertEquals(flag1.mask, a.flags); } + @Test public void testRemoveRevFlagSet() throws Exception { final RevCommit a = commit(); final RevFlag flag1 = rw.newFlag("flag1"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevQueueTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevQueueTestCase.java index c549054cbb..51cf2f1b30 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevQueueTestCase.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevQueueTestCase.java @@ -43,6 +43,12 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + public abstract class RevQueueTestCase<T extends AbstractRevQueue> extends RevWalkTestCase { protected T q; @@ -54,12 +60,14 @@ public abstract class RevQueueTestCase<T extends AbstractRevQueue> extends protected abstract T create(); + @Test public void testEmpty() throws Exception { assertNull(q.next()); assertTrue(q.everbodyHasFlag(RevWalk.UNINTERESTING)); assertFalse(q.anybodyHasFlag(RevWalk.UNINTERESTING)); } + @Test public void testClear() throws Exception { final RevCommit a = parseBody(commit()); final RevCommit b = parseBody(commit(a)); @@ -70,6 +78,7 @@ public abstract class RevQueueTestCase<T extends AbstractRevQueue> extends assertNull(q.next()); } + @Test public void testHasFlags() throws Exception { final RevCommit a = parseBody(commit()); final RevCommit b = parseBody(commit(a)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java index 9300ae2e1b..c89a2873ad 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java @@ -43,6 +43,11 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + import java.io.ByteArrayOutputStream; import org.eclipse.jgit.errors.CorruptObjectException; @@ -52,20 +57,25 @@ import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.lib.TagBuilder; +import org.junit.Test; public class RevTagParseTest extends RepositoryTestCase { + @Test public void testTagBlob() throws Exception { testOneType(Constants.OBJ_BLOB); } + @Test public void testTagTree() throws Exception { testOneType(Constants.OBJ_TREE); } + @Test public void testTagCommit() throws Exception { testOneType(Constants.OBJ_COMMIT); } + @Test public void testTagTag() throws Exception { testOneType(Constants.OBJ_TAG); } @@ -92,6 +102,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertSame(rw.lookupAny(id, typeCode), c.getObject()); } + @Test public void testParseAllFields() throws Exception { final ObjectId treeId = id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); final String name = "v1.2.3.4.5"; @@ -143,6 +154,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals(taggerEmail, cTagger.getEmailAddress()); } + @Test public void testParseOldStyleNoTagger() throws Exception { final ObjectId treeId = id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); final String name = "v1.2.3.4.5"; @@ -203,6 +215,7 @@ public class RevTagParseTest extends RepositoryTestCase { return c; } + @Test public void testParse_implicit_UTF8_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" @@ -227,6 +240,7 @@ public class RevTagParseTest extends RepositoryTestCase { .getFullMessage()); } + @Test public void testParse_implicit_mixed_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" @@ -255,6 +269,7 @@ public class RevTagParseTest extends RepositoryTestCase { * * @throws Exception */ + @Test public void testParse_explicit_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" @@ -287,6 +302,7 @@ public class RevTagParseTest extends RepositoryTestCase { * * @throws Exception */ + @Test public void testParse_explicit_bad_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" @@ -321,6 +337,7 @@ public class RevTagParseTest extends RepositoryTestCase { * * @throws Exception */ + @Test public void testParse_explicit_bad_encoded2() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" @@ -344,6 +361,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage()); } + @Test public void testParse_NoMessage() throws Exception { final String msg = ""; final RevTag c = create(msg); @@ -351,12 +369,14 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals(msg, c.getShortMessage()); } + @Test public void testParse_OnlyLFMessage() throws Exception { final RevTag c = create("\n"); assertEquals("\n", c.getFullMessage()); assertEquals("", c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyNoLF() throws Exception { final String shortMsg = "This is a short message."; final RevTag c = create(shortMsg); @@ -364,6 +384,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyEndLF() throws Exception { final String shortMsg = "This is a short message."; final String fullMsg = shortMsg + "\n"; @@ -372,6 +393,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyEmbeddedLF() throws Exception { final String fullMsg = "This is a\nshort message."; final String shortMsg = fullMsg.replace('\n', ' '); @@ -380,6 +402,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_ShortLineOnlyEmbeddedAndEndingLF() throws Exception { final String fullMsg = "This is a\nshort message.\n"; final String shortMsg = "This is a short message."; @@ -388,6 +411,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_GitStyleMessage() throws Exception { final String shortMsg = "This fixes a bug."; final String body = "We do it with magic and pixie dust and stuff.\n" @@ -398,6 +422,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertEquals(shortMsg, c.getShortMessage()); } + @Test public void testParse_PublicParseMethod() throws CorruptObjectException { ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); TagBuilder src = new TagBuilder(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCullTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCullTest.java index 9e879c5f0d..fb52828c5b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCullTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCullTest.java @@ -43,7 +43,12 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + public class RevWalkCullTest extends RevWalkTestCase { + @Test public void testProperlyCullAllAncestors1() throws Exception { // Credit goes to Junio C Hamano <gitster@pobox.com> for this // test case in git-core (t/t6009-rev-list-parent.sh) @@ -60,6 +65,7 @@ public class RevWalkCullTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testProperlyCullAllAncestors2() throws Exception { // Despite clock skew on c1 being very old it should not // produce, neither should a or b, or any part of that chain. @@ -77,6 +83,7 @@ public class RevWalkCullTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testProperlyCullAllAncestors_LongHistory() throws Exception { final RevCommit a = commit(); RevCommit b = commit(a); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFilterTest.java index a6421c41d1..dd67a9833a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFilterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFilterTest.java @@ -43,6 +43,9 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.io.IOException; import java.util.Date; @@ -54,10 +57,12 @@ import org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter; import org.eclipse.jgit.revwalk.filter.NotRevFilter; import org.eclipse.jgit.revwalk.filter.OrRevFilter; import org.eclipse.jgit.revwalk.filter.RevFilter; +import org.junit.Test; public class RevWalkFilterTest extends RevWalkTestCase { private static final MyAll MY_ALL = new MyAll(); + @Test public void testFilter_ALL() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -71,6 +76,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_Negate_ALL() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -81,6 +87,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NOT_ALL() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -91,6 +98,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NONE() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -101,6 +109,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NOT_NONE() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -114,6 +123,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_ALL_And_NONE() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -124,6 +134,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NONE_And_ALL() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -134,6 +145,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_ALL_Or_NONE() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -147,6 +159,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NONE_Or_ALL() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -160,6 +173,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_MY_ALL_And_NONE() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -170,6 +184,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NONE_And_MY_ALL() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -180,6 +195,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_MY_ALL_Or_NONE() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -193,6 +209,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NONE_Or_MY_ALL() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -206,6 +223,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testFilter_NO_MERGES() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -224,6 +242,7 @@ public class RevWalkFilterTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testCommitTimeRevFilter() throws Exception { final RevCommit a = commit(); tick(100); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergeBaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergeBaseTest.java index 10c9f9b12e..b5d4909f39 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergeBaseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergeBaseTest.java @@ -43,10 +43,15 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import org.eclipse.jgit.revwalk.filter.RevFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; +import org.junit.Test; public class RevWalkMergeBaseTest extends RevWalkTestCase { + @Test public void testNone() throws Exception { final RevCommit c1 = commit(commit(commit())); final RevCommit c2 = commit(commit(commit())); @@ -57,6 +62,7 @@ public class RevWalkMergeBaseTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testDisallowTreeFilter() throws Exception { final RevCommit c1 = commit(); final RevCommit c2 = commit(); @@ -73,6 +79,7 @@ public class RevWalkMergeBaseTest extends RevWalkTestCase { } } + @Test public void testSimple() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -86,6 +93,7 @@ public class RevWalkMergeBaseTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testMultipleHeads_SameBase1() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -101,6 +109,7 @@ public class RevWalkMergeBaseTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testMultipleHeads_SameBase2() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -117,6 +126,7 @@ public class RevWalkMergeBaseTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testCrissCross() throws Exception { // See http://marc.info/?l=git&m=111463358500362&w=2 for a nice // description of what this test is creating. We don't have a diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java index 986a886566..d2083e6b5b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java @@ -43,11 +43,15 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.Collections; import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.jgit.treewalk.filter.TreeFilter; +import org.junit.Test; public class RevWalkPathFilter1Test extends RevWalkTestCase { protected void filter(final String path) { @@ -56,6 +60,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { TreeFilter.ANY_DIFF)); } + @Test public void testEmpty_EmptyTree() throws Exception { final RevCommit a = commit(); filter("a"); @@ -63,6 +68,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testEmpty_NoMatch() throws Exception { final RevCommit a = commit(tree(file("0", blob("0")))); filter("a"); @@ -70,6 +76,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testSimple1() throws Exception { final RevCommit a = commit(tree(file("0", blob("0")))); filter("0"); @@ -78,6 +85,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testEdits_MatchNone() throws Exception { final RevCommit a = commit(tree(file("0", blob("a")))); final RevCommit b = commit(tree(file("0", blob("b"))), a); @@ -88,6 +96,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testEdits_MatchAll() throws Exception { final RevCommit a = commit(tree(file("0", blob("a")))); final RevCommit b = commit(tree(file("0", blob("b"))), a); @@ -102,6 +111,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testStringOfPearls_FilePath1() throws Exception { final RevCommit a = commit(tree(file("d/f", blob("a")))); final RevCommit b = commit(tree(file("d/f", blob("a"))), a); @@ -118,6 +128,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testStringOfPearls_FilePath2() throws Exception { final RevCommit a = commit(tree(file("d/f", blob("a")))); final RevCommit b = commit(tree(file("d/f", blob("a"))), a); @@ -136,6 +147,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testStringOfPearls_DirPath2() throws Exception { final RevCommit a = commit(tree(file("d/f", blob("a")))); final RevCommit b = commit(tree(file("d/f", blob("a"))), a); @@ -154,6 +166,7 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testStringOfPearls_FilePath3() throws Exception { final RevCommit a = commit(tree(file("d/f", blob("a")))); final RevCommit b = commit(tree(file("d/f", blob("a"))), a); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter6012Test.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter6012Test.java index c4bfbf8819..db19f004d7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter6012Test.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter6012Test.java @@ -43,6 +43,9 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.lang.reflect.Field; import java.util.Collections; import java.util.HashMap; @@ -50,6 +53,8 @@ import java.util.HashMap; import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.jgit.treewalk.filter.TreeFilter; +import org.junit.Before; +import org.junit.Test; // Note: Much of this test case is broken as it depends upon // the graph applying topological sorting *before* doing merge @@ -64,6 +69,7 @@ public class RevWalkPathFilter6012Test extends RevWalkTestCase { private HashMap<RevCommit, String> byName; + @Before public void setUp() throws Exception { super.setUp(); @@ -120,11 +126,13 @@ public class RevWalkPathFilter6012Test extends RevWalkTestCase { TreeFilter.ANY_DIFF)); } + @Test public void test1() throws Exception { // TODO --full-history check(i, h, g, f, e, d, c, b, a); } + @Test public void test2() throws Exception { // TODO --full-history filter(pF); @@ -132,6 +140,7 @@ public class RevWalkPathFilter6012Test extends RevWalkTestCase { // check(i, h, e, c, b, a); } + @Test public void test3() throws Exception { // TODO --full-history rw.sort(RevSort.TOPO); @@ -140,6 +149,7 @@ public class RevWalkPathFilter6012Test extends RevWalkTestCase { // check(i, h, e, c, b, a); } + @Test public void test4() throws Exception { // TODO --full-history rw.sort(RevSort.COMMIT_TIME_DESC); @@ -148,6 +158,7 @@ public class RevWalkPathFilter6012Test extends RevWalkTestCase { // check(i, h, e, c, b, a); } + @Test public void test5() throws Exception { // TODO --simplify-merges filter(pF); @@ -155,11 +166,13 @@ public class RevWalkPathFilter6012Test extends RevWalkTestCase { // check(i, e, c, b, a); } + @Test public void test6() throws Exception { filter(pF); check(i, b, a); } + @Test public void test7() throws Exception { rw.sort(RevSort.TOPO); filter(pF); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkSortTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkSortTest.java index 65ed873bf4..5a1f5a7219 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkSortTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkSortTest.java @@ -43,7 +43,13 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + public class RevWalkSortTest extends RevWalkTestCase { + @Test public void testSort_Default() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(1, a); @@ -58,6 +64,7 @@ public class RevWalkSortTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testSort_COMMIT_TIME_DESC() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -73,6 +80,7 @@ public class RevWalkSortTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testSort_REVERSE() throws Exception { final RevCommit a = commit(); final RevCommit b = commit(a); @@ -88,6 +96,7 @@ public class RevWalkSortTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testSort_COMMIT_TIME_DESC_OutOfOrder1() throws Exception { // Despite being out of order time-wise, a strand-of-pearls must // still maintain topological order. @@ -108,6 +117,7 @@ public class RevWalkSortTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testSort_COMMIT_TIME_DESC_OutOfOrder2() throws Exception { // c1 is back dated before its parent. // @@ -127,6 +137,7 @@ public class RevWalkSortTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testSort_TOPO() throws Exception { // c1 is back dated before its parent. // @@ -146,6 +157,7 @@ public class RevWalkSortTest extends RevWalkTestCase { assertNull(rw.next()); } + @Test public void testSort_TOPO_REVERSE() throws Exception { // c1 is back dated before its parent. // diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkTestCase.java index 9473fe6318..1e05e53cb5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkTestCase.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkTestCase.java @@ -43,6 +43,8 @@ package org.eclipse.jgit.revwalk; +import static org.junit.Assert.assertSame; + import java.util.Date; import org.eclipse.jgit.dircache.DirCacheEntry; |