RacyGitTests: Open NameConflictTreeWalk in try-with-resource

Change-Id: Ic17b05fd7d056761b352168de97efb607a289276
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
David Pursehouse 2016-02-12 13:50:54 +09:00
parent 3adea9ac7f
commit 83f1f8fc7c
1 changed files with 36 additions and 32 deletions

View File

@ -82,7 +82,7 @@ public void testIterator() throws IllegalStateException, IOException,
}
FileTreeIteratorWithTimeControl fileIt = new FileTreeIteratorWithTimeControl(
db, modTimes);
NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
try (NameConflictTreeWalk tw = new NameConflictTreeWalk(db)) {
tw.addTree(fileIt);
tw.setRecursive(true);
FileTreeIterator t;
@ -90,11 +90,12 @@ public void testIterator() throws IllegalStateException, IOException,
for (int i = 0; i < 10; i++) {
assertTrue(tw.next());
t = tw.getTree(0, FileTreeIterator.class);
if (i == 0)
if (i == 0) {
t0 = t.getEntryLastModified();
else
} else {
assertEquals(t0, t.getEntryLastModified());
}
}
long t1 = 0;
for (int i = 0; i < 10; i++) {
assertTrue(tw.next());
@ -102,9 +103,10 @@ public void testIterator() throws IllegalStateException, IOException,
if (i == 0) {
t1 = t.getEntryLastModified();
assertTrue(t1 > t0);
} else
} else {
assertEquals(t1, t.getEntryLastModified());
}
}
long t2 = 0;
for (int i = 0; i < 10; i++) {
assertTrue(tw.next());
@ -112,10 +114,12 @@ public void testIterator() throws IllegalStateException, IOException,
if (i == 0) {
t2 = t.getEntryLastModified();
assertTrue(t2 > t1);
} else
} else {
assertEquals(t2, t.getEntryLastModified());
}
}
}
}
public void testRacyGitDetection() throws IOException,
IllegalStateException, InterruptedException {