Browse Source

StatusCommandTest: Open Git in try-with-resource

Change-Id: Id13ad9fa3157d0479da12fb8184437be3ca8c948
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
6aa619ec5c
  1. 10
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java

10
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java

@ -61,8 +61,7 @@ public class StatusCommandTest extends RepositoryTestCase {
@Test
public void testEmptyStatus() throws NoWorkTreeException,
GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
Status stat = git.status().call();
assertEquals(0, stat.getAdded().size());
assertEquals(0, stat.getChanged().size());
@ -71,11 +70,12 @@ public class StatusCommandTest extends RepositoryTestCase {
assertEquals(0, stat.getRemoved().size());
assertEquals(0, stat.getUntracked().size());
}
}
@Test
public void testDifferentStates() throws IOException,
NoFilepatternException, GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("a", "content of a");
writeTrashFile("b", "content of b");
writeTrashFile("c", "content of c");
@ -130,11 +130,12 @@ public class StatusCommandTest extends RepositoryTestCase {
assertEquals(1, stat.getUntrackedFolders().size());
assertTrue(stat.getUntrackedFolders().contains("sub"));
}
}
@Test
public void testDifferentStatesWithPaths() throws IOException,
NoFilepatternException, GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("a", "content of a");
writeTrashFile("D/b", "content of b");
writeTrashFile("D/c", "content of c");
@ -166,4 +167,5 @@ public class StatusCommandTest extends RepositoryTestCase {
stat = git.status().call();
assertEquals(Sets.of("a", "D/b", "D/D/d"), stat.getModified());
}
}
}

Loading…
Cancel
Save