mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 14:49:53 +01:00
Retrieve messages from the database in raw form to avoid creating unnecessary short-lived objects. Added timestamps to headers.
This commit is contained in:
@@ -4,6 +4,8 @@ import java.io.IOException;
|
|||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sf.briar.api.serial.Raw;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for writing a bundle of acknowledgements, subscriptions,
|
* An interface for writing a bundle of acknowledgements, subscriptions,
|
||||||
* transport details and batches.
|
* transport details and batches.
|
||||||
@@ -18,8 +20,8 @@ public interface BundleWriter {
|
|||||||
Map<String, String> transports) throws IOException,
|
Map<String, String> transports) throws IOException,
|
||||||
GeneralSecurityException;
|
GeneralSecurityException;
|
||||||
|
|
||||||
/** Adds a batch to the bundle and returns its identifier. */
|
/** Adds a batch of messages to the bundle and returns its identifier. */
|
||||||
BatchId addBatch(Iterable<Message> messages) throws IOException,
|
BatchId addBatch(Iterable<Raw> messages) throws IOException,
|
||||||
GeneralSecurityException;
|
GeneralSecurityException;
|
||||||
|
|
||||||
/** Finishes writing the bundle. */
|
/** Finishes writing the bundle. */
|
||||||
|
|||||||
@@ -16,4 +16,7 @@ public interface Header {
|
|||||||
|
|
||||||
/** Returns the transport details contained in the header. */
|
/** Returns the transport details contained in the header. */
|
||||||
Map<String, String> getTransports();
|
Map<String, String> getTransports();
|
||||||
|
|
||||||
|
/** Returns the header's timestamp. */
|
||||||
|
long getTimestamp();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.sf.briar.api.protocol;
|
|
||||||
|
|
||||||
public interface MessageFactory {
|
|
||||||
|
|
||||||
Message createMessage(MessageId id, MessageId parent, GroupId group,
|
|
||||||
AuthorId author, long timestamp, byte[] raw);
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package net.sf.briar.serial;
|
package net.sf.briar.api.serial;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import net.sf.briar.api.serial.Raw;
|
|
||||||
|
|
||||||
class RawImpl implements Raw {
|
/** A byte array wrapped in the Raw interface. */
|
||||||
|
public class RawByteArray implements Raw {
|
||||||
|
|
||||||
private final byte[] bytes;
|
private final byte[] bytes;
|
||||||
|
|
||||||
RawImpl(byte[] bytes) {
|
public RawByteArray(byte[] bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,11 +158,11 @@ interface Database<T> {
|
|||||||
Set<BatchId> getLostBatches(T txn, ContactId c) throws DbException;
|
Set<BatchId> getLostBatches(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the message identified by the given ID.
|
* Returns the message identified by the given ID, in raw format.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: messages read.
|
* Locking: messages read.
|
||||||
*/
|
*/
|
||||||
Message getMessage(T txn, MessageId m) throws DbException;
|
byte[] getMessage(T txn, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the IDs of all messages signed by the given author.
|
* Returns the IDs of all messages signed by the given author.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
public class DatabaseCleanerImpl implements DatabaseCleaner, Runnable {
|
class DatabaseCleanerImpl implements DatabaseCleaner, Runnable {
|
||||||
|
|
||||||
private final Callback db;
|
private final Callback db;
|
||||||
private final int msBetweenSweeps;
|
private final int msBetweenSweeps;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import java.util.logging.Logger;
|
|||||||
import net.sf.briar.api.crypto.Password;
|
import net.sf.briar.api.crypto.Password;
|
||||||
import net.sf.briar.api.db.DatabasePassword;
|
import net.sf.briar.api.db.DatabasePassword;
|
||||||
import net.sf.briar.api.db.DbException;
|
import net.sf.briar.api.db.DbException;
|
||||||
import net.sf.briar.api.protocol.MessageFactory;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
@@ -28,9 +27,8 @@ class H2Database extends JdbcDatabase {
|
|||||||
private final long maxSize;
|
private final long maxSize;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
H2Database(File dir, MessageFactory messageFactory,
|
H2Database(File dir, @DatabasePassword Password password, long maxSize) {
|
||||||
@DatabasePassword Password password, long maxSize) {
|
super("BINARY(32)", "BIGINT");
|
||||||
super(messageFactory, "BINARY(32)", "BIGINT");
|
|
||||||
home = new File(dir, "db");
|
home = new File(dir, "db");
|
||||||
this.password = password;
|
this.password = password;
|
||||||
url = "jdbc:h2:split:" + home.getPath()
|
url = "jdbc:h2:split:" + home.getPath()
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import net.sf.briar.api.protocol.AuthorId;
|
|||||||
import net.sf.briar.api.protocol.BatchId;
|
import net.sf.briar.api.protocol.BatchId;
|
||||||
import net.sf.briar.api.protocol.GroupId;
|
import net.sf.briar.api.protocol.GroupId;
|
||||||
import net.sf.briar.api.protocol.Message;
|
import net.sf.briar.api.protocol.Message;
|
||||||
import net.sf.briar.api.protocol.MessageFactory;
|
|
||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
import net.sf.briar.util.FileUtils;
|
import net.sf.briar.util.FileUtils;
|
||||||
|
|
||||||
@@ -157,7 +156,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(JdbcDatabase.class.getName());
|
Logger.getLogger(JdbcDatabase.class.getName());
|
||||||
|
|
||||||
private final MessageFactory messageFactory;
|
|
||||||
// Different database libraries use different names for certain types
|
// Different database libraries use different names for certain types
|
||||||
private final String hashType, bigIntType;
|
private final String hashType, bigIntType;
|
||||||
private final LinkedList<Connection> connections =
|
private final LinkedList<Connection> connections =
|
||||||
@@ -168,9 +166,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
|
|
||||||
protected abstract Connection createConnection() throws SQLException;
|
protected abstract Connection createConnection() throws SQLException;
|
||||||
|
|
||||||
JdbcDatabase(MessageFactory messageFactory, String hashType,
|
JdbcDatabase(String hashType, String bigIntType) {
|
||||||
String bigIntType) {
|
|
||||||
this.messageFactory = messageFactory;
|
|
||||||
this.hashType = hashType;
|
this.hashType = hashType;
|
||||||
this.bigIntType = bigIntType;
|
this.bigIntType = bigIntType;
|
||||||
}
|
}
|
||||||
@@ -683,32 +679,25 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message getMessage(Connection txn, MessageId m) throws DbException {
|
public byte[] getMessage(Connection txn, MessageId m) throws DbException {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
String sql =
|
String sql = "SELECT size, raw FROM messages WHERE messageId = ?";
|
||||||
"SELECT parentId, groupId, authorId, timestamp, size, raw"
|
|
||||||
+ " FROM messages WHERE messageId = ?";
|
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
ps.setBytes(1, m.getBytes());
|
ps.setBytes(1, m.getBytes());
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
boolean found = rs.next();
|
boolean found = rs.next();
|
||||||
assert found;
|
assert found;
|
||||||
MessageId parent = new MessageId(rs.getBytes(1));
|
int size = rs.getInt(1);
|
||||||
GroupId group = new GroupId(rs.getBytes(2));
|
Blob b = rs.getBlob(2);
|
||||||
AuthorId author = new AuthorId(rs.getBytes(3));
|
|
||||||
long timestamp = rs.getLong(4);
|
|
||||||
int size = rs.getInt(5);
|
|
||||||
Blob b = rs.getBlob(6);
|
|
||||||
byte[] raw = b.getBytes(1, size);
|
byte[] raw = b.getBytes(1, size);
|
||||||
assert raw.length == size;
|
assert raw.length == size;
|
||||||
boolean more = rs.next();
|
boolean more = rs.next();
|
||||||
assert !more;
|
assert !more;
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
return messageFactory.createMessage(m, parent, group, author,
|
return raw;
|
||||||
timestamp, raw);
|
|
||||||
} catch(SQLException e) {
|
} catch(SQLException e) {
|
||||||
tryToClose(rs);
|
tryToClose(rs);
|
||||||
tryToClose(ps);
|
tryToClose(ps);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import net.sf.briar.api.protocol.GroupId;
|
|||||||
import net.sf.briar.api.protocol.Header;
|
import net.sf.briar.api.protocol.Header;
|
||||||
import net.sf.briar.api.protocol.Message;
|
import net.sf.briar.api.protocol.Message;
|
||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
|
import net.sf.briar.api.serial.Raw;
|
||||||
|
import net.sf.briar.api.serial.RawByteArray;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
@@ -282,8 +284,8 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
try {
|
try {
|
||||||
Txn txn = db.startTransaction();
|
Txn txn = db.startTransaction();
|
||||||
try {
|
try {
|
||||||
long capacity = Math.min(b.getRemainingCapacity(),
|
long capacity =
|
||||||
Batch.MAX_SIZE);
|
Math.min(b.getRemainingCapacity(), Batch.MAX_SIZE);
|
||||||
Iterator<MessageId> it =
|
Iterator<MessageId> it =
|
||||||
db.getSendableMessages(txn, c, capacity).iterator();
|
db.getSendableMessages(txn, c, capacity).iterator();
|
||||||
if(!it.hasNext()) {
|
if(!it.hasNext()) {
|
||||||
@@ -291,12 +293,12 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
return false; // No more messages to send
|
return false; // No more messages to send
|
||||||
}
|
}
|
||||||
sent = new HashSet<MessageId>();
|
sent = new HashSet<MessageId>();
|
||||||
List<Message> messages = new ArrayList<Message>();
|
List<Raw> messages = new ArrayList<Raw>();
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
MessageId m = it.next();
|
MessageId m = it.next();
|
||||||
Message message = db.getMessage(txn, m);
|
byte[] message = db.getMessage(txn, m);
|
||||||
bytesSent += message.getSize();
|
bytesSent += message.length;
|
||||||
messages.add(message);
|
messages.add(new RawByteArray(message));
|
||||||
sent.add(m);
|
sent.add(m);
|
||||||
}
|
}
|
||||||
batchId = b.addBatch(messages);
|
batchId = b.addBatch(messages);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import net.sf.briar.api.protocol.GroupId;
|
|||||||
import net.sf.briar.api.protocol.Header;
|
import net.sf.briar.api.protocol.Header;
|
||||||
import net.sf.briar.api.protocol.Message;
|
import net.sf.briar.api.protocol.Message;
|
||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
|
import net.sf.briar.api.serial.Raw;
|
||||||
|
import net.sf.briar.api.serial.RawByteArray;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
@@ -212,8 +214,8 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
synchronized(messageStatusLock) {
|
synchronized(messageStatusLock) {
|
||||||
Txn txn = db.startTransaction();
|
Txn txn = db.startTransaction();
|
||||||
try {
|
try {
|
||||||
long capacity = Math.min(b.getRemainingCapacity(),
|
long capacity =
|
||||||
Batch.MAX_SIZE);
|
Math.min(b.getRemainingCapacity(), Batch.MAX_SIZE);
|
||||||
Iterator<MessageId> it =
|
Iterator<MessageId> it =
|
||||||
db.getSendableMessages(txn, c, capacity).iterator();
|
db.getSendableMessages(txn, c, capacity).iterator();
|
||||||
if(!it.hasNext()) {
|
if(!it.hasNext()) {
|
||||||
@@ -221,13 +223,13 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
return false; // No more messages to send
|
return false; // No more messages to send
|
||||||
}
|
}
|
||||||
Set<MessageId> sent = new HashSet<MessageId>();
|
Set<MessageId> sent = new HashSet<MessageId>();
|
||||||
List<Message> messages = new ArrayList<Message>();
|
List<Raw> messages = new ArrayList<Raw>();
|
||||||
int bytesSent = 0;
|
int bytesSent = 0;
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
MessageId m = it.next();
|
MessageId m = it.next();
|
||||||
Message message = db.getMessage(txn, m);
|
byte[] message = db.getMessage(txn, m);
|
||||||
bytesSent += message.getSize();
|
bytesSent += message.length;
|
||||||
messages.add(message);
|
messages.add(new RawByteArray(message));
|
||||||
sent.add(m);
|
sent.add(m);
|
||||||
}
|
}
|
||||||
BatchId batchId = b.addBatch(messages);
|
BatchId batchId = b.addBatch(messages);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import javax.swing.UIManager;
|
|||||||
import net.sf.briar.api.i18n.FontManager;
|
import net.sf.briar.api.i18n.FontManager;
|
||||||
import net.sf.briar.util.FileUtils;
|
import net.sf.briar.util.FileUtils;
|
||||||
|
|
||||||
|
// Needs to be public for installer
|
||||||
public class FontManagerImpl implements FontManager {
|
public class FontManagerImpl implements FontManager {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import net.sf.briar.api.i18n.FontManager;
|
|||||||
import net.sf.briar.api.i18n.I18n;
|
import net.sf.briar.api.i18n.I18n;
|
||||||
import net.sf.briar.util.FileUtils;
|
import net.sf.briar.util.FileUtils;
|
||||||
|
|
||||||
|
// Needs to be public for installer
|
||||||
public class I18nImpl implements I18n {
|
public class I18nImpl implements I18n {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.sf.briar.api.protocol.Batch;
|
|||||||
import net.sf.briar.api.protocol.BatchId;
|
import net.sf.briar.api.protocol.BatchId;
|
||||||
import net.sf.briar.api.protocol.Message;
|
import net.sf.briar.api.protocol.Message;
|
||||||
|
|
||||||
public class BatchFactoryImpl implements BatchFactory {
|
class BatchFactoryImpl implements BatchFactory {
|
||||||
|
|
||||||
public Batch createBatch(BatchId id, List<Message> messages) {
|
public Batch createBatch(BatchId id, List<Message> messages) {
|
||||||
return new BatchImpl(id, messages);
|
return new BatchImpl(id, messages);
|
||||||
|
|||||||
@@ -81,12 +81,13 @@ class BundleReaderImpl implements BundleReader {
|
|||||||
}
|
}
|
||||||
Map<String, String> transports =
|
Map<String, String> transports =
|
||||||
r.readMap(String.class, String.class);
|
r.readMap(String.class, String.class);
|
||||||
|
long timestamp = r.readInt64();
|
||||||
in.setSigning(false);
|
in.setSigning(false);
|
||||||
// Read and verify the signature
|
// Read and verify the signature
|
||||||
byte[] sig = r.readRaw();
|
byte[] sig = r.readRaw();
|
||||||
if(!signature.verify(sig)) throw new SignatureException();
|
if(!signature.verify(sig)) throw new SignatureException();
|
||||||
// Build and return the header
|
// Build and return the header
|
||||||
return headerFactory.createHeader(acks, subs, transports);
|
return headerFactory.createHeader(acks, subs, transports, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Batch getNextBatch() throws IOException, GeneralSecurityException {
|
public Batch getNextBatch() throws IOException, GeneralSecurityException {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
import net.sf.briar.api.protocol.BatchId;
|
import net.sf.briar.api.protocol.BatchId;
|
||||||
import net.sf.briar.api.protocol.BundleWriter;
|
import net.sf.briar.api.protocol.BundleWriter;
|
||||||
import net.sf.briar.api.protocol.GroupId;
|
import net.sf.briar.api.protocol.GroupId;
|
||||||
import net.sf.briar.api.protocol.Message;
|
import net.sf.briar.api.serial.Raw;
|
||||||
import net.sf.briar.api.serial.Writer;
|
import net.sf.briar.api.serial.Writer;
|
||||||
import net.sf.briar.api.serial.WriterFactory;
|
import net.sf.briar.api.serial.WriterFactory;
|
||||||
|
|
||||||
@@ -59,6 +59,7 @@ class BundleWriterImpl implements BundleWriter {
|
|||||||
for(GroupId sub : subs) w.writeRaw(sub);
|
for(GroupId sub : subs) w.writeRaw(sub);
|
||||||
w.writeListEnd();
|
w.writeListEnd();
|
||||||
w.writeMap(transports);
|
w.writeMap(transports);
|
||||||
|
w.writeInt64(System.currentTimeMillis());
|
||||||
out.setSigning(false);
|
out.setSigning(false);
|
||||||
// Create and write the signature
|
// Create and write the signature
|
||||||
byte[] sig = signature.sign();
|
byte[] sig = signature.sign();
|
||||||
@@ -67,7 +68,7 @@ class BundleWriterImpl implements BundleWriter {
|
|||||||
state = State.FIRST_BATCH;
|
state = State.FIRST_BATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BatchId addBatch(Iterable<Message> messages) throws IOException,
|
public BatchId addBatch(Iterable<Raw> messages) throws IOException,
|
||||||
GeneralSecurityException {
|
GeneralSecurityException {
|
||||||
if(state == State.FIRST_BATCH) {
|
if(state == State.FIRST_BATCH) {
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
@@ -81,7 +82,7 @@ class BundleWriterImpl implements BundleWriter {
|
|||||||
out.setDigesting(true);
|
out.setDigesting(true);
|
||||||
out.setSigning(true);
|
out.setSigning(true);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
for(Message m : messages) w.writeRaw(m);
|
for(Raw message : messages) w.writeRaw(message);
|
||||||
w.writeListEnd();
|
w.writeListEnd();
|
||||||
out.setSigning(false);
|
out.setSigning(false);
|
||||||
// Create and write the signature
|
// Create and write the signature
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ import net.sf.briar.api.protocol.Header;
|
|||||||
interface HeaderFactory {
|
interface HeaderFactory {
|
||||||
|
|
||||||
Header createHeader(Set<BatchId> acks, Set<GroupId> subs,
|
Header createHeader(Set<BatchId> acks, Set<GroupId> subs,
|
||||||
Map<String, String> transports);
|
Map<String, String> transports, long timestamp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.sf.briar.api.protocol.Header;
|
|||||||
class HeaderFactoryImpl implements HeaderFactory {
|
class HeaderFactoryImpl implements HeaderFactory {
|
||||||
|
|
||||||
public Header createHeader(Set<BatchId> acks, Set<GroupId> subs,
|
public Header createHeader(Set<BatchId> acks, Set<GroupId> subs,
|
||||||
Map<String, String> transports) {
|
Map<String, String> transports, long timestamp) {
|
||||||
return new HeaderImpl(acks, subs, transports);
|
return new HeaderImpl(acks, subs, transports, timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ class HeaderImpl implements Header {
|
|||||||
private final Set<BatchId> acks;
|
private final Set<BatchId> acks;
|
||||||
private final Set<GroupId> subs;
|
private final Set<GroupId> subs;
|
||||||
private final Map<String, String> transports;
|
private final Map<String, String> transports;
|
||||||
|
private final long timestamp;
|
||||||
|
|
||||||
HeaderImpl(Set<BatchId> acks, Set<GroupId> subs,
|
HeaderImpl(Set<BatchId> acks, Set<GroupId> subs,
|
||||||
Map<String, String> transports) {
|
Map<String, String> transports, long timestamp) {
|
||||||
this.acks = acks;
|
this.acks = acks;
|
||||||
this.subs = subs;
|
this.subs = subs;
|
||||||
this.transports = transports;
|
this.transports = transports;
|
||||||
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<BatchId> getAcks() {
|
public Set<BatchId> getAcks() {
|
||||||
@@ -32,4 +34,8 @@ class HeaderImpl implements Header {
|
|||||||
public Map<String, String> getTransports() {
|
public Map<String, String> getTransports() {
|
||||||
return transports;
|
return transports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.sf.briar.api.protocol.Message;
|
|||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
|
|
||||||
/** A simple in-memory implementation of a message. */
|
/** A simple in-memory implementation of a message. */
|
||||||
public class MessageImpl implements Message {
|
class MessageImpl implements Message {
|
||||||
|
|
||||||
private final MessageId id, parent;
|
private final MessageId id, parent;
|
||||||
private final GroupId group;
|
private final GroupId group;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.io.InputStream;
|
|||||||
import net.sf.briar.api.serial.Reader;
|
import net.sf.briar.api.serial.Reader;
|
||||||
import net.sf.briar.api.serial.ReaderFactory;
|
import net.sf.briar.api.serial.ReaderFactory;
|
||||||
|
|
||||||
public class ReaderFactoryImpl implements ReaderFactory {
|
class ReaderFactoryImpl implements ReaderFactory {
|
||||||
|
|
||||||
public Reader createReader(InputStream in) {
|
public Reader createReader(InputStream in) {
|
||||||
return new ReaderImpl(in);
|
return new ReaderImpl(in);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.briar.api.serial.FormatException;
|
import net.sf.briar.api.serial.FormatException;
|
||||||
|
import net.sf.briar.api.serial.RawByteArray;
|
||||||
import net.sf.briar.api.serial.Reader;
|
import net.sf.briar.api.serial.Reader;
|
||||||
import net.sf.briar.api.serial.Tag;
|
import net.sf.briar.api.serial.Tag;
|
||||||
|
|
||||||
@@ -308,7 +309,7 @@ class ReaderImpl implements Reader {
|
|||||||
if(hasFloat32()) return Float.valueOf(readFloat32());
|
if(hasFloat32()) return Float.valueOf(readFloat32());
|
||||||
if(hasFloat64()) return Double.valueOf(readFloat64());
|
if(hasFloat64()) return Double.valueOf(readFloat64());
|
||||||
if(hasUtf8()) return readUtf8();
|
if(hasUtf8()) return readUtf8();
|
||||||
if(hasRaw()) return new RawImpl(readRaw());
|
if(hasRaw()) return new RawByteArray(readRaw());
|
||||||
if(hasList()) return readList();
|
if(hasList()) return readList();
|
||||||
if(hasMap()) return readMap();
|
if(hasMap()) return readMap();
|
||||||
if(hasNull()) {
|
if(hasNull()) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.io.OutputStream;
|
|||||||
import net.sf.briar.api.serial.Writer;
|
import net.sf.briar.api.serial.Writer;
|
||||||
import net.sf.briar.api.serial.WriterFactory;
|
import net.sf.briar.api.serial.WriterFactory;
|
||||||
|
|
||||||
public class WriterFactoryImpl implements WriterFactory {
|
class WriterFactoryImpl implements WriterFactory {
|
||||||
|
|
||||||
public Writer createWriter(OutputStream out) {
|
public Writer createWriter(OutputStream out) {
|
||||||
return new WriterImpl(out);
|
return new WriterImpl(out);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.sf.briar.api.setup.SetupParameters;
|
|||||||
import net.sf.briar.api.setup.SetupWorkerFactory;
|
import net.sf.briar.api.setup.SetupWorkerFactory;
|
||||||
import net.sf.briar.util.FileUtils;
|
import net.sf.briar.util.FileUtils;
|
||||||
|
|
||||||
|
// Needs to be public for installer
|
||||||
public class SetupWorkerFactoryImpl implements SetupWorkerFactory {
|
public class SetupWorkerFactoryImpl implements SetupWorkerFactory {
|
||||||
|
|
||||||
private final I18n i18n;
|
private final I18n i18n;
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import net.sf.briar.api.protocol.GroupId;
|
|||||||
import net.sf.briar.api.protocol.Header;
|
import net.sf.briar.api.protocol.Header;
|
||||||
import net.sf.briar.api.protocol.Message;
|
import net.sf.briar.api.protocol.Message;
|
||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
import net.sf.briar.protocol.MessageImpl;
|
import net.sf.briar.api.serial.Raw;
|
||||||
|
import net.sf.briar.api.serial.RawByteArray;
|
||||||
|
|
||||||
import org.jmock.Expectations;
|
import org.jmock.Expectations;
|
||||||
import org.jmock.Mockery;
|
import org.jmock.Mockery;
|
||||||
@@ -37,7 +38,7 @@ public abstract class DatabaseComponentTest extends TestCase {
|
|||||||
protected final MessageId messageId, parentId;
|
protected final MessageId messageId, parentId;
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
private final int size;
|
private final int size;
|
||||||
private final byte[] body;
|
private final byte[] raw;
|
||||||
private final Message message;
|
private final Message message;
|
||||||
private final Set<ContactId> contacts;
|
private final Set<ContactId> contacts;
|
||||||
private final Set<BatchId> acks;
|
private final Set<BatchId> acks;
|
||||||
@@ -55,9 +56,9 @@ public abstract class DatabaseComponentTest extends TestCase {
|
|||||||
parentId = new MessageId(TestUtils.getRandomId());
|
parentId = new MessageId(TestUtils.getRandomId());
|
||||||
timestamp = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
size = 1234;
|
size = 1234;
|
||||||
body = new byte[size];
|
raw = new byte[size];
|
||||||
message = new MessageImpl(messageId, MessageId.NONE, groupId, authorId,
|
message = new TestMessage(messageId, MessageId.NONE, groupId, authorId,
|
||||||
timestamp, body);
|
timestamp, raw);
|
||||||
contacts = Collections.singleton(contactId);
|
contacts = Collections.singleton(contactId);
|
||||||
acks = Collections.singleton(batchId);
|
acks = Collections.singleton(batchId);
|
||||||
subs = Collections.singleton(groupId);
|
subs = Collections.singleton(groupId);
|
||||||
@@ -453,6 +454,7 @@ public abstract class DatabaseComponentTest extends TestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testGenerateBundle() throws Exception {
|
public void testGenerateBundle() throws Exception {
|
||||||
final long headerSize = 1234L;
|
final long headerSize = 1234L;
|
||||||
|
final Raw messageRaw = new RawByteArray(raw);
|
||||||
Mockery context = new Mockery();
|
Mockery context = new Mockery();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Database<Object> database = context.mock(Database.class);
|
final Database<Object> database = context.mock(Database.class);
|
||||||
@@ -482,9 +484,9 @@ public abstract class DatabaseComponentTest extends TestCase {
|
|||||||
Batch.MAX_SIZE - headerSize);
|
Batch.MAX_SIZE - headerSize);
|
||||||
will(returnValue(messages));
|
will(returnValue(messages));
|
||||||
oneOf(database).getMessage(txn, messageId);
|
oneOf(database).getMessage(txn, messageId);
|
||||||
will(returnValue(message));
|
will(returnValue(raw));
|
||||||
// Add the batch to the bundle
|
// Add the batch to the bundle
|
||||||
oneOf(bundleWriter).addBatch(Collections.singletonList(message));
|
oneOf(bundleWriter).addBatch(Collections.singletonList(messageRaw));
|
||||||
will(returnValue(batchId));
|
will(returnValue(batchId));
|
||||||
// Record the outstanding batch
|
// Record the outstanding batch
|
||||||
oneOf(database).addOutstandingBatch(
|
oneOf(database).addOutstandingBatch(
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ import net.sf.briar.api.protocol.AuthorId;
|
|||||||
import net.sf.briar.api.protocol.BatchId;
|
import net.sf.briar.api.protocol.BatchId;
|
||||||
import net.sf.briar.api.protocol.GroupId;
|
import net.sf.briar.api.protocol.GroupId;
|
||||||
import net.sf.briar.api.protocol.Message;
|
import net.sf.briar.api.protocol.Message;
|
||||||
import net.sf.briar.api.protocol.MessageFactory;
|
|
||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
import net.sf.briar.protocol.MessageImpl;
|
|
||||||
|
|
||||||
import org.jmock.Expectations;
|
import org.jmock.Expectations;
|
||||||
import org.jmock.Mockery;
|
import org.jmock.Mockery;
|
||||||
@@ -49,7 +47,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
private final MessageId messageId;
|
private final MessageId messageId;
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
private final int size;
|
private final int size;
|
||||||
private final byte[] body;
|
private final byte[] raw;
|
||||||
private final Message message;
|
private final Message message;
|
||||||
|
|
||||||
public H2DatabaseTest() {
|
public H2DatabaseTest() {
|
||||||
@@ -61,10 +59,10 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
messageId = new MessageId(TestUtils.getRandomId());
|
messageId = new MessageId(TestUtils.getRandomId());
|
||||||
timestamp = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
size = 1234;
|
size = 1234;
|
||||||
body = new byte[size];
|
raw = new byte[size];
|
||||||
random.nextBytes(body);
|
random.nextBytes(raw);
|
||||||
message = new MessageImpl(messageId, MessageId.NONE, groupId, authorId,
|
message = new TestMessage(messageId, MessageId.NONE, groupId, authorId,
|
||||||
timestamp, body);
|
timestamp, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -74,10 +72,8 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPersistence() throws DbException {
|
public void testPersistence() throws DbException {
|
||||||
MessageFactory messageFactory = new TestMessageFactory();
|
Database<Connection> db = open(false);
|
||||||
|
|
||||||
// Create a new database
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
// Store some records
|
// Store some records
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
assertFalse(db.containsContact(txn, contactId));
|
assertFalse(db.containsContact(txn, contactId));
|
||||||
@@ -94,7 +90,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
// Reopen the database
|
// Reopen the database
|
||||||
db = open(true, messageFactory);
|
db = open(true);
|
||||||
// Check that the records are still there
|
// Check that the records are still there
|
||||||
txn = db.startTransaction();
|
txn = db.startTransaction();
|
||||||
assertTrue(db.containsContact(txn, contactId));
|
assertTrue(db.containsContact(txn, contactId));
|
||||||
@@ -102,14 +98,8 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
assertEquals(Collections.singletonMap("foo", "bar"), transports);
|
assertEquals(Collections.singletonMap("foo", "bar"), transports);
|
||||||
assertTrue(db.containsSubscription(txn, groupId));
|
assertTrue(db.containsSubscription(txn, groupId));
|
||||||
assertTrue(db.containsMessage(txn, messageId));
|
assertTrue(db.containsMessage(txn, messageId));
|
||||||
Message m1 = db.getMessage(txn, messageId);
|
byte[] raw1 = db.getMessage(txn, messageId);
|
||||||
assertEquals(messageId, m1.getId());
|
assertTrue(Arrays.equals(raw, raw1));
|
||||||
assertEquals(MessageId.NONE, m1.getParent());
|
|
||||||
assertEquals(groupId, m1.getGroup());
|
|
||||||
assertEquals(authorId, m1.getAuthor());
|
|
||||||
assertEquals(timestamp, m1.getTimestamp());
|
|
||||||
assertEquals(size, m1.getSize());
|
|
||||||
assertTrue(Arrays.equals(body, m1.getBytes()));
|
|
||||||
// Delete the records
|
// Delete the records
|
||||||
db.removeContact(txn, contactId);
|
db.removeContact(txn, contactId);
|
||||||
db.removeMessage(txn, messageId);
|
db.removeMessage(txn, messageId);
|
||||||
@@ -118,7 +108,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
// Repoen the database
|
// Repoen the database
|
||||||
db = open(true, messageFactory);
|
db = open(true);
|
||||||
// Check that the records are gone
|
// Check that the records are gone
|
||||||
txn = db.startTransaction();
|
txn = db.startTransaction();
|
||||||
assertFalse(db.containsContact(txn, contactId));
|
assertFalse(db.containsContact(txn, contactId));
|
||||||
@@ -134,8 +124,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
ContactId contactId1 = new ContactId(2);
|
ContactId contactId1 = new ContactId(2);
|
||||||
ContactId contactId2 = new ContactId(3);
|
ContactId contactId2 = new ContactId(3);
|
||||||
ContactId contactId3 = new ContactId(4);
|
ContactId contactId3 = new ContactId(4);
|
||||||
MessageFactory messageFactory = new TestMessageFactory();
|
Database<Connection> db = open(false);
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Create three contacts
|
// Create three contacts
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -156,14 +145,14 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
assertEquals(contactId3, db.addContact(txn, null));
|
assertEquals(contactId3, db.addContact(txn, null));
|
||||||
assertTrue(db.containsContact(txn, contactId3));
|
assertTrue(db.containsContact(txn, contactId3));
|
||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRatings() throws DbException {
|
public void testRatings() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
// Unknown authors should be unrated
|
// Unknown authors should be unrated
|
||||||
assertEquals(Rating.UNRATED, db.getRating(txn, authorId));
|
assertEquals(Rating.UNRATED, db.getRating(txn, authorId));
|
||||||
@@ -174,15 +163,13 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
txn = db.startTransaction();
|
txn = db.startTransaction();
|
||||||
assertEquals(Rating.GOOD, db.getRating(txn, authorId));
|
assertEquals(Rating.GOOD, db.getRating(txn, authorId));
|
||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnsubscribingRemovesMessage() throws DbException {
|
public void testUnsubscribingRemovesMessage() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Subscribe to a group and store a message
|
// Subscribe to a group and store a message
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -198,14 +185,11 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendableMessagesMustBeSendable() throws DbException {
|
public void testSendableMessagesMustBeSendable() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact, subscribe to a group and store a message
|
// Add a contact, subscribe to a group and store a message
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -240,14 +224,11 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendableMessagesMustBeNew() throws DbException {
|
public void testSendableMessagesMustBeNew() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact, subscribe to a group and store a message
|
// Add a contact, subscribe to a group and store a message
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -288,14 +269,11 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendableMessagesMustBeSubscribed() throws DbException {
|
public void testSendableMessagesMustBeSubscribed() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact, subscribe to a group and store a message
|
// Add a contact, subscribe to a group and store a message
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -329,14 +307,11 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendableMessagesMustFitCapacity() throws DbException {
|
public void testSendableMessagesMustFitCapacity() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact, subscribe to a group and store a message
|
// Add a contact, subscribe to a group and store a message
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -363,15 +338,12 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBatchesToAck() throws DbException {
|
public void testBatchesToAck() throws DbException {
|
||||||
BatchId batchId1 = new BatchId(TestUtils.getRandomId());
|
BatchId batchId1 = new BatchId(TestUtils.getRandomId());
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact and some batches to ack
|
// Add a contact and some batches to ack
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -395,14 +367,11 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveAckedBatch() throws DbException {
|
public void testRemoveAckedBatch() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact, subscribe to a group and store a message
|
// Add a contact, subscribe to a group and store a message
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -438,14 +407,11 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveLostBatch() throws DbException {
|
public void testRemoveLostBatch() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact, subscribe to a group and store a message
|
// Add a contact, subscribe to a group and store a message
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -483,7 +449,6 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -493,9 +458,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
ids[i] = new BatchId(TestUtils.getRandomId());
|
ids[i] = new BatchId(TestUtils.getRandomId());
|
||||||
}
|
}
|
||||||
Set<MessageId> empty = Collections.emptySet();
|
Set<MessageId> empty = Collections.emptySet();
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact
|
// Add a contact
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -525,7 +488,6 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -535,9 +497,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
ids[i] = new BatchId(TestUtils.getRandomId());
|
ids[i] = new BatchId(TestUtils.getRandomId());
|
||||||
}
|
}
|
||||||
Set<MessageId> empty = Collections.emptySet();
|
Set<MessageId> empty = Collections.emptySet();
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact
|
// Add a contact
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -559,18 +519,15 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMessagesByAuthor() throws DbException {
|
public void testGetMessagesByAuthor() throws DbException {
|
||||||
AuthorId authorId1 = new AuthorId(TestUtils.getRandomId());
|
AuthorId authorId1 = new AuthorId(TestUtils.getRandomId());
|
||||||
MessageId messageId1 = new MessageId(TestUtils.getRandomId());
|
MessageId messageId1 = new MessageId(TestUtils.getRandomId());
|
||||||
Message message1 = new MessageImpl(messageId1, MessageId.NONE, groupId,
|
Message message1 = new TestMessage(messageId1, MessageId.NONE, groupId,
|
||||||
authorId1, timestamp, body);
|
authorId1, timestamp, raw);
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Subscribe to a group and store two messages
|
// Subscribe to a group and store two messages
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -593,7 +550,6 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -602,16 +558,14 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
MessageId childId2 = new MessageId(TestUtils.getRandomId());
|
MessageId childId2 = new MessageId(TestUtils.getRandomId());
|
||||||
MessageId childId3 = new MessageId(TestUtils.getRandomId());
|
MessageId childId3 = new MessageId(TestUtils.getRandomId());
|
||||||
GroupId groupId1 = new GroupId(TestUtils.getRandomId());
|
GroupId groupId1 = new GroupId(TestUtils.getRandomId());
|
||||||
Message child1 = new MessageImpl(childId1, messageId, groupId,
|
Message child1 = new TestMessage(childId1, messageId, groupId,
|
||||||
authorId, timestamp, body);
|
authorId, timestamp, raw);
|
||||||
Message child2 = new MessageImpl(childId2, messageId, groupId,
|
Message child2 = new TestMessage(childId2, messageId, groupId,
|
||||||
authorId, timestamp, body);
|
authorId, timestamp, raw);
|
||||||
// The third child is in a different group
|
// The third child is in a different group
|
||||||
Message child3 = new MessageImpl(childId3, messageId, groupId1,
|
Message child3 = new TestMessage(childId3, messageId, groupId1,
|
||||||
authorId, timestamp, body);
|
authorId, timestamp, raw);
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Subscribe to the groups and store the messages
|
// Subscribe to the groups and store the messages
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -637,17 +591,14 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetOldMessages() throws DbException {
|
public void testGetOldMessages() throws DbException {
|
||||||
MessageId messageId1 = new MessageId(TestUtils.getRandomId());
|
MessageId messageId1 = new MessageId(TestUtils.getRandomId());
|
||||||
Message message1 = new MessageImpl(messageId1, MessageId.NONE, groupId,
|
Message message1 = new TestMessage(messageId1, MessageId.NONE, groupId,
|
||||||
authorId, timestamp + 1000, body);
|
authorId, timestamp + 1000, raw);
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Subscribe to a group and store two messages
|
// Subscribe to a group and store two messages
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -674,18 +625,15 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetFreeSpace() throws DbException {
|
public void testGetFreeSpace() throws DbException {
|
||||||
byte[] largeBody = new byte[ONE_MEGABYTE];
|
byte[] largeBody = new byte[ONE_MEGABYTE];
|
||||||
for(int i = 0; i < largeBody.length; i++) largeBody[i] = (byte) i;
|
for(int i = 0; i < largeBody.length; i++) largeBody[i] = (byte) i;
|
||||||
Message message1 = new MessageImpl(messageId, MessageId.NONE, groupId,
|
Message message1 = new TestMessage(messageId, MessageId.NONE, groupId,
|
||||||
authorId, timestamp, largeBody);
|
authorId, timestamp, largeBody);
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Sanity check: there should be enough space on disk for this test
|
// Sanity check: there should be enough space on disk for this test
|
||||||
assertTrue(testDir.getFreeSpace() > MAX_SIZE);
|
assertTrue(testDir.getFreeSpace() > MAX_SIZE);
|
||||||
@@ -701,17 +649,14 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
assertTrue(db.getFreeSpace() < free);
|
assertTrue(db.getFreeSpace() < free);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloseWaitsForCommit() throws DbException {
|
public void testCloseWaitsForCommit() throws DbException {
|
||||||
Mockery context = new Mockery();
|
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
final AtomicBoolean transactionFinished = new AtomicBoolean(false);
|
final AtomicBoolean transactionFinished = new AtomicBoolean(false);
|
||||||
final AtomicBoolean closed = new AtomicBoolean(false);
|
final AtomicBoolean closed = new AtomicBoolean(false);
|
||||||
final AtomicBoolean error = new AtomicBoolean(false);
|
final AtomicBoolean error = new AtomicBoolean(false);
|
||||||
final Database<Connection> db = open(false, messageFactory);
|
final Database<Connection> db = open(false);
|
||||||
|
|
||||||
// Start a transaction
|
// Start a transaction
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -746,12 +691,10 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloseWaitsForAbort() throws DbException {
|
public void testCloseWaitsForAbort() throws DbException {
|
||||||
Mockery context = new Mockery();
|
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
final AtomicBoolean transactionFinished = new AtomicBoolean(false);
|
final AtomicBoolean transactionFinished = new AtomicBoolean(false);
|
||||||
final AtomicBoolean closed = new AtomicBoolean(false);
|
final AtomicBoolean closed = new AtomicBoolean(false);
|
||||||
final AtomicBoolean error = new AtomicBoolean(false);
|
final AtomicBoolean error = new AtomicBoolean(false);
|
||||||
final Database<Connection> db = open(false, messageFactory);
|
final Database<Connection> db = open(false);
|
||||||
|
|
||||||
// Start a transaction
|
// Start a transaction
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -786,9 +729,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTransports() throws DbException {
|
public void testUpdateTransports() throws DbException {
|
||||||
Mockery context = new Mockery();
|
Database<Connection> db = open(false);
|
||||||
MessageFactory messageFactory = context.mock(MessageFactory.class);
|
|
||||||
Database<Connection> db = open(false, messageFactory);
|
|
||||||
|
|
||||||
// Add a contact with some transport details
|
// Add a contact with some transport details
|
||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
@@ -813,11 +754,9 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
context.assertIsSatisfied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Database<Connection> open(boolean resume,
|
private Database<Connection> open(boolean resume) throws DbException {
|
||||||
MessageFactory messageFactory) throws DbException {
|
|
||||||
final char[] passwordArray = passwordString.toCharArray();
|
final char[] passwordArray = passwordString.toCharArray();
|
||||||
Mockery context = new Mockery();
|
Mockery context = new Mockery();
|
||||||
final Password password = context.mock(Password.class);
|
final Password password = context.mock(Password.class);
|
||||||
@@ -825,8 +764,7 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
oneOf(password).getPassword();
|
oneOf(password).getPassword();
|
||||||
will(returnValue(passwordArray));
|
will(returnValue(passwordArray));
|
||||||
}});
|
}});
|
||||||
Database<Connection> db =
|
Database<Connection> db = new H2Database(testDir, password, MAX_SIZE);
|
||||||
new H2Database(testDir, messageFactory, password, MAX_SIZE);
|
|
||||||
db.open(resume);
|
db.open(resume);
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
// The password array should be cleared after use
|
// The password array should be cleared after use
|
||||||
@@ -839,12 +777,4 @@ public class H2DatabaseTest extends TestCase {
|
|||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
TestUtils.deleteTestDirectory(testDir);
|
TestUtils.deleteTestDirectory(testDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestMessageFactory implements MessageFactory {
|
|
||||||
|
|
||||||
public Message createMessage(MessageId id, MessageId parent,
|
|
||||||
GroupId group, AuthorId author, long timestamp, byte[] raw) {
|
|
||||||
return new MessageImpl(id, parent, group, author, timestamp, raw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
63
test/net/sf/briar/db/TestMessage.java
Normal file
63
test/net/sf/briar/db/TestMessage.java
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package net.sf.briar.db;
|
||||||
|
|
||||||
|
import net.sf.briar.api.protocol.AuthorId;
|
||||||
|
import net.sf.briar.api.protocol.GroupId;
|
||||||
|
import net.sf.briar.api.protocol.Message;
|
||||||
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
|
|
||||||
|
class TestMessage implements Message {
|
||||||
|
|
||||||
|
private final MessageId id, parent;
|
||||||
|
private final GroupId group;
|
||||||
|
private final AuthorId author;
|
||||||
|
private final long timestamp;
|
||||||
|
private final byte[] raw;
|
||||||
|
|
||||||
|
public TestMessage(MessageId id, MessageId parent, GroupId group,
|
||||||
|
AuthorId author, long timestamp, byte[] raw) {
|
||||||
|
this.id = id;
|
||||||
|
this.parent = parent;
|
||||||
|
this.group = group;
|
||||||
|
this.author = author;
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.raw = raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageId getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageId getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupId getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorId getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return raw.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getBytes() {
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Message && id.equals(((Message)o).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return id.hashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,15 +34,19 @@ import net.sf.briar.api.protocol.MessageEncoder;
|
|||||||
import net.sf.briar.api.protocol.MessageId;
|
import net.sf.briar.api.protocol.MessageId;
|
||||||
import net.sf.briar.api.protocol.MessageParser;
|
import net.sf.briar.api.protocol.MessageParser;
|
||||||
import net.sf.briar.api.protocol.UniqueId;
|
import net.sf.briar.api.protocol.UniqueId;
|
||||||
|
import net.sf.briar.api.serial.Raw;
|
||||||
|
import net.sf.briar.api.serial.RawByteArray;
|
||||||
import net.sf.briar.api.serial.ReaderFactory;
|
import net.sf.briar.api.serial.ReaderFactory;
|
||||||
import net.sf.briar.api.serial.WriterFactory;
|
import net.sf.briar.api.serial.WriterFactory;
|
||||||
import net.sf.briar.serial.ReaderFactoryImpl;
|
import net.sf.briar.serial.SerialModule;
|
||||||
import net.sf.briar.serial.WriterFactoryImpl;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
public class BundleReadWriteTest extends TestCase {
|
public class BundleReadWriteTest extends TestCase {
|
||||||
|
|
||||||
private static final String SIGNATURE_ALGO = "SHA256withRSA";
|
private static final String SIGNATURE_ALGO = "SHA256withRSA";
|
||||||
@@ -62,9 +66,8 @@ public class BundleReadWriteTest extends TestCase {
|
|||||||
private final String nick = "Foo Bar";
|
private final String nick = "Foo Bar";
|
||||||
private final String messageBody = "This is the message body! Wooooooo!";
|
private final String messageBody = "This is the message body! Wooooooo!";
|
||||||
|
|
||||||
// FIXME: This test should not depend on impls in another component
|
private final ReaderFactory rf;
|
||||||
private final ReaderFactory rf = new ReaderFactoryImpl();
|
private final WriterFactory wf;
|
||||||
private final WriterFactory wf = new WriterFactoryImpl();
|
|
||||||
|
|
||||||
private final KeyPair keyPair;
|
private final KeyPair keyPair;
|
||||||
private final Signature sig;
|
private final Signature sig;
|
||||||
@@ -74,6 +77,9 @@ public class BundleReadWriteTest extends TestCase {
|
|||||||
|
|
||||||
public BundleReadWriteTest() throws Exception {
|
public BundleReadWriteTest() throws Exception {
|
||||||
super();
|
super();
|
||||||
|
Injector i = Guice.createInjector(new SerialModule());
|
||||||
|
rf = i.getInstance(ReaderFactory.class);
|
||||||
|
wf = i.getInstance(WriterFactory.class);
|
||||||
keyPair = KeyPairGenerator.getInstance(KEY_PAIR_ALGO).generateKeyPair();
|
keyPair = KeyPairGenerator.getInstance(KEY_PAIR_ALGO).generateKeyPair();
|
||||||
sig = Signature.getInstance(SIGNATURE_ALGO);
|
sig = Signature.getInstance(SIGNATURE_ALGO);
|
||||||
dig = MessageDigest.getInstance(DIGEST_ALGO);
|
dig = MessageDigest.getInstance(DIGEST_ALGO);
|
||||||
@@ -101,9 +107,10 @@ public class BundleReadWriteTest extends TestCase {
|
|||||||
FileOutputStream out = new FileOutputStream(bundle);
|
FileOutputStream out = new FileOutputStream(bundle);
|
||||||
BundleWriter w = new BundleWriterImpl(out, wf, keyPair.getPrivate(),
|
BundleWriter w = new BundleWriterImpl(out, wf, keyPair.getPrivate(),
|
||||||
sig, dig, capacity);
|
sig, dig, capacity);
|
||||||
|
Raw messageRaw = new RawByteArray(message.getBytes());
|
||||||
|
|
||||||
w.addHeader(acks, subs, transports);
|
w.addHeader(acks, subs, transports);
|
||||||
w.addBatch(Collections.singleton(message));
|
w.addBatch(Collections.singleton(messageRaw));
|
||||||
w.finish();
|
w.finish();
|
||||||
|
|
||||||
assertTrue(bundle.exists());
|
assertTrue(bundle.exists());
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.Map.Entry;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import net.sf.briar.api.serial.FormatException;
|
import net.sf.briar.api.serial.FormatException;
|
||||||
import net.sf.briar.api.serial.Raw;
|
import net.sf.briar.api.serial.Raw;
|
||||||
|
import net.sf.briar.api.serial.RawByteArray;
|
||||||
import net.sf.briar.util.StringUtils;
|
import net.sf.briar.util.StringUtils;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -222,7 +223,7 @@ public class ReaderImplTest extends TestCase {
|
|||||||
assertNotNull(m);
|
assertNotNull(m);
|
||||||
assertEquals(2, m.size());
|
assertEquals(2, m.size());
|
||||||
assertEquals((byte) 123, m.get("foo"));
|
assertEquals((byte) 123, m.get("foo"));
|
||||||
Raw raw = new RawImpl(new byte[] {});
|
Raw raw = new RawByteArray(new byte[] {});
|
||||||
assertTrue(m.containsKey(raw));
|
assertTrue(m.containsKey(raw));
|
||||||
assertNull(m.get(raw));
|
assertNull(m.get(raw));
|
||||||
assertTrue(r.eof());
|
assertTrue(r.eof());
|
||||||
@@ -287,7 +288,7 @@ public class ReaderImplTest extends TestCase {
|
|||||||
assertNotNull(m);
|
assertNotNull(m);
|
||||||
assertEquals(2, m.size());
|
assertEquals(2, m.size());
|
||||||
assertEquals((byte) 123, m.get("foo"));
|
assertEquals((byte) 123, m.get("foo"));
|
||||||
Raw raw = new RawImpl(new byte[] {});
|
Raw raw = new RawByteArray(new byte[] {});
|
||||||
assertTrue(m.containsKey(raw));
|
assertTrue(m.containsKey(raw));
|
||||||
assertNull(m.get(raw));
|
assertNull(m.get(raw));
|
||||||
assertTrue(r.eof());
|
assertTrue(r.eof());
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import net.sf.briar.api.serial.RawByteArray;
|
||||||
import net.sf.briar.util.StringUtils;
|
import net.sf.briar.util.StringUtils;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -141,7 +142,7 @@ public class WriterImplTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriteRawObject() throws IOException {
|
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");
|
checkContents("F6" + "05" + "0001FF7F80");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ public class WriterImplTest extends TestCase {
|
|||||||
// Use LinkedHashMap to get predictable iteration order
|
// Use LinkedHashMap to get predictable iteration order
|
||||||
Map<Object, Object> m = new LinkedHashMap<Object, Object>();
|
Map<Object, Object> m = new LinkedHashMap<Object, Object>();
|
||||||
m.put("foo", Integer.valueOf(123)); // Written as a uint7
|
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);
|
w.writeMap(m);
|
||||||
checkContents("F4" + "02" + "F703666F6F" + "7B" + "F600" + "F0");
|
checkContents("F4" + "02" + "F703666F6F" + "7B" + "F600" + "F0");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import net.sf.briar.api.i18n.Stri18ng;
|
|||||||
import net.sf.briar.ui.wizard.Wizard;
|
import net.sf.briar.ui.wizard.Wizard;
|
||||||
import net.sf.briar.ui.wizard.WizardPanel;
|
import net.sf.briar.ui.wizard.WizardPanel;
|
||||||
|
|
||||||
public class PasswordPanel extends WizardPanel {
|
class PasswordPanel extends WizardPanel {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1012132977732308293L;
|
private static final long serialVersionUID = -1012132977732308293L;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.sf.briar.api.i18n.I18n;
|
|||||||
import net.sf.briar.api.i18n.Stri18ng;
|
import net.sf.briar.api.i18n.Stri18ng;
|
||||||
import net.sf.briar.ui.wizard.DirectoryChooserPanel;
|
import net.sf.briar.ui.wizard.DirectoryChooserPanel;
|
||||||
|
|
||||||
public class LocationPanel extends DirectoryChooserPanel {
|
class LocationPanel extends DirectoryChooserPanel {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8831098591612528860L;
|
private static final long serialVersionUID = -8831098591612528860L;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.sf.briar.api.i18n.I18n;
|
|||||||
import net.sf.briar.api.i18n.Stri18ng;
|
import net.sf.briar.api.i18n.Stri18ng;
|
||||||
import net.sf.briar.ui.wizard.Wizard;
|
import net.sf.briar.ui.wizard.Wizard;
|
||||||
|
|
||||||
public class SetupWizard extends Wizard {
|
class SetupWizard extends Wizard {
|
||||||
|
|
||||||
private static int WIDTH = 400, HEIGHT = 300;
|
private static int WIDTH = 400, HEIGHT = 300;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user