BundleWriterTest: Open RevWalk in try-with-resource

Change-Id: Ie25770a73b19d6522bad9fdc0966f48370f96265
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
David Pursehouse 2016-01-21 19:13:04 +09:00
parent 2a7b3ff00b
commit 7e8e4ec019
1 changed files with 19 additions and 17 deletions

View File

@ -126,24 +126,26 @@ public void testIncrementalBundle() throws Exception {
assertNull(newRepo.resolve("refs/heads/a")); assertNull(newRepo.resolve("refs/heads/a"));
// Next an incremental bundle // Next an incremental bundle
bundle = makeBundle("refs/heads/cc", db.resolve("c").name(), try (RevWalk rw = new RevWalk(db)) {
new RevWalk(db).parseCommit(db.resolve("a").toObjectId())); bundle = makeBundle("refs/heads/cc", db.resolve("c").name(),
fetchResult = fetchFromBundle(newRepo, bundle); rw.parseCommit(db.resolve("a").toObjectId()));
advertisedRef = fetchResult.getAdvertisedRef("refs/heads/cc"); fetchResult = fetchFromBundle(newRepo, bundle);
assertEquals(db.resolve("c").name(), advertisedRef.getObjectId().name()); advertisedRef = fetchResult.getAdvertisedRef("refs/heads/cc");
assertEquals(db.resolve("c").name(), newRepo.resolve("refs/heads/cc") assertEquals(db.resolve("c").name(), advertisedRef.getObjectId().name());
.name()); assertEquals(db.resolve("c").name(), newRepo.resolve("refs/heads/cc")
assertNull(newRepo.resolve("refs/heads/c")); .name());
assertNull(newRepo.resolve("refs/heads/a")); // still unknown assertNull(newRepo.resolve("refs/heads/c"));
assertNull(newRepo.resolve("refs/heads/a")); // still unknown
try { try {
// Check that we actually needed the first bundle // Check that we actually needed the first bundle
Repository newRepo2 = createBareRepository(); Repository newRepo2 = createBareRepository();
fetchResult = fetchFromBundle(newRepo2, bundle); fetchResult = fetchFromBundle(newRepo2, bundle);
fail("We should not be able to fetch from bundle with prerequisites that are not fulfilled"); fail("We should not be able to fetch from bundle with prerequisites that are not fulfilled");
} catch (MissingBundlePrerequisiteException e) { } catch (MissingBundlePrerequisiteException e) {
assertTrue(e.getMessage() assertTrue(e.getMessage()
.indexOf(db.resolve("refs/heads/a").name()) >= 0); .indexOf(db.resolve("refs/heads/a").name()) >= 0);
}
} }
} }