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

Loading…
Cancel
Save