diff --git a/components/net/sf/briar/db/DatabaseComponentImpl.java b/components/net/sf/briar/db/DatabaseComponentImpl.java index f3a82817887e877f3b639935e70174c81c0ca9e6..a437dde9a55db82cd9a94dbdc5dcc7fce0e57cd6 100644 --- a/components/net/sf/briar/db/DatabaseComponentImpl.java +++ b/components/net/sf/briar/db/DatabaseComponentImpl.java @@ -1191,7 +1191,8 @@ DatabaseCleaner.Callback { contactLock.readLock().unlock(); } // Call the listeners outside the lock - callListeners(new SubscriptionsUpdatedEvent(Collections.singleton(c))); + callListeners(new SubscriptionsUpdatedEvent( + Collections.singletonList(c))); } public void receiveTransportUpdate(ContactId c, TransportUpdate t) diff --git a/test/net/sf/briar/db/DatabaseComponentImplTest.java b/test/net/sf/briar/db/DatabaseComponentImplTest.java index 0c0e2f45ee15dfa63c4a0f38b86e1ccf32629b29..da67ef8b4d4855df0777a2ddcf371faddc548d3f 100644 --- a/test/net/sf/briar/db/DatabaseComponentImplTest.java +++ b/test/net/sf/briar/db/DatabaseComponentImplTest.java @@ -74,7 +74,7 @@ public class DatabaseComponentImplTest extends DatabaseComponentTest { oneOf(database).startTransaction(); will(returnValue(txn)); oneOf(database).getOldMessages(txn, BYTES_PER_SWEEP); - will(returnValue(Collections.singleton(messageId))); + will(returnValue(Collections.singletonList(messageId))); oneOf(database).getSendability(txn, messageId); will(returnValue(0)); oneOf(database).removeMessage(txn, messageId); @@ -102,7 +102,7 @@ public class DatabaseComponentImplTest extends DatabaseComponentTest { oneOf(database).startTransaction(); will(returnValue(txn)); oneOf(database).getOldMessages(txn, BYTES_PER_SWEEP); - will(returnValue(Collections.singleton(messageId))); + will(returnValue(Collections.singletonList(messageId))); oneOf(database).getSendability(txn, messageId); will(returnValue(1)); oneOf(database).getGroupMessageParent(txn, messageId); diff --git a/test/net/sf/briar/db/DatabaseComponentTest.java b/test/net/sf/briar/db/DatabaseComponentTest.java index cf68411585ed4f29b977d21b10cea5a4c99c4be6..59e0e9fe128ae863c8c9e598194ad133ce859f74 100644 --- a/test/net/sf/briar/db/DatabaseComponentTest.java +++ b/test/net/sf/briar/db/DatabaseComponentTest.java @@ -592,7 +592,7 @@ public abstract class DatabaseComponentTest extends TestCase { } catch(NoSuchContactException expected) {} try { - db.setSeen(contactId, Collections.singleton(messageId)); + db.setSeen(contactId, Collections.singletonList(messageId)); fail(); } catch(NoSuchContactException expected) {} @@ -1433,12 +1433,12 @@ public abstract class DatabaseComponentTest extends TestCase { allowing(database).commitTransaction(txn); allowing(database).containsContact(txn, contactId); will(returnValue(true)); - // setSeen(contactId, Collections.singleton(messageId)) + // setSeen(contactId, Collections.singletonList(messageId)) oneOf(database).setStatusSeenIfVisible(txn, contactId, messageId); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner); - db.setSeen(contactId, Collections.singleton(messageId)); + db.setSeen(contactId, Collections.singletonList(messageId)); context.assertIsSatisfied(); } diff --git a/test/net/sf/briar/db/H2DatabaseTest.java b/test/net/sf/briar/db/H2DatabaseTest.java index 11020c3178e1cd039ed7e93cbf4ee8a7facb1a32..0d54f31d76c50bd26d406fe17d9d8f915612cf08 100644 --- a/test/net/sf/briar/db/H2DatabaseTest.java +++ b/test/net/sf/briar/db/H2DatabaseTest.java @@ -339,7 +339,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); db.setStatus(txn, contactId, messageId, Status.NEW); @@ -377,7 +377,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); @@ -419,7 +419,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); db.setStatus(txn, contactId, messageId, Status.NEW); @@ -458,7 +458,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); db.setStatus(txn, contactId, messageId, Status.NEW); @@ -493,7 +493,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); @@ -537,7 +537,7 @@ public class H2DatabaseTest extends TestCase { assertFalse(it.hasNext()); // Making the subscription visible should make the message sendable - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); assertTrue(db.hasSendableMessages(txn, contactId)); it = db.getSendableMessages(txn, contactId, ONE_MEGABYTE).iterator(); assertTrue(it.hasNext()); @@ -614,12 +614,12 @@ public class H2DatabaseTest extends TestCase { // Add an outstanding batch db.addOutstandingBatch(txn, contactId, batchId, - Collections.singleton(messageId)); + Collections.singletonList(messageId)); // It should not be possible to add the same outstanding batch again try { db.addOutstandingBatch(txn, contactId, batchId, - Collections.singleton(messageId)); + Collections.singletonList(messageId)); fail(); } catch(DbException expected) {} @@ -640,11 +640,11 @@ public class H2DatabaseTest extends TestCase { // Add an outstanding batch for the first contact db.addOutstandingBatch(txn, contactId, batchId, - Collections.singleton(messageId)); + Collections.singletonList(messageId)); // Add the same outstanding batch for the second contact db.addOutstandingBatch(txn, contactId1, batchId, - Collections.singleton(messageId)); + Collections.singletonList(messageId)); db.commitTransaction(txn); db.close(); @@ -658,7 +658,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); @@ -672,7 +672,7 @@ public class H2DatabaseTest extends TestCase { assertFalse(it.hasNext()); db.setStatus(txn, contactId, messageId, Status.SENT); db.addOutstandingBatch(txn, contactId, batchId, - Collections.singleton(messageId)); + Collections.singletonList(messageId)); // The message should no longer be sendable it = db.getSendableMessages(txn, contactId, ONE_MEGABYTE).iterator(); @@ -697,7 +697,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); @@ -711,7 +711,7 @@ public class H2DatabaseTest extends TestCase { assertFalse(it.hasNext()); db.setStatus(txn, contactId, messageId, Status.SENT); db.addOutstandingBatch(txn, contactId, batchId, - Collections.singleton(messageId)); + Collections.singletonList(messageId)); // The message should no longer be sendable it = db.getSendableMessages(txn, contactId, ONE_MEGABYTE).iterator(); @@ -1252,7 +1252,7 @@ public class H2DatabaseTest extends TestCase { // the message is older than the contact's subscription assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); Map<Group, Long> subs = Collections.singletonMap(group, timestamp + 1); db.setSubscriptions(txn, contactId, subs, 1); db.addGroupMessage(txn, message); @@ -1276,7 +1276,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); @@ -1301,7 +1301,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact and subscribe to a group assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); // The message is not in the database @@ -1376,7 +1376,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); @@ -1398,7 +1398,7 @@ public class H2DatabaseTest extends TestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn, secret)); db.addSubscription(txn, group); - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); db.setSubscriptions(txn, contactId, subscriptions, 1); db.addGroupMessage(txn, message); @@ -1422,7 +1422,7 @@ public class H2DatabaseTest extends TestCase { // The group should not be visible to the contact assertEquals(Collections.emptyList(), db.getVisibility(txn, groupId)); // Make the group visible to the contact - db.setVisibility(txn, groupId, Collections.singleton(contactId)); + db.setVisibility(txn, groupId, Collections.singletonList(contactId)); assertEquals(Collections.singletonList(contactId), db.getVisibility(txn, groupId)); // Make the group invisible again @@ -1617,7 +1617,8 @@ public class H2DatabaseTest extends TestCase { assertEquals(0L, db.getTransportsSent(txn, contactId)); // Update the timestamps - db.setSubscriptionsModified(txn, Collections.singleton(contactId), 1L); + db.setSubscriptionsModified(txn, + Collections.singletonList(contactId), 1L); db.setSubscriptionsSent(txn, contactId, 2L); db.setTransportsModified(txn, 3L); db.setTransportsSent(txn, contactId, 4L); diff --git a/test/net/sf/briar/transport/ConnectionRecogniserImplTest.java b/test/net/sf/briar/transport/ConnectionRecogniserImplTest.java index b95460a59e29c5bb0aefeacbab3d8a4a1bb58f25..2400c2dceb4f4d3977317b0446463371e8d40ede 100644 --- a/test/net/sf/briar/transport/ConnectionRecogniserImplTest.java +++ b/test/net/sf/briar/transport/ConnectionRecogniserImplTest.java @@ -62,7 +62,7 @@ public class ConnectionRecogniserImplTest extends TestCase { oneOf(db).getLocalTransports(); will(returnValue(transports)); oneOf(db).getContacts(); - will(returnValue(Collections.singleton(contactId))); + will(returnValue(Collections.singletonList(contactId))); oneOf(db).getSharedSecret(contactId); will(returnValue(secret)); oneOf(db).getRemoteIndex(contactId, transportId); @@ -93,7 +93,7 @@ public class ConnectionRecogniserImplTest extends TestCase { oneOf(db).getLocalTransports(); will(returnValue(transports)); oneOf(db).getContacts(); - will(returnValue(Collections.singleton(contactId))); + will(returnValue(Collections.singletonList(contactId))); oneOf(db).getSharedSecret(contactId); will(returnValue(secret)); oneOf(db).getRemoteIndex(contactId, transportId);