mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Removed writer's count of bytes written and renamed a method.
This commit is contained in:
@@ -100,18 +100,18 @@ public class AckReaderTest extends TestCase {
|
||||
private byte[] createAck(boolean tooBig) throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
w.writeUserDefinedTag(Types.ACK);
|
||||
w.writeUserDefinedId(Types.ACK);
|
||||
w.writeListStart();
|
||||
byte[] b = new byte[UniqueId.LENGTH];
|
||||
Random random = new Random();
|
||||
while(out.size() + BatchId.LENGTH + 3
|
||||
< ProtocolConstants.MAX_PACKET_LENGTH) {
|
||||
w.writeUserDefinedTag(Types.BATCH_ID);
|
||||
w.writeUserDefinedId(Types.BATCH_ID);
|
||||
random.nextBytes(b);
|
||||
w.writeBytes(b);
|
||||
}
|
||||
if(tooBig) {
|
||||
w.writeUserDefinedTag(Types.BATCH_ID);
|
||||
w.writeUserDefinedId(Types.BATCH_ID);
|
||||
random.nextBytes(b);
|
||||
w.writeBytes(b);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class AckReaderTest extends TestCase {
|
||||
private byte[] createEmptyAck() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
w.writeUserDefinedTag(Types.ACK);
|
||||
w.writeUserDefinedId(Types.ACK);
|
||||
w.writeListStart();
|
||||
w.writeListEnd();
|
||||
return out.toByteArray();
|
||||
|
||||
@@ -143,10 +143,10 @@ public class BatchReaderTest extends TestCase {
|
||||
private byte[] createBatch(int size) throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(size);
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
w.writeUserDefinedTag(Types.BATCH);
|
||||
w.writeUserDefinedId(Types.BATCH);
|
||||
w.writeListStart();
|
||||
// We're using a fake message reader, so it's OK to use a fake message
|
||||
w.writeUserDefinedTag(Types.MESSAGE);
|
||||
w.writeUserDefinedId(Types.MESSAGE);
|
||||
w.writeBytes(new byte[size - 10]);
|
||||
w.writeListEnd();
|
||||
byte[] b = out.toByteArray();
|
||||
@@ -157,7 +157,7 @@ public class BatchReaderTest extends TestCase {
|
||||
private byte[] createEmptyBatch() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
w.writeUserDefinedTag(Types.BATCH);
|
||||
w.writeUserDefinedId(Types.BATCH);
|
||||
w.writeListStart();
|
||||
w.writeListEnd();
|
||||
return out.toByteArray();
|
||||
|
||||
@@ -115,7 +115,7 @@ public class RequestReaderTest extends TestCase {
|
||||
private byte[] createRequest(boolean tooBig) throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
w.writeUserDefinedTag(Types.REQUEST);
|
||||
w.writeUserDefinedId(Types.REQUEST);
|
||||
// Allow one byte for the REQUEST tag, one byte for the BYTES tag,
|
||||
// and five bytes for the length as an int32
|
||||
int size = ProtocolConstants.MAX_PACKET_LENGTH - 7;
|
||||
@@ -128,7 +128,7 @@ public class RequestReaderTest extends TestCase {
|
||||
private byte[] createRequest(byte[] bitmap) throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Writer w = writerFactory.createWriter(out);
|
||||
w.writeUserDefinedTag(Types.REQUEST);
|
||||
w.writeUserDefinedId(Types.REQUEST);
|
||||
w.writeBytes(bitmap);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
@@ -269,8 +269,8 @@ public class WriterImplTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testWriteShortUserDefinedTag() throws IOException {
|
||||
w.writeUserDefinedTag(0);
|
||||
w.writeUserDefinedTag(31);
|
||||
w.writeUserDefinedId(0);
|
||||
w.writeUserDefinedId(31);
|
||||
// SHORT_USER tag (3 bits), 0 (5 bits), SHORT_USER tag (3 bits),
|
||||
// 31 (5 bits)
|
||||
checkContents("C0" + "DF");
|
||||
@@ -278,8 +278,8 @@ public class WriterImplTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testWriteUserDefinedTag() throws IOException {
|
||||
w.writeUserDefinedTag(32);
|
||||
w.writeUserDefinedTag(255);
|
||||
w.writeUserDefinedId(32);
|
||||
w.writeUserDefinedId(255);
|
||||
// USER tag, 32 as uint8, USER tag, 255 as uint8
|
||||
checkContents("EF" + "20" + "EF" + "FF");
|
||||
}
|
||||
@@ -288,7 +288,7 @@ public class WriterImplTest extends TestCase {
|
||||
public void testWriteCollectionOfWritables() throws IOException {
|
||||
Writable writable = new Writable() {
|
||||
public void writeTo(Writer w) throws IOException {
|
||||
w.writeUserDefinedTag(0);
|
||||
w.writeUserDefinedId(0);
|
||||
w.writeString("foo");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user