Retransmission without backoff for messages and updates.

This commit is contained in:
akwizgran
2013-02-06 19:06:14 +00:00
parent bec8543bfa
commit 4c5657321d
9 changed files with 274 additions and 206 deletions

View File

@@ -523,7 +523,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
} catch(NoSuchContactException expected) {}
try {
db.generateRetentionUpdate(contactId);
db.generateRetentionUpdate(contactId, 123);
fail();
} catch(NoSuchContactException expected) {}
@@ -533,7 +533,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
} catch(NoSuchContactException expected) {}
try {
db.generateSubscriptionUpdate(contactId);
db.generateSubscriptionUpdate(contactId, 123);
fail();
} catch(NoSuchContactException expected) {}
@@ -543,7 +543,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
} catch(NoSuchContactException expected) {}
try {
db.generateTransportUpdates(contactId);
db.generateTransportUpdates(contactId, 123);
fail();
} catch(NoSuchContactException expected) {}
@@ -696,7 +696,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
oneOf(database).getRawMessage(txn, messageId1);
will(returnValue(raw1));
// Record the outstanding messages
oneOf(database).addOutstandingMessages(txn, contactId, sendable,
oneOf(database).setMessageExpiry(txn, contactId, sendable,
Long.MAX_VALUE);
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner,
@@ -733,8 +733,8 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
will(returnValue(raw1)); // Message is sendable
oneOf(database).getRawMessageIfSendable(txn, contactId, messageId2);
will(returnValue(null)); // Message is not sendable
// Record the outstanding message
oneOf(database).addOutstandingMessages(txn, contactId,
// Mark the message as sent
oneOf(database).setMessageExpiry(txn, contactId,
Arrays.asList(messageId1), Long.MAX_VALUE);
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner,
@@ -788,13 +788,14 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
oneOf(database).getSubscriptionUpdate(txn, contactId);
oneOf(database).getSubscriptionUpdate(txn, contactId,
Long.MAX_VALUE);
will(returnValue(null));
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner,
shutdown);
assertNull(db.generateSubscriptionUpdate(contactId));
assertNull(db.generateSubscriptionUpdate(contactId, Long.MAX_VALUE));
context.assertIsSatisfied();
}
@@ -812,13 +813,15 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
oneOf(database).getSubscriptionUpdate(txn, contactId);
oneOf(database).getSubscriptionUpdate(txn, contactId,
Long.MAX_VALUE);
will(returnValue(new SubscriptionUpdate(Arrays.asList(group), 1)));
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner,
shutdown);
SubscriptionUpdate u = db.generateSubscriptionUpdate(contactId);
SubscriptionUpdate u = db.generateSubscriptionUpdate(contactId,
Long.MAX_VALUE);
assertEquals(Arrays.asList(group), u.getGroups());
assertEquals(1, u.getVersion());
@@ -838,13 +841,13 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
oneOf(database).getTransportUpdates(txn, contactId);
oneOf(database).getTransportUpdates(txn, contactId, Long.MAX_VALUE);
will(returnValue(null));
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner,
shutdown);
assertNull(db.generateTransportUpdates(contactId));
assertNull(db.generateTransportUpdates(contactId, Long.MAX_VALUE));
context.assertIsSatisfied();
}
@@ -862,15 +865,15 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
oneOf(database).getTransportUpdates(txn, contactId);
oneOf(database).getTransportUpdates(txn, contactId, Long.MAX_VALUE);
will(returnValue(Arrays.asList(new TransportUpdate(transportId,
transportProperties, 1))));
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner,
shutdown);
Collection<TransportUpdate> updates = db.generateTransportUpdates(
contactId);
Collection<TransportUpdate> updates =
db.generateTransportUpdates(contactId, Long.MAX_VALUE);
assertNotNull(updates);
assertEquals(1, updates.size());
TransportUpdate u = updates.iterator().next();

View File

@@ -523,7 +523,7 @@ public class H2DatabaseTest extends BriarTestCase {
assertTrue(it.hasNext());
assertEquals(messageId, it.next());
assertFalse(it.hasNext());
db.addOutstandingMessages(txn, contactId, Arrays.asList(messageId),
db.setMessageExpiry(txn, contactId, Arrays.asList(messageId),
Long.MAX_VALUE);
// The message should no longer be sendable

View File

@@ -113,19 +113,22 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase {
oneOf(db).generateTransportAcks(contactId);
will(returnValue(null));
// No transport updates to send
oneOf(db).generateTransportUpdates(contactId);
oneOf(db).generateTransportUpdates(with(contactId),
with(any(long.class)));
will(returnValue(null));
// No subscription ack to send
oneOf(db).generateSubscriptionAck(contactId);
will(returnValue(null));
// No subscription update to send
oneOf(db).generateSubscriptionUpdate(contactId);
oneOf(db).generateSubscriptionUpdate(with(contactId),
with(any(long.class)));
will(returnValue(null));
// No retention ack to send
oneOf(db).generateRetentionAck(contactId);
will(returnValue(null));
// No retention update to send
oneOf(db).generateRetentionUpdate(contactId);
oneOf(db).generateRetentionUpdate(with(contactId),
with(any(long.class)));
will(returnValue(null));
// No acks to send
oneOf(db).generateAck(with(contactId), with(any(int.class)));
@@ -160,19 +163,22 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase {
oneOf(db).generateTransportAcks(contactId);
will(returnValue(null));
// No transport updates to send
oneOf(db).generateTransportUpdates(contactId);
oneOf(db).generateTransportUpdates(with(contactId),
with(any(long.class)));
will(returnValue(null));
// No subscription ack to send
oneOf(db).generateSubscriptionAck(contactId);
will(returnValue(null));
// No subscription update to send
oneOf(db).generateSubscriptionUpdate(contactId);
oneOf(db).generateSubscriptionUpdate(with(contactId),
with(any(long.class)));
will(returnValue(null));
// No retention ack to send
oneOf(db).generateRetentionAck(contactId);
will(returnValue(null));
// No retention update to send
oneOf(db).generateRetentionUpdate(contactId);
oneOf(db).generateRetentionUpdate(with(contactId),
with(any(long.class)));
will(returnValue(null));
// One ack to send
oneOf(db).generateAck(with(contactId), with(any(int.class)));