mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Update data format to match BDF spec.
This commit is contained in:
@@ -108,7 +108,7 @@ public class LockFairnessTest extends BriarTestCase {
|
||||
}
|
||||
};
|
||||
first.start();
|
||||
// Writer
|
||||
// BdfWriter
|
||||
Thread writer = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -14,10 +14,9 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ReaderImplTest extends BriarTestCase {
|
||||
public class BdfReaderImplTest extends BriarTestCase {
|
||||
|
||||
private ByteArrayInputStream in = null;
|
||||
private ReaderImpl r = null;
|
||||
private BdfReaderImpl r = null;
|
||||
|
||||
@Test
|
||||
public void testReadEmptyInput() throws Exception {
|
||||
@@ -127,49 +126,6 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntegersMustHaveMinimalLength() throws Exception {
|
||||
// INTEGER_16 could be encoded as INTEGER_8
|
||||
setContents("21" + "7F" + "22" + "007F");
|
||||
assertEquals(Byte.MAX_VALUE, r.readInteger());
|
||||
try {
|
||||
r.readInteger();
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
setContents("21" + "80" + "22" + "FF80");
|
||||
assertEquals(Byte.MIN_VALUE, r.readInteger());
|
||||
try {
|
||||
r.readInteger();
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
// INTEGER_32 could be encoded as INTEGER_16
|
||||
setContents("22" + "7FFF" + "24" + "00007FFF");
|
||||
assertEquals(Short.MAX_VALUE, r.readInteger());
|
||||
try {
|
||||
r.readInteger();
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
setContents("22" + "8000" + "24" + "FFFF8000");
|
||||
assertEquals(Short.MIN_VALUE, r.readInteger());
|
||||
try {
|
||||
r.readInteger();
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
// INTEGER_64 could be encoded as INTEGER_32
|
||||
setContents("24" + "7FFFFFFF" + "28" + "000000007FFFFFFF");
|
||||
assertEquals(Integer.MAX_VALUE, r.readInteger());
|
||||
try {
|
||||
r.readInteger();
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
setContents("24" + "80000000" + "28" + "FFFFFFFF80000000");
|
||||
assertEquals(Integer.MIN_VALUE, r.readInteger());
|
||||
try {
|
||||
r.readInteger();
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadFloat() throws Exception {
|
||||
// http://babbage.cs.qc.edu/IEEE-754/Decimal.html
|
||||
@@ -218,7 +174,9 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
try {
|
||||
r.readString(2);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
} catch (FormatException expected) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -258,7 +216,9 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
try {
|
||||
r.readString(Byte.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
} catch (FormatException expected) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -296,7 +256,9 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
try {
|
||||
r.readString(Short.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
} catch (FormatException expected) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -311,28 +273,6 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringsMustHaveMinimalLength() throws Exception {
|
||||
// STRING_16 could be encoded as STRING_8
|
||||
String longest8 = TestUtils.createRandomString(Byte.MAX_VALUE);
|
||||
String long8Hex = StringUtils.toHexString(longest8.getBytes("UTF-8"));
|
||||
setContents("41" + "7F" + long8Hex + "42" + "007F" + long8Hex);
|
||||
assertEquals(longest8, r.readString(Integer.MAX_VALUE));
|
||||
try {
|
||||
r.readString(Integer.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
// STRING_32 could be encoded as STRING_16
|
||||
String longest16 = TestUtils.createRandomString(Short.MAX_VALUE);
|
||||
String long16Hex = StringUtils.toHexString(longest16.getBytes("UTF-8"));
|
||||
setContents("42" + "7FFF" + long16Hex + "44" + "00007FFF" + long16Hex);
|
||||
assertEquals(longest16, r.readString(Integer.MAX_VALUE));
|
||||
try {
|
||||
r.readString(Integer.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadRaw8() throws Exception {
|
||||
byte[] longest = new byte[Byte.MAX_VALUE];
|
||||
@@ -355,7 +295,9 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
try {
|
||||
r.readRaw(2);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
} catch (FormatException expected) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -395,7 +337,9 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
try {
|
||||
r.readRaw(Byte.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
} catch (FormatException expected) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -433,7 +377,9 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
try {
|
||||
r.readRaw(Short.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
} catch (FormatException expected) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -448,28 +394,6 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRawMustHaveMinimalLength() throws Exception {
|
||||
// RAW_16 could be encoded as RAW_8
|
||||
byte[] longest8 = new byte[Byte.MAX_VALUE];
|
||||
String long8Hex = StringUtils.toHexString(longest8);
|
||||
setContents("51" + "7F" + long8Hex + "52" + "007F" + long8Hex);
|
||||
assertArrayEquals(longest8, r.readRaw(Integer.MAX_VALUE));
|
||||
try {
|
||||
r.readRaw(Integer.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
// RAW_32 could be encoded as RAW_16
|
||||
byte[] longest16 = new byte[Short.MAX_VALUE];
|
||||
String long16Hex = StringUtils.toHexString(longest16);
|
||||
setContents("52" + "7FFF" + long16Hex + "54" + "00007FFF" + long16Hex);
|
||||
assertArrayEquals(longest16, r.readRaw(Integer.MAX_VALUE));
|
||||
try {
|
||||
r.readRaw(Integer.MAX_VALUE);
|
||||
fail();
|
||||
} catch (FormatException expected) {}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadList() throws Exception {
|
||||
// A list containing 1, "foo", and 128
|
||||
@@ -499,44 +423,45 @@ public class ReaderImplTest extends BriarTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadMap() throws Exception {
|
||||
// A map containing "foo" -> 123 and "bar" -> null
|
||||
public void testReadDictionary() throws Exception {
|
||||
// A dictionary containing "foo" -> 123 and "bar" -> null
|
||||
setContents("70" + "41" + "03" + "666F6F" + "21" + "7B" +
|
||||
"41" + "03" + "626172" + "00" + "80");
|
||||
r.readMapStart();
|
||||
assertFalse(r.hasMapEnd());
|
||||
r.readDictionaryStart();
|
||||
assertFalse(r.hasDictionaryEnd());
|
||||
assertEquals("foo", r.readString(1000));
|
||||
assertFalse(r.hasMapEnd());
|
||||
assertFalse(r.hasDictionaryEnd());
|
||||
assertEquals(123, r.readInteger());
|
||||
assertFalse(r.hasMapEnd());
|
||||
assertFalse(r.hasDictionaryEnd());
|
||||
assertEquals("bar", r.readString(1000));
|
||||
assertFalse(r.hasMapEnd());
|
||||
assertFalse(r.hasDictionaryEnd());
|
||||
assertTrue(r.hasNull());
|
||||
r.readNull();
|
||||
assertTrue(r.hasMapEnd());
|
||||
r.readMapEnd();
|
||||
assertTrue(r.hasDictionaryEnd());
|
||||
r.readDictionaryEnd();
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipMap() throws Exception {
|
||||
public void testSkipDictionary() throws Exception {
|
||||
// A map containing "foo" -> 123 and "bar" -> null
|
||||
setContents("70" + "41" + "03" + "666F6F" + "21" + "7B" +
|
||||
"41" + "03" + "626172" + "00" + "80");
|
||||
r.skipMap();
|
||||
r.skipDictionary();
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipNestedListsAndMaps() throws Exception {
|
||||
// A list containing a map containing two empty lists
|
||||
setContents("60" + "70" + "60" + "80" + "60" + "80" + "80" + "80");
|
||||
public void testSkipNestedListsAndDictionaries() throws Exception {
|
||||
// A list containing a dictionary containing "" -> an empty list
|
||||
setContents("60" + "70" + "4100" + "60" + "80" + "80" + "80");
|
||||
r.skipList();
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
private void setContents(String hex) {
|
||||
in = new ByteArrayInputStream(StringUtils.fromHexString(hex));
|
||||
r = new ReaderImpl(in);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(
|
||||
StringUtils.fromHexString(hex));
|
||||
r = new BdfReaderImpl(in);
|
||||
}
|
||||
}
|
||||
@@ -16,15 +16,15 @@ import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class WriterImplTest extends BriarTestCase {
|
||||
public class BdfWriterImplTest extends BriarTestCase {
|
||||
|
||||
private ByteArrayOutputStream out = null;
|
||||
private WriterImpl w = null;
|
||||
private BdfWriterImpl w = null;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
out = new ByteArrayOutputStream();
|
||||
w = new WriterImpl(out);
|
||||
w = new BdfWriterImpl(out);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,12 +165,12 @@ public class WriterImplTest extends BriarTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteMap() throws IOException {
|
||||
public void testWriteDictionary() throws IOException {
|
||||
// Use LinkedHashMap to get predictable iteration order
|
||||
Map<String, Object> m = new LinkedHashMap<String, Object>();
|
||||
for (int i = 0; i < 4; i++) m.put(String.valueOf(i), i);
|
||||
w.writeMap(m);
|
||||
// MAP tag, keys as strings and values as integers, END tag
|
||||
w.writeDictionary(m);
|
||||
// DICTIONARY tag, keys as strings and values as integers, END tag
|
||||
checkContents("70" + "41" + "01" + "30" + "21" + "00" +
|
||||
"41" + "01" + "31" + "21" + "01" +
|
||||
"41" + "01" + "32" + "21" + "02" +
|
||||
@@ -191,21 +191,21 @@ public class WriterImplTest extends BriarTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteDelimitedMap() throws IOException {
|
||||
w.writeMapStart();
|
||||
public void testWriteDelimitedDictionary() throws IOException {
|
||||
w.writeDictionaryStart();
|
||||
w.writeString("foo");
|
||||
w.writeInteger(123);
|
||||
w.writeString("bar");
|
||||
w.writeNull();
|
||||
w.writeMapEnd();
|
||||
// MAP tag, "foo" as string, 123 as integer, "bar" as string,
|
||||
w.writeDictionaryEnd();
|
||||
// DICTIONARY tag, "foo" as string, 123 as integer, "bar" as string,
|
||||
// NULL tag, END tag
|
||||
checkContents("70" + "41" + "03" + "666F6F" +
|
||||
"21" + "7B" + "41" + "03" + "626172" + "00" + "80");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteNestedMapsAndLists() throws IOException {
|
||||
public void testWriteNestedDictionariesAndLists() throws IOException {
|
||||
Map<String, Object> inner = new LinkedHashMap<String, Object>();
|
||||
inner.put("bar", new byte[0]);
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
@@ -213,9 +213,9 @@ public class WriterImplTest extends BriarTestCase {
|
||||
list.add(inner);
|
||||
Map<String, Object> outer = new LinkedHashMap<String, Object>();
|
||||
outer.put("foo", list);
|
||||
w.writeMap(outer);
|
||||
// MAP tag, "foo" as string, LIST tag, 1 as integer, MAP tag,
|
||||
// "bar" as string, {} as raw, END tag, END tag, END tag
|
||||
w.writeDictionary(outer);
|
||||
// DICTIONARY tag, "foo" as string, LIST tag, 1 as integer,
|
||||
// DICTIONARY tag, "bar" as string, {} as raw, END tag, END tag, END tag
|
||||
checkContents("70" + "41" + "03" + "666F6F" + "60" +
|
||||
"21" + "01" + "70" + "41" + "03" + "626172" + "51" + "00" +
|
||||
"80" + "80" + "80");
|
||||
@@ -6,9 +6,9 @@ import com.google.inject.Injector;
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.data.ReaderFactory;
|
||||
import org.briarproject.api.data.Writer;
|
||||
import org.briarproject.api.data.WriterFactory;
|
||||
import org.briarproject.api.data.BdfReaderFactory;
|
||||
import org.briarproject.api.data.BdfWriter;
|
||||
import org.briarproject.api.data.BdfWriterFactory;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.util.ByteUtils;
|
||||
import org.junit.Test;
|
||||
@@ -30,13 +30,13 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
|
||||
// FIXME: This is an integration test, not a unit test
|
||||
|
||||
private final ReaderFactory readerFactory;
|
||||
private final WriterFactory writerFactory;
|
||||
private final BdfReaderFactory bdfReaderFactory;
|
||||
private final BdfWriterFactory bdfWriterFactory;
|
||||
|
||||
public PacketReaderImplTest() throws Exception {
|
||||
Injector i = Guice.createInjector(new DataModule());
|
||||
readerFactory = i.getInstance(ReaderFactory.class);
|
||||
writerFactory = i.getInstance(WriterFactory.class);
|
||||
bdfReaderFactory = i.getInstance(BdfReaderFactory.class);
|
||||
bdfWriterFactory = i.getInstance(BdfWriterFactory.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -44,7 +44,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createAck(true);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
try {
|
||||
reader.readAck();
|
||||
@@ -59,7 +60,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createAck(false);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
reader.readAck();
|
||||
}
|
||||
@@ -69,7 +71,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createEmptyAck();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
try {
|
||||
reader.readAck();
|
||||
@@ -84,7 +87,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createOffer(true);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
try {
|
||||
reader.readOffer();
|
||||
@@ -99,7 +103,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createOffer(false);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
reader.readOffer();
|
||||
}
|
||||
@@ -109,7 +114,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createEmptyOffer();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
try {
|
||||
reader.readOffer();
|
||||
@@ -124,7 +130,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createRequest(true);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
try {
|
||||
reader.readRequest();
|
||||
@@ -139,7 +146,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createRequest(false);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
reader.readRequest();
|
||||
}
|
||||
@@ -149,7 +157,8 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
byte[] b = createEmptyRequest();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
org.briarproject.sync.PacketReaderImpl
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(readerFactory, null,
|
||||
reader = new org.briarproject.sync.PacketReaderImpl(
|
||||
bdfReaderFactory, null,
|
||||
null, in);
|
||||
try {
|
||||
reader.readRequest();
|
||||
@@ -162,7 +171,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
private byte[] createAck(boolean tooBig) throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
out.write(new byte[HEADER_LENGTH]);
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
BdfWriter w = bdfWriterFactory.createWriter(out);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
while (out.size() + UNIQUE_ID_LENGTH + LIST_END_LENGTH * 2
|
||||
@@ -182,7 +191,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
private byte[] createEmptyAck() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
out.write(new byte[HEADER_LENGTH]);
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
BdfWriter w = bdfWriterFactory.createWriter(out);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
w.writeListEnd();
|
||||
@@ -196,7 +205,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
private byte[] createOffer(boolean tooBig) throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
out.write(new byte[HEADER_LENGTH]);
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
BdfWriter w = bdfWriterFactory.createWriter(out);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
while (out.size() + UNIQUE_ID_LENGTH + LIST_END_LENGTH * 2
|
||||
@@ -216,7 +225,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
private byte[] createEmptyOffer() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
out.write(new byte[HEADER_LENGTH]);
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
BdfWriter w = bdfWriterFactory.createWriter(out);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
w.writeListEnd();
|
||||
@@ -230,7 +239,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
private byte[] createRequest(boolean tooBig) throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
out.write(new byte[HEADER_LENGTH]);
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
BdfWriter w = bdfWriterFactory.createWriter(out);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
while (out.size() + UNIQUE_ID_LENGTH + LIST_END_LENGTH * 2
|
||||
@@ -250,7 +259,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
private byte[] createEmptyRequest() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
out.write(new byte[HEADER_LENGTH]);
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
BdfWriter w = bdfWriterFactory.createWriter(out);
|
||||
w.writeListStart();
|
||||
w.writeListStart();
|
||||
w.writeListEnd();
|
||||
|
||||
Reference in New Issue
Block a user