Browse Source

RepoCommandTest: Refactor to use try-with-resource

Change-Id: If37ce4447feb431169a75594194a7ef02e362d4e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.0
David Pursehouse 7 years ago
parent
commit
1512035451
  1. 330
      org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java

330
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java

@ -185,21 +185,24 @@ public class RepoCommandTest extends RepositoryTestCase {
}
}
@Test
public void runTwiceIsNOP() throws Exception {
Repository child = Git.cloneRepository()
.setURI(groupADb.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true)).setBare(true).call()
.getRepository();
Repository dest = Git.cloneRepository()
.setURI(db.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true)).setBare(true).call()
private Repository cloneRepository(Repository repo, boolean bare)
throws Exception {
Repository r = Git.cloneRepository()
.setURI(repo.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true)).setBare(bare).call()
.getRepository();
if (bare) {
assertTrue(r.isBare());
} else {
assertFalse(r.isBare());
}
return r;
}
assertTrue(dest.isBare());
assertTrue(child.isBare());
@Test
public void runTwiceIsNOP() throws Exception {
try (Repository child = cloneRepository(groupADb, true);
Repository dest = cloneRepository(db, true)) {
StringBuilder xmlContent = new StringBuilder();
xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
.append("<manifest>")
@ -215,44 +218,28 @@ public class RepoCommandTest extends RepositoryTestCase {
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("platform/")
.setRemoteReader(repos).setURI("platform/")
.setTargetURI("platform/superproject")
.setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(true)
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
.call();
String firstIdStr = commit.getId().name() + ":" + ".gitmodules";
commit = new RepoCommand(dest)
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("platform/")
.setRemoteReader(repos).setURI("platform/")
.setTargetURI("platform/superproject")
.setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(true)
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
.call();
String idStr = commit.getId().name() + ":" + ".gitmodules";
assertEquals(firstIdStr, idStr);
child.close();
dest.close();
}
}
@Test
public void androidSetup() throws Exception {
Repository child = Git.cloneRepository()
.setURI(groupADb.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true)).setBare(true).call()
.getRepository();
Repository dest = Git.cloneRepository()
.setURI(db.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true)).setBare(true).call()
.getRepository();
assertTrue(dest.isBare());
assertTrue(child.isBare());
try (Repository child = cloneRepository(groupADb, true);
Repository dest = cloneRepository(db, true)) {
StringBuilder xmlContent = new StringBuilder();
xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
.append("<manifest>")
@ -266,27 +253,25 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put("platform/base", child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("platform/")
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos).setURI("platform/")
.setTargetURI("platform/superproject")
.setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(true)
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
.call();
String idStr = commit.getId().name() + ":" + ".gitmodules";
ObjectId modId = dest.resolve(idStr);
try (ObjectReader reader = dest.newObjectReader()) {
byte[] bytes = reader.open(modId).getCachedBytes(Integer.MAX_VALUE);
byte[] bytes = reader.open(modId)
.getCachedBytes(Integer.MAX_VALUE);
Config base = new Config();
BlobBasedConfig cfg = new BlobBasedConfig(base, bytes);
String subUrl = cfg.getString("submodule", "base", "url");
assertEquals(subUrl, "../base");
}
child.close();
dest.close();
}
}
@Test
@ -299,52 +284,33 @@ public class RepoCommandTest extends RepositoryTestCase {
.append("<project path=\"base\" name=\"platform/base\" />")
.append("</manifest>");
Repository dest = Git.cloneRepository()
.setURI(db.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true)).setBare(true).call()
.getRepository();
assertTrue(dest.isBare());
try (Repository dest = cloneRepository(db, true)) {
RevCommit commit = new RepoCommand(dest)
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(new IndexedRepos())
.setURI("platform/")
.setRemoteReader(new IndexedRepos()).setURI("platform/")
.setTargetURI("platform/superproject")
.setRecordRemoteBranch(true)
.setIgnoreRemoteFailures(true)
.setRecordSubmoduleLabels(true)
.call();
.setRecordRemoteBranch(true).setIgnoreRemoteFailures(true)
.setRecordSubmoduleLabels(true).call();
String idStr = commit.getId().name() + ":" + ".gitmodules";
ObjectId modId = dest.resolve(idStr);
try (ObjectReader reader = dest.newObjectReader()) {
byte[] bytes = reader.open(modId).getCachedBytes(Integer.MAX_VALUE);
byte[] bytes = reader.open(modId)
.getCachedBytes(Integer.MAX_VALUE);
Config base = new Config();
BlobBasedConfig cfg = new BlobBasedConfig(base, bytes);
String subUrl = cfg.getString("submodule", "base", "url");
assertEquals(subUrl, "https://host.com/platform/base");
}
dest.close();
}
}
@Test
public void gerritSetup() throws Exception {
Repository child =
Git.cloneRepository().setURI(groupADb.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true))
.setBare(true).call().getRepository();
Repository dest = Git.cloneRepository()
.setURI(db.getDirectory().toURI().toString()).setDirectory(createUniqueTestGitDir(true))
.setBare(true).call().getRepository();
assertTrue(dest.isBare());
assertTrue(child.isBare());
try (Repository child = cloneRepository(groupADb, true);
Repository dest = cloneRepository(db, true)) {
StringBuilder xmlContent = new StringBuilder();
xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
.append("<manifest>")
@ -358,38 +324,31 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put("plugins/cookbook", child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("")
.setTargetURI("gerrit")
.setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(true)
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos).setURI("").setTargetURI("gerrit")
.setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
.call();
String idStr = commit.getId().name() + ":" + ".gitmodules";
ObjectId modId = dest.resolve(idStr);
try (ObjectReader reader = dest.newObjectReader()) {
byte[] bytes = reader.open(modId).getCachedBytes(Integer.MAX_VALUE);
byte[] bytes = reader.open(modId)
.getCachedBytes(Integer.MAX_VALUE);
Config base = new Config();
BlobBasedConfig cfg = new BlobBasedConfig(base, bytes);
String subUrl = cfg.getString("submodule", "plugins/cookbook", "url");
String subUrl = cfg.getString("submodule", "plugins/cookbook",
"url");
assertEquals(subUrl, "../plugins/cookbook");
}
child.close();
dest.close();
}
}
@Test
public void absoluteRemoteURL() throws Exception {
Repository child =
Git.cloneRepository().setURI(groupADb.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true))
.setBare(true).call().getRepository();
Repository dest = Git.cloneRepository()
.setURI(db.getDirectory().toURI().toString()).setDirectory(createUniqueTestGitDir(true))
.setBare(true).call().getRepository();
try (Repository child = cloneRepository(groupADb, true);
Repository dest = cloneRepository(db, true)) {
String abs = "https://chromium.googlesource.com";
String repoUrl = "https://chromium.googlesource.com/chromium/src";
boolean fetchSlash = false;
@ -400,9 +359,11 @@ public class RepoCommandTest extends RepositoryTestCase {
String baseUrl = baseSlash ? abs + "/" : abs;
StringBuilder xmlContent = new StringBuilder();
xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
xmlContent.append(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
.append("<manifest>")
.append("<remote name=\"origin\" fetch=\"" + fetchUrl + "\" />")
.append("<remote name=\"origin\" fetch=\""
+ fetchUrl + "\" />")
.append("<default revision=\"master\" remote=\"origin\" />")
.append("<project path=\"src\" name=\"chromium/src\" />")
.append("</manifest>");
@ -412,41 +373,37 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put(repoUrl, child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI(baseUrl)
.setTargetURI("gerrit")
.setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(true)
.call();
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos).setURI(baseUrl)
.setTargetURI("gerrit").setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(true).call();
String idStr = commit.getId().name() + ":" + ".gitmodules";
ObjectId modId = dest.resolve(idStr);
try (ObjectReader reader = dest.newObjectReader()) {
byte[] bytes = reader.open(modId).getCachedBytes(Integer.MAX_VALUE);
byte[] bytes = reader.open(modId)
.getCachedBytes(Integer.MAX_VALUE);
Config base = new Config();
BlobBasedConfig cfg = new BlobBasedConfig(base, bytes);
String subUrl = cfg.getString("submodule", "src", "url");
assertEquals("https://chromium.googlesource.com/chromium/src", subUrl);
String subUrl = cfg.getString("submodule", "src",
"url");
assertEquals(
"https://chromium.googlesource.com/chromium/src",
subUrl);
}
fetchSlash = !fetchSlash;
} while (fetchSlash);
baseSlash = !baseSlash;
} while (baseSlash);
child.close();
dest.close();
}
}
@Test
public void absoluteRemoteURLAbsoluteTargetURL() throws Exception {
Repository child =
Git.cloneRepository().setURI(groupADb.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true))
.setBare(true).call().getRepository();
Repository dest = Git.cloneRepository()
.setURI(db.getDirectory().toURI().toString()).setDirectory(createUniqueTestGitDir(true))
.setBare(true).call().getRepository();
try (Repository child = cloneRepository(groupADb, true);
Repository dest = cloneRepository(db, true)) {
String abs = "https://chromium.googlesource.com";
String repoUrl = "https://chromium.googlesource.com/chromium/src";
boolean fetchSlash = false;
@ -457,9 +414,11 @@ public class RepoCommandTest extends RepositoryTestCase {
String baseUrl = baseSlash ? abs + "/" : abs;
StringBuilder xmlContent = new StringBuilder();
xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
xmlContent.append(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
.append("<manifest>")
.append("<remote name=\"origin\" fetch=\"" + fetchUrl + "\" />")
.append("<remote name=\"origin\" fetch=\""
+ fetchUrl + "\" />")
.append("<default revision=\"master\" remote=\"origin\" />")
.append("<project path=\"src\" name=\"chromium/src\" />")
.append("</manifest>");
@ -469,30 +428,30 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put(repoUrl, child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI(baseUrl)
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos).setURI(baseUrl)
.setTargetURI(abs + "/superproject")
.setRecordRemoteBranch(true)
.setRecordSubmoduleLabels(true)
.call();
.setRecordSubmoduleLabels(true).call();
String idStr = commit.getId().name() + ":" + ".gitmodules";
ObjectId modId = dest.resolve(idStr);
try (ObjectReader reader = dest.newObjectReader()) {
byte[] bytes = reader.open(modId).getCachedBytes(Integer.MAX_VALUE);
byte[] bytes = reader.open(modId)
.getCachedBytes(Integer.MAX_VALUE);
Config base = new Config();
BlobBasedConfig cfg = new BlobBasedConfig(base, bytes);
String subUrl = cfg.getString("submodule", "src", "url");
String subUrl = cfg.getString("submodule", "src",
"url");
assertEquals("../chromium/src", subUrl);
}
fetchSlash = !fetchSlash;
} while (fetchSlash);
baseSlash = !baseSlash;
} while (baseSlash);
child.close();
dest.close();
}
}
@Test
@ -513,12 +472,13 @@ public class RepoCommandTest extends RepositoryTestCase {
.call();
File hello = new File(db.getWorkTree(), "foo/hello.txt");
assertTrue("submodule should be checked out", hello.exists());
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("submodule content should be as expected",
"master world", content);
}
}
@Test
public void testRepoManifestGroups() throws Exception {
@ -603,20 +563,22 @@ public class RepoCommandTest extends RepositoryTestCase {
// The original file should exist
File hello = new File(localDb.getWorkTree(), "foo/hello.txt");
assertTrue("The original file should exist", hello.exists());
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("The original file should have expected content",
"master world", content);
}
// The dest file should also exist
hello = new File(localDb.getWorkTree(), "Hello");
assertTrue("The destination file should exist", hello.exists());
reader = new BufferedReader(new FileReader(hello));
content = reader.readLine();
reader.close();
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
assertEquals("The destination file should have expected content",
"master world", content);
}
}
@Test
public void testBareRepo() throws Exception {
@ -638,24 +600,27 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri).call();
// Clone it
File directory = createTempDirectory("testBareRepo");
Repository localDb = Git.cloneRepository().setDirectory(directory)
try (Repository localDb = Git.cloneRepository().setDirectory(directory)
.setURI(remoteDb.getDirectory().toURI().toString()).call()
.getRepository();
.getRepository()) {
// The .gitmodules file should exist
File gitmodules = new File(localDb.getWorkTree(), ".gitmodules");
assertTrue("The .gitmodules file should exist", gitmodules.exists());
assertTrue("The .gitmodules file should exist",
gitmodules.exists());
// The first line of .gitmodules file should be expected
BufferedReader reader = new BufferedReader(new FileReader(gitmodules));
try (BufferedReader reader = new BufferedReader(
new FileReader(gitmodules))) {
String content = reader.readLine();
reader.close();
assertEquals("The first line of .gitmodules file should be as expected",
assertEquals(
"The first line of .gitmodules file should be as expected",
"[submodule \"foo\"]", content);
}
// The gitlink should be the same as remote head sha1
String gitlink = localDb.resolve(Constants.HEAD + ":foo").name();
localDb.close();
String remote = defaultDb.resolve(Constants.HEAD).name();
assertEquals("The gitlink should be the same as remote head", remote,
gitlink);
assertEquals("The gitlink should be the same as remote head",
remote, gitlink);
}
}
@Test
@ -677,12 +642,13 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri)
.call();
File hello = new File(db.getWorkTree(), "foo/hello.txt");
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("submodule content should be as expected",
"branch world", content);
}
}
@Test
public void testRevisionBranch() throws Exception {
@ -703,12 +669,13 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri)
.call();
File hello = new File(db.getWorkTree(), "foo/hello.txt");
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("submodule content should be as expected",
"branch world", content);
}
}
@Test
public void testRevisionTag() throws Exception {
@ -729,12 +696,13 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri)
.call();
File hello = new File(db.getWorkTree(), "foo/hello.txt");
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("submodule content should be as expected",
"branch world", content);
}
}
@Test
public void testRevisionBare() throws Exception {
@ -757,14 +725,14 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri).call();
// Clone it
File directory = createTempDirectory("testRevisionBare");
Repository localDb = Git.cloneRepository().setDirectory(directory)
try (Repository localDb = Git.cloneRepository().setDirectory(directory)
.setURI(remoteDb.getDirectory().toURI().toString()).call()
.getRepository();
.getRepository()) {
// The gitlink should be the same as oldCommitId
String gitlink = localDb.resolve(Constants.HEAD + ":foo").name();
localDb.close();
assertEquals("The gitlink is same as remote head", oldCommitId.name(),
gitlink);
assertEquals("The gitlink is same as remote head",
oldCommitId.name(), gitlink);
}
}
@Test
@ -790,23 +758,25 @@ public class RepoCommandTest extends RepositoryTestCase {
.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 Hello file should exist
File hello = new File(localDb.getWorkTree(), "Hello");
assertTrue("The Hello file should exist", hello.exists());
// The foo/Hello file should be skipped.
File foohello = new File(localDb.getWorkTree(), "foo/Hello");
assertFalse("The foo/Hello file should be skipped", foohello.exists());
localDb.close();
assertFalse("The foo/Hello file should be skipped",
foohello.exists());
// The content of Hello file should be expected
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("The Hello file should have expected content",
"branch world", content);
}
}
}
@Test
public void testReplaceManifestBare() throws Exception {
@ -841,22 +811,24 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri).call();
// Clone it
File directory = createTempDirectory("testReplaceManifestBare");
Repository localDb = Git.cloneRepository().setDirectory(directory)
File dotmodules;
try (Repository localDb = Git.cloneRepository().setDirectory(directory)
.setURI(remoteDb.getDirectory().toURI().toString()).call()
.getRepository();
.getRepository()) {
// The Hello file should not exist
File hello = new File(localDb.getWorkTree(), "Hello");
assertFalse("The Hello file shouldn't exist", hello.exists());
// The Hello.txt file should exist
File hellotxt = new File(localDb.getWorkTree(), "Hello.txt");
assertTrue("The Hello.txt file should exist", hellotxt.exists());
dotmodules = new File(localDb.getWorkTree(),
Constants.DOT_GIT_MODULES);
}
// The .gitmodules file should have 'submodule "bar"' and shouldn't
// have
// 'submodule "foo"' lines.
File dotmodules = new File(localDb.getWorkTree(),
Constants.DOT_GIT_MODULES);
localDb.close();
BufferedReader reader = new BufferedReader(new FileReader(dotmodules));
try (BufferedReader reader = new BufferedReader(
new FileReader(dotmodules))) {
boolean foo = false;
boolean bar = false;
while (true) {
@ -868,10 +840,10 @@ public class RepoCommandTest extends RepositoryTestCase {
if (line.contains("submodule \"bar\""))
bar = true;
}
reader.close();
assertTrue("The bar submodule should exist", bar);
assertFalse("The foo submodule shouldn't exist", foo);
}
}
@Test
public void testRemoveOverlappingBare() throws Exception {
@ -896,16 +868,19 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri).call();
// Clone it
File directory = createTempDirectory("testRemoveOverlappingBare");
Repository localDb = Git.cloneRepository().setDirectory(directory)
File dotmodules;
try (Repository localDb = Git.cloneRepository().setDirectory(directory)
.setURI(remoteDb.getDirectory().toURI().toString()).call()
.getRepository();
.getRepository()) {
dotmodules = new File(localDb.getWorkTree(),
Constants.DOT_GIT_MODULES);
}
// The .gitmodules file should have 'submodule "foo"' and shouldn't
// have
// 'submodule "foo/bar"' lines.
File dotmodules = new File(localDb.getWorkTree(),
Constants.DOT_GIT_MODULES);
localDb.close();
BufferedReader reader = new BufferedReader(new FileReader(dotmodules));
try (BufferedReader reader = new BufferedReader(
new FileReader(dotmodules))) {
boolean foo = false;
boolean foobar = false;
boolean a = false;
@ -920,11 +895,11 @@ public class RepoCommandTest extends RepositoryTestCase {
if (line.contains("submodule \"a\""))
a = true;
}
reader.close();
assertTrue("The foo submodule should exist", foo);
assertFalse("The foo/bar submodule shouldn't exist", foobar);
assertTrue("The a submodule should exist", a);
}
}
@Test
public void testIncludeTag() throws Exception {
@ -959,12 +934,13 @@ public class RepoCommandTest extends RepositoryTestCase {
.call();
File hello = new File(localDb.getWorkTree(), "foo/hello.txt");
assertTrue("submodule should be checked out", hello.exists());
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("submodule content should be as expected",
"master world", content);
}
}
@Test
public void testRemoteAlias() throws Exception {
StringBuilder xmlContent = new StringBuilder();
@ -1165,12 +1141,13 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri)
.call();
File hello = new File(db.getWorkTree(), "foo/hello.txt");
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("submodule content should be as expected",
"branch world", content);
}
}
@Test
public void testDefaultRemoteRevision() throws Exception {
@ -1191,12 +1168,13 @@ public class RepoCommandTest extends RepositoryTestCase {
.setURI(rootUri)
.call();
File hello = new File(db.getWorkTree(), "foo/hello.txt");
BufferedReader reader = new BufferedReader(new FileReader(hello));
try (BufferedReader reader = new BufferedReader(
new FileReader(hello))) {
String content = reader.readLine();
reader.close();
assertEquals("submodule content should be as expected",
"branch world", content);
}
}
private void resolveRelativeUris() {
// Find the longest common prefix ends with "/" as rootUri.

Loading…
Cancel
Save