Use absolute paths for file:// URIs in tests

When run under Buck the repository paths may be relative.  Request
an absolute path to construct the URI, as relative paths are not
supported in file:// style URIs.

Change-Id: I85470d1db2f4e80cba30f1559c0d99bdfa8ac410
diff --git a/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java b/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java
index 7cd5b74..3ce0663 100644
--- a/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java
+++ b/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java
@@ -101,7 +101,7 @@ public void shouldRaiseErrorOnBadSourceURL() throws Exception {
 	public void shouldCloneAValidGitRepository() throws Exception {
 		Repository repo = createBareRepository();
 		File directory = repo.getDirectory();
-		task.setUri("file://" + directory);
+		task.setUri("file://" + directory.getAbsolutePath());
 		task.execute();
 
 		assertTrue(RepositoryCache.FileKey.isGitRepository(new File(dest, ".git"), FS.DETECTED));
@@ -111,7 +111,7 @@ public void shouldCloneAValidGitRepository() throws Exception {
 	public void shouldCreateABareCloneOfAValidGitRepository() throws Exception {
 		Repository repo = createBareRepository();
 		File directory = repo.getDirectory();
-		task.setUri("file://" + directory);
+		task.setUri("file://" + directory.getAbsolutePath());
 		task.setBare(true);
 		task.execute();
 
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
index c2c8317..91ced0a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
@@ -121,7 +121,7 @@ private Git setUpRepoWithRemote() throws Exception {
 		Git localGit = new Git(localRepository);
 		StoredConfig config = localRepository.getConfig();
 		RemoteConfig rc = new RemoteConfig(config, "origin");
-		rc.addURI(new URIish(remoteRepository.getDirectory().getPath()));
+		rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath()));
 		rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
 		rc.update(config);
 		config.save();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
index 31f909a..56c1201 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
@@ -110,7 +110,7 @@ public void testCloneRepository() throws IOException,
 		File directory = createTempDirectory("testCloneRepository");
 		CloneCommand command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 		assertNotNull(git2);
@@ -142,7 +142,7 @@ public void testBareCloneRepository() throws IOException,
 		CloneCommand command = Git.cloneRepository();
 		command.setBare(true);
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 		assertEquals(new RefSpec("+refs/heads/*:refs/heads/*"),
@@ -162,7 +162,7 @@ public void testCloneRepositoryWithBranch() throws IOException,
 		CloneCommand command = Git.cloneRepository();
 		command.setBranch("refs/heads/master");
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 
@@ -177,7 +177,7 @@ public void testCloneRepositoryWithBranch() throws IOException,
 		command = Git.cloneRepository();
 		command.setBranch("refs/heads/master");
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		command.setNoCheckout(true);
 		git2 = command.call();
 		addRepoToClose(git2.getRepository());
@@ -192,7 +192,7 @@ public void testCloneRepositoryWithBranch() throws IOException,
 		command = Git.cloneRepository();
 		command.setBranch("refs/heads/master");
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		command.setBare(true);
 		git2 = command.call();
 		addRepoToClose(git2.getRepository());
@@ -209,7 +209,7 @@ public void testCloneRepositoryWithBranchShortName() throws Exception {
 		CloneCommand command = Git.cloneRepository();
 		command.setBranch("test");
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 
@@ -223,7 +223,7 @@ public void testCloneRepositoryWithTagName() throws Exception {
 		CloneCommand command = Git.cloneRepository();
 		command.setBranch("tag-initial");
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 
@@ -242,7 +242,7 @@ public void testCloneRepositoryOnlyOneBranch() throws IOException,
 		command.setBranchesToClone(Collections
 				.singletonList("refs/heads/master"));
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 		assertNotNull(git2);
@@ -257,7 +257,7 @@ public void testCloneRepositoryOnlyOneBranch() throws IOException,
 		command.setBranchesToClone(Collections
 				.singletonList("refs/heads/master"));
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		command.setBare(true);
 		git2 = command.call();
 		addRepoToClose(git2.getRepository());
@@ -284,14 +284,14 @@ public void testCloneRepositoryWhenDestinationDirectoryExistsAndIsNotEmpty()
 		File directory = createTempDirectory(dirName);
 		CloneCommand command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 		assertNotNull(git2);
 		// clone again
 		command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		try {
 			git2 = command.call();
 			// we shouldn't get here
@@ -310,7 +310,7 @@ public void testCloneRepositoryWithMultipleHeadBranches() throws Exception {
 		File directory = createTempDirectory("testCloneRepositoryWithMultipleHeadBranches");
 		CloneCommand clone = Git.cloneRepository();
 		clone.setDirectory(directory);
-		clone.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		clone.setURI(fileUri());
 		Git git2 = clone.call();
 		addRepoToClose(git2.getRepository());
 		assertNotNull(git2);
@@ -343,7 +343,7 @@ public void testCloneRepositoryWithSubmodules() throws Exception {
 		CloneCommand clone = Git.cloneRepository();
 		clone.setDirectory(directory);
 		clone.setCloneSubmodules(true);
-		clone.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		clone.setURI(fileUri());
 		Git git2 = clone.call();
 		addRepoToClose(git2.getRepository());
 		assertNotNull(git2);
@@ -458,7 +458,7 @@ public void testCloneWithAutoSetupRebase() throws Exception {
 		File directory = createTempDirectory("testCloneRepository1");
 		CloneCommand command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
 		assertFalse(git2
@@ -476,7 +476,7 @@ public void testCloneWithAutoSetupRebase() throws Exception {
 		directory = createTempDirectory("testCloneRepository2");
 		command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		git2 = command.call();
 		addRepoToClose(git2.getRepository());
 		assertTrue(git2
@@ -492,7 +492,7 @@ public void testCloneWithAutoSetupRebase() throws Exception {
 		directory = createTempDirectory("testCloneRepository2");
 		command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		git2 = command.call();
 		addRepoToClose(git2.getRepository());
 		assertTrue(git2
@@ -502,4 +502,8 @@ public void testCloneWithAutoSetupRebase() throws Exception {
 						ConfigConstants.CONFIG_KEY_REBASE, false));
 
 	}
+
+	private String fileUri() {
+		return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
+	}
 }
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java
index f31276d..a853d6a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java
@@ -82,7 +82,7 @@ public void testLsRemote() throws Exception {
 		File directory = createTempDirectory("testRepository");
 		CloneCommand command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		command.setCloneAllBranches(true);
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
@@ -99,7 +99,7 @@ public void testLsRemoteWithTags() throws Exception {
 		File directory = createTempDirectory("testRepository");
 		CloneCommand command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		command.setCloneAllBranches(true);
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
@@ -116,7 +116,7 @@ public void testLsRemoteWithHeads() throws Exception {
 		File directory = createTempDirectory("testRepository");
 		CloneCommand command = Git.cloneRepository();
 		command.setDirectory(directory);
-		command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+		command.setURI(fileUri());
 		command.setCloneAllBranches(true);
 		Git git2 = command.call();
 		addRepoToClose(git2.getRepository());
@@ -130,10 +130,14 @@ public void testLsRemoteWithHeads() throws Exception {
 
 	@Test
 	public void testLsRemoteWithoutLocalRepository() throws Exception {
-		String uri = "file://" + git.getRepository().getWorkTree().getPath();
+		String uri = fileUri();
 		Collection<Ref> refs = Git.lsRemoteRepository().setRemote(uri).setHeads(true).call();
 		assertNotNull(refs);
 		assertEquals(2, refs.size());
 	}
 
+	private String fileUri() {
+		return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
+	}
+
 }
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
index 8d22a1b..c03ced5 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
@@ -139,7 +139,8 @@ public void testPullMerge() throws Exception {
 		assertEquals(sourceCommit.getId(), mergedCommits[1]);
 		RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
 				.getNewHead());
-		String message = "Merge branch 'master' of " + db.getWorkTree();
+		String message = "Merge branch 'master' of "
+				+ db.getWorkTree().getAbsolutePath();
 		assertEquals(message, mergeCommit.getShortMessage());
 	}
 
@@ -255,7 +256,7 @@ public void setUp() throws Exception {
 
 		config
 				.addURI(new URIish(source.getRepository().getWorkTree()
-						.getPath()));
+						.getAbsolutePath()));
 		config.addFetchRefSpec(new RefSpec(
 				"+refs/heads/*:refs/remotes/origin/*"));
 		config.update(targetConfig);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
index 993e16f..25534fd 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
@@ -319,7 +319,7 @@ public void setUp() throws Exception {
 
 		config
 				.addURI(new URIish(source.getRepository().getWorkTree()
-						.getPath()));
+						.getAbsolutePath()));
 		config.addFetchRefSpec(new RefSpec(
 				"+refs/heads/*:refs/remotes/origin/*"));
 		config.update(targetConfig);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
index efdcfeb..280d604 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
@@ -129,7 +129,8 @@ public void absoluteGitDirRef() throws Exception {
 		builder.setMustExist(true);
 		Repository repo2 = builder.build();
 
-		assertEquals(repo1.getDirectory(), repo2.getDirectory());
+		assertEquals(repo1.getDirectory().getAbsolutePath(), repo2
+				.getDirectory().getAbsolutePath());
 		assertEquals(dir, repo2.getWorkTree());
 	}
 
@@ -167,7 +168,8 @@ public void scanWithGitDirRef() throws Exception {
 
 		builder.setWorkTree(dir);
 		builder.findGitDir(dir);
-		assertEquals(repo1.getDirectory(), builder.getGitDir());
+		assertEquals(repo1.getDirectory().getAbsolutePath(), builder
+				.getGitDir().getAbsolutePath());
 		builder.setMustExist(true);
 		Repository repo2 = builder.build();
 
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
index 2b9c107..383ff50 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
@@ -171,8 +171,10 @@ public void apply(DirCacheEntry ent) {
 		Repository subRepo = gen.getRepository();
 		addRepoToClose(subRepo);
 		assertNotNull(subRepo);
-		assertEquals(modulesGitDir, subRepo.getDirectory());
-		assertEquals(new File(db.getWorkTree(), path), subRepo.getWorkTree());
+		assertEquals(modulesGitDir.getAbsolutePath(),
+				subRepo.getDirectory().getAbsolutePath());
+		assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(),
+				subRepo.getWorkTree().getAbsolutePath());
 		assertFalse(gen.next());
 	}
 
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java
index b969183..28a3f44 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java
@@ -231,7 +231,7 @@ public void testLocalTransportWithRelativePath() throws Exception {
 	@Test
 	public void testLocalTransportFetchWithoutLocalRepository()
 			throws Exception {
-		URIish uri = new URIish("file://" + db.getWorkTree().getPath());
+		URIish uri = new URIish("file://" + db.getWorkTree().getAbsolutePath());
 		transport = Transport.open(uri);
 		FetchConnection fetchConnection = transport.openFetch();
 		try {