diff options
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java index 9e663d7b4c..5685ccac61 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java @@ -66,6 +66,7 @@ import org.eclipse.jgit.lib.TextProgressMonitor; import org.eclipse.jgit.revwalk.RevObject; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.storage.file.PackIndex.MutableEntry; +import org.eclipse.jgit.storage.pack.PackConfig; import org.eclipse.jgit.storage.pack.PackWriter; import org.eclipse.jgit.transport.IndexPack; import org.eclipse.jgit.util.JGitTestUtil; @@ -78,6 +79,8 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { private static final List<RevObject> EMPTY_LIST_REVS = Collections .<RevObject> emptyList(); + private PackConfig config; + private PackWriter writer; private ByteArrayOutputStream os; @@ -96,16 +99,23 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { packBase = new File(trash, "tmp_pack"); packFile = new File(trash, "tmp_pack.pack"); indexFile = new File(trash, "tmp_pack.idx"); - writer = new PackWriter(db); + config = new PackConfig(db); + } + + public void tearDown() throws Exception { + if (writer != null) + writer.release(); + super.tearDown(); } /** * Test constructor for exceptions, default settings, initialization. */ public void testContructor() { + writer = new PackWriter(config, db.newObjectReader()); assertEquals(false, writer.isDeltaBaseAsOffset()); - assertEquals(true, writer.isReuseDeltas()); - assertEquals(true, writer.isReuseObjects()); + assertEquals(true, config.isReuseDeltas()); + assertEquals(true, config.isReuseObjects()); assertEquals(0, writer.getObjectsNumber()); } @@ -113,13 +123,17 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { * Change default settings and verify them. */ public void testModifySettings() { + config.setReuseDeltas(false); + config.setReuseObjects(false); + config.setDeltaBaseAsOffset(false); + assertEquals(false, config.isReuseDeltas()); + assertEquals(false, config.isReuseObjects()); + assertEquals(false, config.isDeltaBaseAsOffset()); + + writer = new PackWriter(config, db.newObjectReader()); writer.setDeltaBaseAsOffset(true); - writer.setReuseDeltas(false); - writer.setReuseObjects(false); - assertEquals(true, writer.isDeltaBaseAsOffset()); - assertEquals(false, writer.isReuseDeltas()); - assertEquals(false, writer.isReuseObjects()); + assertEquals(false, config.isDeltaBaseAsOffset()); } /** @@ -188,7 +202,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { * @throws IOException */ public void testWritePack1() throws IOException { - writer.setReuseDeltas(false); + config.setReuseDeltas(false); writeVerifyPack1(); } @@ -199,8 +213,8 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { * @throws IOException */ public void testWritePack1NoObjectReuse() throws IOException { - writer.setReuseDeltas(false); - writer.setReuseObjects(false); + config.setReuseDeltas(false); + config.setReuseObjects(false); writeVerifyPack1(); } @@ -231,7 +245,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { * @throws IOException */ public void testWritePack2DeltasReuseOffsets() throws IOException { - writer.setDeltaBaseAsOffset(true); + config.setDeltaBaseAsOffset(true); writeVerifyPack2(true); } @@ -265,7 +279,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { * */ public void testWritePack3() throws MissingObjectException, IOException { - writer.setReuseDeltas(false); + config.setReuseDeltas(false); final ObjectId forcedOrder[] = new ObjectId[] { ObjectId.fromString("82c6b885ff600be425b4ea96dee75dca255b69e7"), ObjectId.fromString("c59759f143fb1fe21c197981df75a7ee00290799"), @@ -363,7 +377,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { } public void testWriteIndex() throws Exception { - writer.setIndexVersion(2); + config.setIndexVersion(2); writeVerifyPack4(false); // Validate that IndexPack came up with the right CRC32 value. @@ -419,7 +433,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { } private void writeVerifyPack2(boolean deltaReuse) throws IOException { - writer.setReuseDeltas(deltaReuse); + config.setReuseDeltas(deltaReuse); final LinkedList<ObjectId> interestings = new LinkedList<ObjectId>(); interestings.add(ObjectId .fromString("82c6b885ff600be425b4ea96dee75dca255b69e7")); @@ -482,6 +496,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { final boolean ignoreMissingUninteresting) throws MissingObjectException, IOException { NullProgressMonitor m = NullProgressMonitor.INSTANCE; + writer = new PackWriter(config, db.newObjectReader()); writer.setThin(thin); writer.setIgnoreMissingUninteresting(ignoreMissingUninteresting); writer.preparePack(m, interestings, uninterestings); @@ -493,6 +508,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { private void createVerifyOpenPack(final Iterator<RevObject> objectSource) throws MissingObjectException, IOException { NullProgressMonitor m = NullProgressMonitor.INSTANCE; + writer = new PackWriter(config, db.newObjectReader()); writer.preparePack(objectSource); writer.writePack(m, m, os); writer.release(); |