summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorKevin Corcoran <kevin.corcoran@puppetlabs.com>2016-04-13 15:55:08 -0700
committerDavid Pursehouse <david.pursehouse@gmail.com>2016-10-24 14:00:02 +0900
commitfa0a93119cd3bc6e2673be25a89b8d7638598f3d (patch)
treedd6776c12f35a16c0d8c3ce672d2ac02f9a09cd3 /org.eclipse.jgit.test
parent88f433be84e27468d9234b0305b97139d593c8a9 (diff)
downloadjgit-fa0a93119cd3bc6e2673be25a89b8d7638598f3d.tar.gz
jgit-fa0a93119cd3bc6e2673be25a89b8d7638598f3d.zip
Make streamFileThreshold configurable
Previously, the streamFileThreshold, the threshold at which a file would be streamed rather than loaded entirely into memory, was only configurable on a global basis. This commit makes this threshold configurable on a per-loader basis. Bug: 490404 Change-Id: I492c18c3155dbf56eedda9044a61d76120fd75f9 Signed-off-by: Kevin Corcoran <kevin.corcoran@puppetlabs.com> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
index ba07d6842f..1c10bb335a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
@@ -310,6 +310,27 @@ public class PackFileTest extends LocalDiskRepositoryTestCase {
}
}
+ @Test
+ public void testConfigurableStreamFileThreshold() throws Exception {
+ byte[] data = getRng().nextBytes(300);
+ RevBlob id = tr.blob(data);
+ tr.branch("master").commit().add("A", id).create();
+ tr.packAndPrune();
+ assertTrue("has blob", wc.has(id));
+
+ ObjectLoader ol = wc.open(id);
+ ObjectStream in = ol.openStream();
+ assertTrue(in instanceof ObjectStream.SmallStream);
+ assertEquals(300, in.available());
+ in.close();
+
+ wc.setStreamFileThreshold(299);
+ ol = wc.open(id);
+ in = ol.openStream();
+ assertTrue(in instanceof ObjectStream.Filter);
+ assertEquals(1, in.available());
+ }
+
private static byte[] clone(int first, byte[] base) {
byte[] r = new byte[base.length];
System.arraycopy(base, 1, r, 1, r.length - 1);