Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-01-14 08:38:18 +0000
committerMatthias Sohn2016-01-19 16:27:46 +0000
commit9d721de69bd160c070f6de7ce6a011fd955c9679 (patch)
tree531e07196b00535a9802fb0d98183f821f6c33ec /org.eclipse.jgit.pgm.test/tst
parent3b63a242efff6ee2e3f3d87d40b8fbdd1fddacd3 (diff)
downloadjgit-9d721de69bd160c070f6de7ce6a011fd955c9679.tar.gz
jgit-9d721de69bd160c070f6de7ce6a011fd955c9679.tar.xz
jgit-9d721de69bd160c070f6de7ce6a011fd955c9679.zip
BranchTest: Create Git instances in try-with-resource
Change-Id: I8becee479fab91a18e6daffd6f4fd57338c9d120 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Diffstat (limited to 'org.eclipse.jgit.pgm.test/tst')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java
index 4200cd05cf..d1bd5baceb 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java
@@ -57,7 +57,9 @@ public class BranchTest extends CLIRepositoryTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
- new Git(db).commit().setMessage("initial commit").call();
+ try (Git git = new Git(db)) {
+ git.commit().setMessage("initial commit").call();
+ }
}
@Test
@@ -77,13 +79,15 @@ public class BranchTest extends CLIRepositoryTestCase {
@Test
public void testListContains() throws Exception {
- new Git(db).branchCreate().setName("initial").call();
- RevCommit second = new Git(db).commit().setMessage("second commit")
- .call();
- assertArrayOfLinesEquals(new String[] { " initial", "* master", "" },
- execute("git branch --contains 6fd41be"));
- assertArrayOfLinesEquals(new String[] { "* master", "" },
- execute("git branch --contains " + second.name()));
+ try (Git git = new Git(db)) {
+ git.branchCreate().setName("initial").call();
+ RevCommit second = git.commit().setMessage("second commit")
+ .call();
+ assertArrayOfLinesEquals(new String[] { " initial", "* master", "" },
+ execute("git branch --contains 6fd41be"));
+ assertArrayOfLinesEquals(new String[] { "* master", "" },
+ execute("git branch --contains " + second.name()));
+ }
}
@Test

Back to the top