diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-06-24 12:35:19 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-06-24 12:37:58 -0700 |
commit | 826fb260a3515c86eba9e65e54695c78a085425c (patch) | |
tree | ff8616377fc8085817697315389b1a39dfe016cc /org.eclipse.jgit.test/tst | |
parent | 2cebb7dbc712898197029881a8c1f41628e51804 (diff) | |
download | jgit-826fb260a3515c86eba9e65e54695c78a085425c.tar.gz jgit-826fb260a3515c86eba9e65e54695c78a085425c.zip |
TemporaryBuffer: Fix reading from in-memory InputStream
I had the conditions wrong here, causing the in-memory InputStream
to always appear to be at EOF.
Change-Id: I6811d6187a34eaf1fd6c5002550d631decdfc391
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java index cc4cad5ee1..eb4fb1e87d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java @@ -52,6 +52,7 @@ import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.Arrays; import org.eclipse.jgit.junit.TestRng; @@ -249,6 +250,20 @@ public class TemporaryBufferTest { } @Test + public void testInCoreInputStream() throws IOException { + final int cnt = 256; + final byte[] test = new TestRng(getName()).nextBytes(cnt); + final TemporaryBuffer.Heap b = new TemporaryBuffer.Heap(cnt + 4); + b.write(test); + b.close(); + + InputStream in = b.openInputStream(); + byte[] act = new byte[cnt]; + IO.readFully(in, act, 0, cnt); + assertTrue(Arrays.equals(test, act)); + } + + @Test public void testInCoreLimit_SwitchOnAppendByte() throws IOException { final TemporaryBuffer b = new TemporaryBuffer.LocalFile(); final byte[] test = new TestRng(getName()) |