Retrieve messages from the database in raw form to avoid creating unnecessary short-lived objects. Added timestamps to headers.

This commit is contained in:
akwizgran
2011-07-14 12:01:35 +01:00
parent d4382fd232
commit 836d30f6df
32 changed files with 202 additions and 197 deletions

View File

@@ -11,6 +11,7 @@ import java.util.Map.Entry;
import junit.framework.TestCase;
import net.sf.briar.api.serial.FormatException;
import net.sf.briar.api.serial.Raw;
import net.sf.briar.api.serial.RawByteArray;
import net.sf.briar.util.StringUtils;
import org.junit.Test;
@@ -222,7 +223,7 @@ public class ReaderImplTest extends TestCase {
assertNotNull(m);
assertEquals(2, m.size());
assertEquals((byte) 123, m.get("foo"));
Raw raw = new RawImpl(new byte[] {});
Raw raw = new RawByteArray(new byte[] {});
assertTrue(m.containsKey(raw));
assertNull(m.get(raw));
assertTrue(r.eof());
@@ -287,7 +288,7 @@ public class ReaderImplTest extends TestCase {
assertNotNull(m);
assertEquals(2, m.size());
assertEquals((byte) 123, m.get("foo"));
Raw raw = new RawImpl(new byte[] {});
Raw raw = new RawByteArray(new byte[] {});
assertTrue(m.containsKey(raw));
assertNull(m.get(raw));
assertTrue(r.eof());

View File

@@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
import net.sf.briar.api.serial.RawByteArray;
import net.sf.briar.util.StringUtils;
import org.junit.Before;
@@ -141,7 +142,7 @@ public class WriterImplTest extends TestCase {
@Test
public void testWriteRawObject() throws IOException {
w.writeRaw(new RawImpl(new byte[] {0, 1, -1, 127, -128}));
w.writeRaw(new RawByteArray(new byte[] {0, 1, -1, 127, -128}));
checkContents("F6" + "05" + "0001FF7F80");
}
@@ -160,7 +161,7 @@ public class WriterImplTest extends TestCase {
// Use LinkedHashMap to get predictable iteration order
Map<Object, Object> m = new LinkedHashMap<Object, Object>();
m.put("foo", Integer.valueOf(123)); // Written as a uint7
m.put(new RawImpl(new byte[] {}), null); // Empty array != null
m.put(new RawByteArray(new byte[] {}), null); // Empty array != null
w.writeMap(m);
checkContents("F4" + "02" + "F703666F6F" + "7B" + "F600" + "F0");
}