diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2019-01-20 17:08:01 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2019-01-20 17:08:01 +0900 |
commit | b6fe0abc4ce66dcc65991f80c15035486afd1e53 (patch) | |
tree | 1e99453bfafe1ff17627de05d7a14d8780f067f4 /org.eclipse.jgit.test/tst | |
parent | 5ac044abc009175765387b0450196b1d5dc027ab (diff) | |
download | jgit-b6fe0abc4ce66dcc65991f80c15035486afd1e53.tar.gz jgit-b6fe0abc4ce66dcc65991f80c15035486afd1e53.zip |
PackParserTest: Open TestRepository in try-with-resource
Change-Id: Ie3521f40ac80bc58df95f9f5dc79d51b29380461
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java index 0f98fac706..fd952f328f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java @@ -141,8 +141,10 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testTinyThinPack() throws Exception { - TestRepository d = new TestRepository<Repository>(db); - RevBlob a = d.blob("a"); + RevBlob a; + try (TestRepository d = new TestRepository<Repository>(db)) { + a = d.blob("a"); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); @@ -162,8 +164,9 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testPackWithDuplicateBlob() throws Exception { final byte[] data = Constants.encode("0123456789abcdefg"); - TestRepository<Repository> d = new TestRepository<>(db); - assertTrue(db.getObjectDatabase().has(d.blob(data))); + try (TestRepository<Repository> d = new TestRepository<>(db)) { + assertTrue(db.getObjectDatabase().has(d.blob(data))); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); packHeader(pack, 1); @@ -179,8 +182,10 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testPackWithTrailingGarbage() throws Exception { - TestRepository d = new TestRepository<Repository>(db); - RevBlob a = d.blob("a"); + RevBlob a; + try (TestRepository d = new TestRepository<Repository>(db)) { + a = d.blob("a"); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); packHeader(pack, 1); @@ -206,9 +211,10 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testMaxObjectSizeFullBlob() throws Exception { - TestRepository d = new TestRepository<Repository>(db); final byte[] data = Constants.encode("0123456789"); - d.blob(data); + try (TestRepository d = new TestRepository<Repository>(db)) { + d.blob(data); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); @@ -238,8 +244,10 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testMaxObjectSizeDeltaBlock() throws Exception { - TestRepository d = new TestRepository<Repository>(db); - RevBlob a = d.blob("a"); + RevBlob a; + try (TestRepository d = new TestRepository<Repository>(db)) { + a = d.blob("a"); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); @@ -269,8 +277,10 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testMaxObjectSizeDeltaResultSize() throws Exception { - TestRepository d = new TestRepository<Repository>(db); - RevBlob a = d.blob("0123456789"); + RevBlob a; + try (TestRepository d = new TestRepository<Repository>(db)) { + a = d.blob("0123456789"); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); @@ -299,8 +309,10 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testNonMarkingInputStream() throws Exception { - TestRepository d = new TestRepository<Repository>(db); - RevBlob a = d.blob("a"); + RevBlob a; + try (TestRepository d = new TestRepository<Repository>(db)) { + a = d.blob("a"); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); packHeader(pack, 1); @@ -337,8 +349,10 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testDataAfterPackFooterSingleRead() throws Exception { - TestRepository d = new TestRepository<Repository>(db); - RevBlob a = d.blob("a"); + RevBlob a; + try (TestRepository d = new TestRepository<Repository>(db)) { + a = d.blob("a"); + } TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(32*1024); packHeader(pack, 1); @@ -395,9 +409,11 @@ public class PackParserTest extends RepositoryTestCase { @Test public void testDataAfterPackFooterSplitHeaderRead() throws Exception { - TestRepository d = new TestRepository<Repository>(db); final byte[] data = Constants.encode("a"); - RevBlob b = d.blob(data); + RevBlob b; + try (TestRepository d = new TestRepository<Repository>(db)) { + b = d.blob(data); + } int objects = 248; TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(32 * 1024); |