Browse Source

RevCommitListTest: Open Git and RevWalk in try-with-resource

Change-Id: I4ba273a364a12f82a3b3b06ba050bc633411daf6
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
3c4e7c08a7
  1. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitListTest.java

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitListTest.java

@ -57,15 +57,16 @@ public class RevCommitListTest extends RepositoryTestCase {
private RevCommitList<RevCommit> list;
public void setup(int count) throws Exception {
Git git = new Git(db);
try (Git git = new Git(db);
RevWalk w = new RevWalk(db);) {
for (int i = 0; i < count; i++)
git.commit().setCommitter(committer).setAuthor(author)
.setMessage("commit " + i).call();
list = new RevCommitList<RevCommit>();
RevWalk w = new RevWalk(db);
w.markStart(w.lookupCommit(db.resolve(Constants.HEAD)));
list.source(w);
}
}
@Test
public void testFillToHighMark2() throws Exception {
@ -107,7 +108,7 @@ public class RevCommitListTest extends RepositoryTestCase {
public void testFillToCommit() throws Exception {
setup(3);
RevWalk w = new RevWalk(db);
try (RevWalk w = new RevWalk(db)) {
w.markStart(w.lookupCommit(db.resolve(Constants.HEAD)));
w.next();
@ -119,6 +120,7 @@ public class RevCommitListTest extends RepositoryTestCase {
assertEquals("commit 1", list.get(1).getFullMessage());
assertNull(list.get(3));
}
}
@Test
public void testFillToUnknownCommit() throws Exception {

Loading…
Cancel
Save