summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMathias Kinzler2010-11-05 07:26:56 (EDT)
committer Mathias Kinzler2010-11-05 07:26:56 (EDT)
commitaf31a97c82eb1a213fbc853daf9e9cab68bceccb (patch)
tree2392b3807fa1e72cc3093528c921a9799356150a
parent009507ca2eafe1c6218ca3779348452495dcd3a3 (diff)
downloadjgit-af31a97c82eb1a213fbc853daf9e9cab68bceccb.zip
jgit-af31a97c82eb1a213fbc853daf9e9cab68bceccb.tar.gz
jgit-af31a97c82eb1a213fbc853daf9e9cab68bceccb.tar.bz2
CommitAndLogCommandTests: add a test for LogCommand.addRange()refs/changes/65/1865/1
There were also some compiler warning due to empty catch blocks that were fixed. Change-Id: I165bcddcdfacd34f020d1b938a41954916eb106e Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
index 9106cc2..3d7f779 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
@@ -53,6 +53,8 @@ import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
+import org.eclipse.jgit.errors.IncorrectObjectTypeException;
+import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.UnmergedPathException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -105,6 +107,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
git.commit().setAuthor(author).call();
fail("Didn't get the expected exception");
} catch (NoMessageException e) {
+ // expected
}
}
@@ -122,6 +125,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
commitCmd.setAuthor(author);
fail("didn't catch the expected exception");
} catch (IllegalStateException e) {
+ // expected
}
LogCommand logCmd = git.log();
logCmd.call();
@@ -130,6 +134,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
logCmd.call();
fail("didn't catch the expected exception");
} catch (IllegalStateException e) {
+ // expected
}
}
@@ -191,4 +196,39 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
assertEquals("db00fd65b218578127ea51f3dffac701f12f486a",
tw.getObjectId(0).getName());
}
+
+ public void testCommitRange() throws NoHeadException, NoMessageException,
+ UnmergedPathException, ConcurrentRefUpdateException,
+ JGitInternalException, WrongRepositoryStateException,
+ IncorrectObjectTypeException, MissingObjectException {
+ // do 4 commits and set the range to the second and fourth one
+ Git git = new Git(db);
+ git.commit().setMessage("first commit").call();
+ RevCommit second = git.commit().setMessage("second commit")
+ .setCommitter(committer).call();
+ git.commit().setMessage("third commit").setAuthor(author).call();
+ RevCommit last = git.commit().setMessage("fourth commit").setAuthor(
+ author)
+ .setCommitter(committer).call();
+ Iterable<RevCommit> commits = git.log().addRange(second.getId(),
+ last.getId()).call();
+
+ // check that we have the third and fourth commit
+ PersonIdent defaultCommitter = new PersonIdent(db);
+ PersonIdent expectedAuthors[] = new PersonIdent[] { author, author };
+ PersonIdent expectedCommitters[] = new PersonIdent[] {
+ defaultCommitter, committer };
+ String expectedMessages[] = new String[] { "third commit",
+ "fourth commit" };
+ int l = expectedAuthors.length - 1;
+ for (RevCommit c : commits) {
+ assertEquals(expectedAuthors[l].getName(), c.getAuthorIdent()
+ .getName());
+ assertEquals(expectedCommitters[l].getName(), c.getCommitterIdent()
+ .getName());
+ assertEquals(c.getFullMessage(), expectedMessages[l]);
+ l--;
+ }
+ assertEquals(l, -1);
+ }
}