InterIndexDiffFilterTest: Open TreeWalk in try-with-resource
Change-Id: Ie0046771b1ab1c9784d9a3bb597a9d76c6c3017d Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
parent
6d33322df4
commit
de73fbf597
|
@ -76,11 +76,12 @@ public void setUp() throws Exception {
|
||||||
public void testEmpty() throws IOException {
|
public void testEmpty() throws IOException {
|
||||||
DirCache dc1 = DirCache.newInCore();
|
DirCache dc1 = DirCache.newInCore();
|
||||||
DirCache dc2 = DirCache.newInCore();
|
DirCache dc2 = DirCache.newInCore();
|
||||||
TreeWalk tw = new TreeWalk(db);
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.addTree(new DirCacheIterator(dc1));
|
tw.addTree(new DirCacheIterator(dc1));
|
||||||
tw.addTree(new DirCacheIterator(dc2));
|
tw.addTree(new DirCacheIterator(dc2));
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static final class AddEdit extends PathEdit {
|
static final class AddEdit extends PathEdit {
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ public void testOneOnly() throws IOException {
|
||||||
editor.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
|
editor.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
|
||||||
editor.finish();
|
editor.finish();
|
||||||
|
|
||||||
TreeWalk tw = new TreeWalk(db);
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.addTree(new DirCacheIterator(dc1));
|
tw.addTree(new DirCacheIterator(dc1));
|
||||||
tw.addTree(new DirCacheIterator(dc2));
|
tw.addTree(new DirCacheIterator(dc2));
|
||||||
|
@ -133,6 +134,7 @@ public void testOneOnly() throws IOException {
|
||||||
assertEquals("a/a", tw.getPathString());
|
assertEquals("a/a", tw.getPathString());
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTwoSame() throws IOException {
|
public void testTwoSame() throws IOException {
|
||||||
|
@ -145,7 +147,7 @@ public void testTwoSame() throws IOException {
|
||||||
ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
|
ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
|
||||||
ed2.finish();
|
ed2.finish();
|
||||||
|
|
||||||
TreeWalk tw = new TreeWalk(db);
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.addTree(new DirCacheIterator(dc1));
|
tw.addTree(new DirCacheIterator(dc1));
|
||||||
tw.addTree(new DirCacheIterator(dc2));
|
tw.addTree(new DirCacheIterator(dc2));
|
||||||
|
@ -153,6 +155,7 @@ public void testTwoSame() throws IOException {
|
||||||
|
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTwoSameDifferByAssumeValid() throws IOException {
|
public void testTwoSameDifferByAssumeValid() throws IOException {
|
||||||
|
@ -165,7 +168,7 @@ public void testTwoSameDifferByAssumeValid() throws IOException {
|
||||||
ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, true));
|
ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, true));
|
||||||
ed2.finish();
|
ed2.finish();
|
||||||
|
|
||||||
TreeWalk tw = new TreeWalk(db);
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.addTree(new DirCacheIterator(dc1));
|
tw.addTree(new DirCacheIterator(dc1));
|
||||||
tw.addTree(new DirCacheIterator(dc2));
|
tw.addTree(new DirCacheIterator(dc2));
|
||||||
|
@ -175,6 +178,7 @@ public void testTwoSameDifferByAssumeValid() throws IOException {
|
||||||
assertEquals("a/a", tw.getPathString());
|
assertEquals("a/a", tw.getPathString());
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTwoSameSameAssumeValidDifferentContent()
|
public void testTwoSameSameAssumeValidDifferentContent()
|
||||||
|
@ -188,7 +192,7 @@ public void testTwoSameSameAssumeValidDifferentContent()
|
||||||
ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("b"), 1, true));
|
ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("b"), 1, true));
|
||||||
ed2.finish();
|
ed2.finish();
|
||||||
|
|
||||||
TreeWalk tw = new TreeWalk(db);
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.addTree(new DirCacheIterator(dc1));
|
tw.addTree(new DirCacheIterator(dc1));
|
||||||
tw.addTree(new DirCacheIterator(dc2));
|
tw.addTree(new DirCacheIterator(dc2));
|
||||||
|
@ -196,4 +200,5 @@ public void testTwoSameSameAssumeValidDifferentContent()
|
||||||
|
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue