Browse Source

PacketLineInTest: test for END and DELIM being distinguishable

Explicitly test that END and DELIM can be distinguished. If not, the
wire protocol V2 breaks down.

Bug: 568950
Change-Id: I5f3496168244303c68893f1c756831dd27440aeb
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
tags/v5.10.0.202012021225-rc1
Thomas Wolf 3 years ago
parent
commit
c053b510b3

+ 8
- 3
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineInTest.java View File



import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
final String act = in.readString(); final String act = in.readString();
assertEquals("", act); assertEquals("", act);
assertFalse(PacketLineIn.isEnd(act)); assertFalse(PacketLineIn.isEnd(act));
assertFalse(PacketLineIn.isDelimiter(act));
assertEOF(); assertEOF();
} }


@Test @Test
public void testReadString_End() throws IOException { public void testReadString_End() throws IOException {
init("0000"); init("0000");
assertTrue(PacketLineIn.isEnd(in.readString()));
String act = in.readString();
assertTrue(PacketLineIn.isEnd(act));
assertFalse(PacketLineIn.isDelimiter(act));
assertEOF(); assertEOF();
} }


@Test @Test
public void testReadString_Delim() throws IOException { public void testReadString_Delim() throws IOException {
init("0001"); init("0001");
assertTrue(PacketLineIn.isDelimiter(in.readString()));
String act = in.readString();
assertTrue(PacketLineIn.isDelimiter(act));
assertFalse(PacketLineIn.isEnd(act));
assertEOF(); assertEOF();
} }



Loading…
Cancel
Save