summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-10-07 16:00:21 -0400
committerCode Review <codereview-daemon@eclipse.org>2011-10-07 16:00:21 -0400
commitcc03e27093c3b24afe2dbe3f64138efcb659ba76 (patch)
tree7a77945bbbe60ca1f20bf16f39d7080ca2064f01 /org.eclipse.jgit.test/tst
parentf99ce8d6ff977866cb4513a6146f3e890d8f32c8 (diff)
parent01888db892aa9590862d886c01f3b293140db153 (diff)
downloadjgit-cc03e27093c3b24afe2dbe3f64138efcb659ba76.tar.gz
jgit-cc03e27093c3b24afe2dbe3f64138efcb659ba76.zip
Merge changes I7cdb563b,I7f60ae68,I7bd1e769,I92683805,I0e51a8e6
* changes: UploadPack: Fix races in smart HTTP negotiation PackWriter: Export more statistics Do not requeue state vector in stateless RPC fetch Wrap excessively long line in BasePackFetchConnection Fix smart HTTP client stream alignment errors
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
index 5fd6816ec7..9fb323c4db 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
@@ -106,13 +106,21 @@ public class UnionInputStreamTest {
u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
final byte[] r = new byte[5];
- assertEquals(5, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 1, 0, 2, 3, 4 }, r));
+ assertEquals(3, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
assertEquals(1, u.read(r, 0, 5));
- assertEquals(5, r[0]);
+ assertEquals(3, r[0]);
+ assertEquals(2, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
assertEquals(-1, u.read(r, 0, 5));
}
+ private static byte[] slice(byte[] in, int len) {
+ byte[] r = new byte[len];
+ System.arraycopy(in, 0, r, 0, len);
+ return r;
+ }
+
@Test
public void testArrayConstructor() throws IOException {
final UnionInputStream u = new UnionInputStream(
@@ -121,10 +129,12 @@ public class UnionInputStreamTest {
new ByteArrayInputStream(new byte[] { 4, 5 }));
final byte[] r = new byte[5];
- assertEquals(5, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 1, 0, 2, 3, 4 }, r));
+ assertEquals(3, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
assertEquals(1, u.read(r, 0, 5));
- assertEquals(5, r[0]);
+ assertEquals(3, r[0]);
+ assertEquals(2, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
assertEquals(-1, u.read(r, 0, 5));
}
@@ -143,9 +153,9 @@ public class UnionInputStreamTest {
u.add(new ByteArrayInputStream(new byte[] { 3 }));
u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
assertEquals(0, u.skip(0));
- assertEquals(4, u.skip(4));
- assertEquals(4, u.read());
- assertEquals(1, u.skip(5));
+ assertEquals(3, u.skip(3));
+ assertEquals(3, u.read());
+ assertEquals(2, u.skip(5));
assertEquals(0, u.skip(5));
assertEquals(-1, u.read());