Browse Source

RepoCommandSymlinkTest#testLinkFileBare: Use try-with-resource

Change-Id: I72756d92dc5ea54ad009dddb9cebbcd6d1a0b4f8
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.0
David Pursehouse 7 years ago
parent
commit
57c6ff94fb
  1. 70
      org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandSymlinkTest.java

70
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandSymlinkTest.java

@ -119,45 +119,47 @@ public class RepoCommandSymlinkTest extends RepositoryTestCase {
.setURI(rootUri).call(); .setURI(rootUri).call();
// Clone it // Clone it
File directory = createTempDirectory("testCopyFileBare"); File directory = createTempDirectory("testCopyFileBare");
Repository localDb = Git.cloneRepository().setDirectory(directory) try (Repository localDb = Git.cloneRepository()
.setDirectory(directory)
.setURI(remoteDb.getDirectory().toURI().toString()).call() .setURI(remoteDb.getDirectory().toURI().toString()).call()
.getRepository(); .getRepository()) {
// The LinkedHello symlink should exist. // The LinkedHello symlink should exist.
File linkedhello = new File(localDb.getWorkTree(), "LinkedHello"); File linkedhello = new File(localDb.getWorkTree(),
assertTrue("The LinkedHello file should exist", "LinkedHello");
localDb.getFS().exists(linkedhello)); assertTrue("The LinkedHello file should exist",
assertTrue("The LinkedHello file should be a symlink", localDb.getFS().exists(linkedhello));
localDb.getFS().isSymLink(linkedhello)); assertTrue("The LinkedHello file should be a symlink",
assertEquals("foo/hello.txt", localDb.getFS().isSymLink(linkedhello));
localDb.getFS().readSymLink(linkedhello)); assertEquals("foo/hello.txt",
localDb.getFS().readSymLink(linkedhello));
// The foo/LinkedHello file should be skipped. // The foo/LinkedHello file should be skipped.
File linkedfoohello = new File(localDb.getWorkTree(), "foo/LinkedHello"); File linkedfoohello = new File(localDb.getWorkTree(),
assertFalse("The foo/LinkedHello file should be skipped", "foo/LinkedHello");
localDb.getFS().exists(linkedfoohello)); assertFalse("The foo/LinkedHello file should be skipped",
localDb.getFS().exists(linkedfoohello));
// The subdir/LinkedHello file should use a relative ../ // The subdir/LinkedHello file should use a relative ../
File linkedsubdirhello = new File(localDb.getWorkTree(), File linkedsubdirhello = new File(localDb.getWorkTree(),
"subdir/LinkedHello"); "subdir/LinkedHello");
assertTrue("The subdir/LinkedHello file should exist", assertTrue("The subdir/LinkedHello file should exist",
localDb.getFS().exists(linkedsubdirhello)); localDb.getFS().exists(linkedsubdirhello));
assertTrue("The subdir/LinkedHello file should be a symlink", assertTrue("The subdir/LinkedHello file should be a symlink",
localDb.getFS().isSymLink(linkedsubdirhello)); localDb.getFS().isSymLink(linkedsubdirhello));
assertEquals("../foo/hello.txt", assertEquals("../foo/hello.txt",
localDb.getFS().readSymLink(linkedsubdirhello)); localDb.getFS().readSymLink(linkedsubdirhello));
// The bar/foo/LinkedHello file should use a single relative ../ // The bar/foo/LinkedHello file should use a single relative ../
File linkedbarfoohello = new File(localDb.getWorkTree(), File linkedbarfoohello = new File(localDb.getWorkTree(),
"bar/foo/LinkedHello"); "bar/foo/LinkedHello");
assertTrue("The bar/foo/LinkedHello file should exist", assertTrue("The bar/foo/LinkedHello file should exist",
localDb.getFS().exists(linkedbarfoohello)); localDb.getFS().exists(linkedbarfoohello));
assertTrue("The bar/foo/LinkedHello file should be a symlink", assertTrue("The bar/foo/LinkedHello file should be a symlink",
localDb.getFS().isSymLink(linkedbarfoohello)); localDb.getFS().isSymLink(linkedbarfoohello));
assertEquals("../baz/hello.txt", assertEquals("../baz/hello.txt",
localDb.getFS().readSymLink(linkedbarfoohello)); localDb.getFS().readSymLink(linkedbarfoohello));
}
localDb.close();
} }
} }
} }

Loading…
Cancel
Save