Browse Source

SubmoduleWalkTest: Open Repository in try-with-resource

Change-Id: I9c4ee4e4c55f48db1f21e18b212657e4dd3de053
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.4
David Pursehouse 6 years ago
parent
commit
6503a67e46
  1. 31
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java

31
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java

@ -145,7 +145,6 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertFalse(gen.next()); assertFalse(gen.next());
} }
@SuppressWarnings("resource" /* java 7 */)
@Test @Test
public void repositoryWithRootLevelSubmoduleAbsoluteRef() public void repositoryWithRootLevelSubmoduleAbsoluteRef()
throws IOException, ConfigInvalidException { throws IOException, ConfigInvalidException {
@ -189,17 +188,16 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertNull(gen.getModulesPath()); assertNull(gen.getModulesPath());
assertNull(gen.getModulesUpdate()); assertNull(gen.getModulesUpdate());
assertNull(gen.getModulesUrl()); assertNull(gen.getModulesUrl());
Repository subRepo = gen.getRepository(); try (Repository subRepo = gen.getRepository()) {
assertNotNull(subRepo); assertNotNull(subRepo);
assertEquals(modulesGitDir.getAbsolutePath(), assertEquals(modulesGitDir.getAbsolutePath(),
subRepo.getDirectory().getAbsolutePath()); subRepo.getDirectory().getAbsolutePath());
assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(), assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(),
subRepo.getWorkTree().getAbsolutePath()); subRepo.getWorkTree().getAbsolutePath());
subRepo.close(); }
assertFalse(gen.next()); assertFalse(gen.next());
} }
@SuppressWarnings("resource" /* java 7 */)
@Test @Test
public void repositoryWithRootLevelSubmoduleRelativeRef() public void repositoryWithRootLevelSubmoduleRelativeRef()
throws IOException, ConfigInvalidException { throws IOException, ConfigInvalidException {
@ -244,13 +242,14 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertNull(gen.getModulesPath()); assertNull(gen.getModulesPath());
assertNull(gen.getModulesUpdate()); assertNull(gen.getModulesUpdate());
assertNull(gen.getModulesUrl()); assertNull(gen.getModulesUrl());
Repository subRepo = gen.getRepository(); try (Repository subRepo = gen.getRepository()) {
assertNotNull(subRepo); assertNotNull(subRepo);
assertEqualsFile(modulesGitDir, subRepo.getDirectory()); assertEqualsFile(modulesGitDir, subRepo.getDirectory());
assertEqualsFile(new File(db.getWorkTree(), path), assertEqualsFile(new File(db.getWorkTree(), path),
subRepo.getWorkTree()); subRepo.getWorkTree());
subRepo.close(); subRepo.close();
assertFalse(gen.next()); assertFalse(gen.next());
}
} }
@Test @Test

Loading…
Cancel
Save