diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-01-21 19:13:04 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-01-21 19:13:23 +0900 |
commit | 7e8e4ec019f4ca4d9a1892c7c882eba6013fdeaa (patch) | |
tree | c06561981218b437113e67b369a46336fc7de14f | |
parent | 2a7b3ff00b2a6ae3b0b91159b9cc872cb9392b18 (diff) | |
download | jgit-7e8e4ec019f4ca4d9a1892c7c882eba6013fdeaa.tar.gz jgit-7e8e4ec019f4ca4d9a1892c7c882eba6013fdeaa.zip |
BundleWriterTest: Open RevWalk in try-with-resource
Change-Id: Ie25770a73b19d6522bad9fdc0966f48370f96265
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java index ba89d2d616..461530896d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java @@ -126,24 +126,26 @@ public class BundleWriterTest extends SampleDataRepositoryTestCase { assertNull(newRepo.resolve("refs/heads/a")); // Next an incremental bundle - bundle = makeBundle("refs/heads/cc", db.resolve("c").name(), - new RevWalk(db).parseCommit(db.resolve("a").toObjectId())); - fetchResult = fetchFromBundle(newRepo, bundle); - advertisedRef = fetchResult.getAdvertisedRef("refs/heads/cc"); - assertEquals(db.resolve("c").name(), advertisedRef.getObjectId().name()); - assertEquals(db.resolve("c").name(), newRepo.resolve("refs/heads/cc") - .name()); - assertNull(newRepo.resolve("refs/heads/c")); - assertNull(newRepo.resolve("refs/heads/a")); // still unknown - - try { - // Check that we actually needed the first bundle - Repository newRepo2 = createBareRepository(); - fetchResult = fetchFromBundle(newRepo2, bundle); - fail("We should not be able to fetch from bundle with prerequisites that are not fulfilled"); - } catch (MissingBundlePrerequisiteException e) { - assertTrue(e.getMessage() - .indexOf(db.resolve("refs/heads/a").name()) >= 0); + try (RevWalk rw = new RevWalk(db)) { + bundle = makeBundle("refs/heads/cc", db.resolve("c").name(), + rw.parseCommit(db.resolve("a").toObjectId())); + fetchResult = fetchFromBundle(newRepo, bundle); + advertisedRef = fetchResult.getAdvertisedRef("refs/heads/cc"); + assertEquals(db.resolve("c").name(), advertisedRef.getObjectId().name()); + assertEquals(db.resolve("c").name(), newRepo.resolve("refs/heads/cc") + .name()); + assertNull(newRepo.resolve("refs/heads/c")); + assertNull(newRepo.resolve("refs/heads/a")); // still unknown + + try { + // Check that we actually needed the first bundle + Repository newRepo2 = createBareRepository(); + fetchResult = fetchFromBundle(newRepo2, bundle); + fail("We should not be able to fetch from bundle with prerequisites that are not fulfilled"); + } catch (MissingBundlePrerequisiteException e) { + assertTrue(e.getMessage() + .indexOf(db.resolve("refs/heads/a").name()) >= 0); + } } } |