Browse Source

TreeFilterTest: Open TreeWalk in try-with-resource

Change-Id: If100a66e544926bcffe9a9a0b31bfd4806902864
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
a82f5c7425
  1. 21
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java

21
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java

@ -55,9 +55,10 @@ import org.junit.Test;
public class TreeFilterTest extends RepositoryTestCase {
@Test
public void testALL_IncludesAnything() throws Exception {
final TreeWalk tw = new TreeWalk(db);
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ALL.include(tw));
try (final TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ALL.include(tw));
}
}
@Test
@ -72,16 +73,18 @@ public class TreeFilterTest extends RepositoryTestCase {
@Test
public void testNotALL_IncludesNothing() throws Exception {
final TreeWalk tw = new TreeWalk(db);
tw.addTree(new EmptyTreeIterator());
assertFalse(TreeFilter.ALL.negate().include(tw));
try (final TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertFalse(TreeFilter.ALL.negate().include(tw));
}
}
@Test
public void testANY_DIFF_IncludesSingleTreeCase() throws Exception {
final TreeWalk tw = new TreeWalk(db);
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ANY_DIFF.include(tw));
try (final TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ANY_DIFF.include(tw));
}
}
@Test

Loading…
Cancel
Save