Browse Source

ArchiveCommandTest: Create Git instances in try-with-resource

Change-Id: Icbfd92395db85818736142fd3fb3432385e89ca9
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
a833fec219
  1. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java

@ -85,7 +85,7 @@ public class ArchiveCommandTest extends RepositoryTestCase {
@Test
public void archiveHeadAllFiles() throws IOException, GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("file_1.txt", "content_1_1");
git.add().addFilepattern("file_1.txt").call();
git.commit().setMessage("create file").call();
@ -103,10 +103,11 @@ public class ArchiveCommandTest extends RepositoryTestCase {
assertEquals(UNEXPECTED_FILE_CONTENTS, "content_1_2", format.getByPath("file_1.txt"));
assertEquals(UNEXPECTED_FILE_CONTENTS, "content_2_2", format.getByPath("file_2.txt"));
}
}
@Test
public void archiveHeadSpecificPath() throws IOException, GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("file_1.txt", "content_1_1");
git.add().addFilepattern("file_1.txt").call();
git.commit().setMessage("create file").call();
@ -126,10 +127,11 @@ public class ArchiveCommandTest extends RepositoryTestCase {
assertEquals(UNEXPECTED_FILE_CONTENTS, "content_2_2", format.getByPath(expectedFilePath));
assertNull(UNEXPECTED_TREE_CONTENTS, format.getByPath("some_directory"));
}
}
@Test
public void archiveByIdSpecificFile() throws IOException, GitAPIException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("file_1.txt", "content_1_1");
git.add().addFilepattern("file_1.txt").call();
RevCommit first = git.commit().setMessage("create file").call();
@ -154,10 +156,11 @@ public class ArchiveCommandTest extends RepositoryTestCase {
assertEquals(UNEXPECTED_ARCHIVE_SIZE, 1, format.size());
assertEquals(UNEXPECTED_FILE_CONTENTS, "content_1_1", format.getByPath("file_1.txt"));
}
}
@Test
public void archiveByDirectoryPath() throws GitAPIException, IOException {
Git git = new Git(db);
try (Git git = new Git(db)) {
writeTrashFile("file_0.txt", "content_0_1");
git.add().addFilepattern("file_0.txt").call();
git.commit().setMessage("commit_1").call();
@ -183,6 +186,7 @@ public class ArchiveCommandTest extends RepositoryTestCase {
assertNull(UNEXPECTED_TREE_CONTENTS, format.getByPath("some_directory"));
assertNull(UNEXPECTED_TREE_CONTENTS, format.getByPath("some_directory/nested_directory"));
}
}
private class MockFormat implements ArchiveCommand.Format<MockOutputStream> {

Loading…
Cancel
Save