RepoCommandSymlinkTest#testLinkFileBare: Use try-with-resource

Change-Id: I72756d92dc5ea54ad009dddb9cebbcd6d1a0b4f8
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2018-03-14 13:35:50 +09:00
parent 1512035451
commit 57c6ff94fb
1 changed files with 36 additions and 34 deletions

View File

@ -119,12 +119,14 @@ public void testLinkFileBare() throws Exception {
.setURI(rootUri).call();
// Clone it
File directory = createTempDirectory("testCopyFileBare");
Repository localDb = Git.cloneRepository().setDirectory(directory)
try (Repository localDb = Git.cloneRepository()
.setDirectory(directory)
.setURI(remoteDb.getDirectory().toURI().toString()).call()
.getRepository();
.getRepository()) {
// The LinkedHello symlink should exist.
File linkedhello = new File(localDb.getWorkTree(), "LinkedHello");
File linkedhello = new File(localDb.getWorkTree(),
"LinkedHello");
assertTrue("The LinkedHello file should exist",
localDb.getFS().exists(linkedhello));
assertTrue("The LinkedHello file should be a symlink",
@ -133,7 +135,8 @@ public void testLinkFileBare() throws Exception {
localDb.getFS().readSymLink(linkedhello));
// The foo/LinkedHello file should be skipped.
File linkedfoohello = new File(localDb.getWorkTree(), "foo/LinkedHello");
File linkedfoohello = new File(localDb.getWorkTree(),
"foo/LinkedHello");
assertFalse("The foo/LinkedHello file should be skipped",
localDb.getFS().exists(linkedfoohello));
@ -156,8 +159,7 @@ public void testLinkFileBare() throws Exception {
localDb.getFS().isSymLink(linkedbarfoohello));
assertEquals("../baz/hello.txt",
localDb.getFS().readSymLink(linkedbarfoohello));
localDb.close();
}
}
}
}