Source:
<code>public void testRecordRemoteBranch() throws Exception { try ( Repository remoteDb = createBareRepository(); Repository tempDb = createWorkRepository()) { StringBuilder xmlContent = new StringBuilder(); xmlContent .append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") .append("<manifest>") .append("<remote name=\"remote1\" fetch=\".\" />") .append("<default revision=\"master\" remote=\"remote1\" />") .append("<project path=\"with-branch\" ") .append("revision=\"master\" ") .append("name=\"").append(notDefaultUri).append("\" />") .append("<project path=\"with-long-branch\" ") .append("revision=\"refs/heads/master\" ") .append("name=\"").append(defaultUri).append("\" />") .append("</manifest>"); JGitTestUtil.writeTrashFile(tempDb, "manifest.xml", xmlContent.toString()); RepoCommand command = new RepoCommand(remoteDb); command.setPath(tempDb.getWorkTree().getAbsolutePath() + "/manifest.xml") .setURI(rootUri) .setRecordRemoteBranch(true) .call(); File directory = createTempDirectory("testBareRepo"); Repository localDb = Git.cloneRepository().setDirectory(directory) .setURI(remoteDb.getDirectory().toURI().toString()).call() .getRepository(); File gitmodules = new File(localDb.getWorkTree(), ".gitmodules"); assertTrue("The .gitmodules file should exist", gitmodules.exists()); FileBasedConfig c = new FileBasedConfig(gitmodules, FS.DETECTED); <START> try { <END> c.load(); } catch (ConfigInvalidException err) { throw new IllegalArgumentException("Cannot load config file."); } assertEquals("standard branches work", "master", c.getString("submodule", "with-branch", "branch")); assertEquals("long branches work", "refs/heads/master", c.getString("submodule", "with-long-branch", "branch")); } }</code><technical_language>I this try..catch is necessary. In JUnit, ConfigInvalidException thrown effect throwing IllegalArgumentException</technical_language>

Target:
public void testRecordRemoteBranch() throws Exception { try ( Repository remoteDb = createBareRepository(); Repository tempDb = createWorkRepository()) { StringBuilder xmlContent = new StringBuilder(); xmlContent .append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") .append("<manifest>") .append("<remote name=\"remote1\" fetch=\".\" />") .append("<default revision=\"master\" remote=\"remote1\" />") .append("<project path=\"with-branch\" ") .append("revision=\"master\" ") .append("name=\"").append(notDefaultUri).append("\" />") .append("<project path=\"with-long-branch\" ") .append("revision=\"refs/heads/master\" ") .append("name=\"").append(defaultUri).append("\" />") .append("</manifest>"); JGitTestUtil.writeTrashFile(tempDb, "manifest.xml", xmlContent.toString()); RepoCommand command = new RepoCommand(remoteDb); command.setPath(tempDb.getWorkTree().getAbsolutePath() + "/manifest.xml") .setURI(rootUri) .setRecordRemoteBranch(true) .call(); File directory = createTempDirectory("testBareRepo"); Repository localDb = Git.cloneRepository().setDirectory(directory) .setURI(remoteDb.getDirectory().toURI().toString()).call() .getRepository(); File gitmodules = new File(localDb.getWorkTree(), ".gitmodules"); assertTrue("The .gitmodules file should exist", gitmodules.exists()); FileBasedConfig c = new FileBasedConfig(gitmodules, FS.DETECTED); c.load(); assertEquals("standard branches work", "master", c.getString("submodule", "with-branch", "branch")); assertEquals("long branches work", "refs/heads/master", c.getString("submodule", "with-long-branch", "branch")); } }