mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Removed unnecessary Raw interface.
This commit is contained in:
@@ -106,12 +106,12 @@ public class AckReaderTest extends TestCase {
|
||||
while(out.size() < Ack.MAX_SIZE - BatchId.SERIALISED_LENGTH) {
|
||||
w.writeUserDefinedTag(Tags.BATCH_ID);
|
||||
random.nextBytes(b);
|
||||
w.writeRaw(b);
|
||||
w.writeBytes(b);
|
||||
}
|
||||
if(tooBig) {
|
||||
w.writeUserDefinedTag(Tags.BATCH_ID);
|
||||
random.nextBytes(b);
|
||||
w.writeRaw(b);
|
||||
w.writeBytes(b);
|
||||
}
|
||||
w.writeListEnd();
|
||||
assertEquals(tooBig, out.size() > Ack.MAX_SIZE);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class BatchReaderTest extends TestCase {
|
||||
w.writeListStart();
|
||||
// We're using a fake message reader, so it's OK to use a fake message
|
||||
w.writeUserDefinedTag(Tags.MESSAGE);
|
||||
w.writeRaw(new byte[size - 10]);
|
||||
w.writeBytes(new byte[size - 10]);
|
||||
w.writeListEnd();
|
||||
byte[] b = out.toByteArray();
|
||||
assertEquals(size, b.length);
|
||||
@@ -170,7 +170,7 @@ public class BatchReaderTest extends TestCase {
|
||||
|
||||
public Message readObject(Reader r) throws IOException {
|
||||
r.readUserDefinedTag(Tags.MESSAGE);
|
||||
r.readRaw();
|
||||
r.readBytes();
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ import junit.framework.TestCase;
|
||||
import net.sf.briar.api.serial.Consumer;
|
||||
import net.sf.briar.api.serial.FormatException;
|
||||
import net.sf.briar.api.serial.ObjectReader;
|
||||
import net.sf.briar.api.serial.Raw;
|
||||
import net.sf.briar.api.serial.RawByteArray;
|
||||
import net.sf.briar.api.serial.Bytes;
|
||||
import net.sf.briar.api.serial.Reader;
|
||||
import net.sf.briar.util.StringUtils;
|
||||
|
||||
@@ -134,12 +133,12 @@ public class ReaderImplTest extends TestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadRaw() throws Exception {
|
||||
public void testReadBytes() throws Exception {
|
||||
setContents("F603010203" + "93010203" + "F600" + "90");
|
||||
assertTrue(Arrays.equals(new byte[] {1, 2, 3}, r.readRaw()));
|
||||
assertTrue(Arrays.equals(new byte[] {1, 2, 3}, r.readRaw()));
|
||||
assertTrue(Arrays.equals(new byte[] {}, r.readRaw()));
|
||||
assertTrue(Arrays.equals(new byte[] {}, r.readRaw()));
|
||||
assertTrue(Arrays.equals(new byte[] {1, 2, 3}, r.readBytes()));
|
||||
assertTrue(Arrays.equals(new byte[] {1, 2, 3}, r.readBytes()));
|
||||
assertTrue(Arrays.equals(new byte[] {}, r.readBytes()));
|
||||
assertTrue(Arrays.equals(new byte[] {}, r.readBytes()));
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@@ -197,9 +196,9 @@ public class ReaderImplTest extends TestCase {
|
||||
assertNotNull(m);
|
||||
assertEquals(2, m.size());
|
||||
assertEquals((byte) 123, m.get("foo"));
|
||||
Raw raw = new RawByteArray(new byte[] {});
|
||||
assertTrue(m.containsKey(raw));
|
||||
assertNull(m.get(raw));
|
||||
Bytes b = new Bytes(new byte[] {});
|
||||
assertTrue(m.containsKey(b));
|
||||
assertNull(m.get(b));
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@@ -210,9 +209,9 @@ public class ReaderImplTest extends TestCase {
|
||||
assertNotNull(m);
|
||||
assertEquals(2, m.size());
|
||||
assertEquals((byte) 123, m.get("foo"));
|
||||
Raw raw = new RawByteArray(new byte[] {});
|
||||
assertTrue(m.containsKey(raw));
|
||||
assertNull(m.get(raw));
|
||||
Bytes b = new Bytes(new byte[] {});
|
||||
assertTrue(m.containsKey(b));
|
||||
assertNull(m.get(b));
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@@ -275,9 +274,9 @@ public class ReaderImplTest extends TestCase {
|
||||
assertNotNull(m);
|
||||
assertEquals(2, m.size());
|
||||
assertEquals((byte) 123, m.get("foo"));
|
||||
Raw raw = new RawByteArray(new byte[] {});
|
||||
assertTrue(m.containsKey(raw));
|
||||
assertNull(m.get(raw));
|
||||
Bytes b = new Bytes(new byte[] {});
|
||||
assertTrue(m.containsKey(b));
|
||||
assertNull(m.get(b));
|
||||
assertTrue(r.eof());
|
||||
}
|
||||
|
||||
@@ -291,7 +290,7 @@ public class ReaderImplTest extends TestCase {
|
||||
assertFalse(r.hasMapEnd());
|
||||
assertEquals((byte) 123, r.readIntAny());
|
||||
assertFalse(r.hasMapEnd());
|
||||
assertTrue(Arrays.equals(new byte[] {}, r.readRaw()));
|
||||
assertTrue(Arrays.equals(new byte[] {}, r.readBytes()));
|
||||
assertFalse(r.hasMapEnd());
|
||||
assertTrue(r.hasNull());
|
||||
r.readNull();
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.briar.api.serial.RawByteArray;
|
||||
import net.sf.briar.api.serial.Writable;
|
||||
import net.sf.briar.api.serial.Writer;
|
||||
import net.sf.briar.util.StringUtils;
|
||||
@@ -152,38 +151,20 @@ public class WriterImplTest extends TestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteShortRawBytes() throws IOException {
|
||||
w.writeRaw(new byte[] {
|
||||
public void testWriteShortBytes() throws IOException {
|
||||
w.writeBytes(new byte[] {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
|
||||
});
|
||||
// SHORT_RAW tag, length 15, raw bytes
|
||||
// SHORT_BYTES tag, length 15, bytes
|
||||
checkContents("9" + "F" + "000102030405060708090A0B0C0D0E");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteShortRawObject() throws IOException {
|
||||
w.writeRaw(new RawByteArray(new byte[] {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
|
||||
}));
|
||||
// SHORT_RAW tag, length 15, raw bytes
|
||||
checkContents("9" + "F" + "000102030405060708090A0B0C0D0E");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRawBytes() throws IOException {
|
||||
w.writeRaw(new byte[] {
|
||||
public void testWriteBytes() throws IOException {
|
||||
w.writeBytes(new byte[] {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
||||
});
|
||||
// RAW tag, length 16 as uint7, raw bytes
|
||||
checkContents("F6" + "10" + "000102030405060708090A0B0C0D0E0F");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRawObject() throws IOException {
|
||||
w.writeRaw(new RawByteArray(new byte[] {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
||||
}));
|
||||
// RAW tag, length 16 as uint7, raw bytes
|
||||
// BYTES tag, length 16 as uint7, bytes
|
||||
checkContents("F6" + "10" + "000102030405060708090A0B0C0D0E0F");
|
||||
}
|
||||
|
||||
@@ -257,11 +238,11 @@ public class WriterImplTest extends TestCase {
|
||||
w.writeMapStart();
|
||||
w.writeString("foo"); // Written as short string
|
||||
w.writeIntAny(123); // Written as a uint7
|
||||
w.writeRaw(new byte[] {}); // Written as short raw
|
||||
w.writeBytes(new byte[] {}); // Written as short bytes
|
||||
w.writeNull();
|
||||
w.writeMapEnd();
|
||||
// MAP_START tag, "foo" as short string, 123 as uint7,
|
||||
// byte[] {} as short raw, NULL tag, END tag
|
||||
// byte[] {} as short bytes, NULL tag, END tag
|
||||
checkContents("F2" + "83666F6F" + "7B" + "90" + "F0" + "F1");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user