diff --git a/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java b/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java index 85e21b7052f2d6da85b6148bf0cc67e26670e066..fe15f9d39a98cf72aa323d98bfcf03d2d30a1ae5 100644 --- a/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java +++ b/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java @@ -117,8 +117,8 @@ public class ProtocolIntegrationTest extends BriarTestCase { message3 = messageFactory.createMessage(null, group1, groupKeyPair.getPrivate(), author, authorKeyPair.getPrivate(), subject, messageBody.getBytes("UTF-8")); - messageIds = Arrays.asList(message.getId(), - message1.getId(), message2.getId(), message3.getId()); + messageIds = Arrays.asList(message.getId(), message1.getId(), + message2.getId(), message3.getId()); // Create some transport properties transportId = new TransportId(TestUtils.getRandomId()); transportProperties = new TransportProperties(Collections.singletonMap( diff --git a/briar-tests/src/net/sf/briar/db/DatabaseComponentImplTest.java b/briar-tests/src/net/sf/briar/db/DatabaseComponentImplTest.java index 61a29eff1087bc8f15465d3505670efe31546f4c..68d12d286845720b6e23a18047e58d5ff59634f6 100644 --- a/briar-tests/src/net/sf/briar/db/DatabaseComponentImplTest.java +++ b/briar-tests/src/net/sf/briar/db/DatabaseComponentImplTest.java @@ -3,6 +3,7 @@ package net.sf.briar.db; import static net.sf.briar.db.DatabaseConstants.BYTES_PER_SWEEP; import static net.sf.briar.db.DatabaseConstants.MIN_FREE_SPACE; +import java.util.Arrays; import java.util.Collections; import net.sf.briar.api.clock.SystemClock; @@ -79,7 +80,7 @@ public class DatabaseComponentImplTest extends DatabaseComponentTest { oneOf(database).startTransaction(); will(returnValue(txn)); oneOf(database).getOldMessages(txn, BYTES_PER_SWEEP); - will(returnValue(Collections.singletonList(messageId))); + will(returnValue(Arrays.asList(messageId))); oneOf(database).getSendability(txn, messageId); will(returnValue(0)); oneOf(database).removeMessage(txn, messageId); @@ -109,7 +110,7 @@ public class DatabaseComponentImplTest extends DatabaseComponentTest { oneOf(database).startTransaction(); will(returnValue(txn)); oneOf(database).getOldMessages(txn, BYTES_PER_SWEEP); - will(returnValue(Collections.singletonList(messageId))); + will(returnValue(Arrays.asList(messageId))); oneOf(database).getSendability(txn, messageId); will(returnValue(1)); oneOf(database).getGroupMessageParent(txn, messageId); diff --git a/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java b/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java index a952cb341a04e06ee88a7867ef3301968126b684..09c76be1adb97624d02af8712cceb2006a9dbe90 100644 --- a/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java +++ b/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java @@ -127,7 +127,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { oneOf(listener).eventOccurred(with(any(ContactAddedEvent.class))); // getContacts() oneOf(database).getContacts(txn); - will(returnValue(Collections.singletonList(contactId))); + will(returnValue(Arrays.asList(contactId))); // getRemoteProperties(transportId) oneOf(database).getRemoteProperties(txn, transportId); will(returnValue(Collections.emptyMap())); @@ -145,7 +145,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { will(returnValue(Collections.emptyList())); // getSubscriptions() oneOf(database).getSubscriptions(txn); - will(returnValue(Collections.singletonList(groupId))); + will(returnValue(Arrays.asList(groupId))); // unsubscribe(groupId) oneOf(database).containsSubscription(txn, groupId); will(returnValue(true)); @@ -173,13 +173,13 @@ public abstract class DatabaseComponentTest extends BriarTestCase { db.setRating(authorId, GOOD); // First time - listeners called db.setRating(authorId, GOOD); // Second time - not called assertEquals(contactId, db.addContact()); - assertEquals(Collections.singletonList(contactId), db.getContacts()); + assertEquals(Arrays.asList(contactId), db.getContacts()); assertEquals(Collections.emptyMap(), db.getRemoteProperties(transportId)); db.subscribe(group); // First time - listeners called db.subscribe(group); // Second time - not called assertEquals(Collections.emptyList(), db.getMessageHeaders(groupId)); - assertEquals(Collections.singletonList(groupId), db.getSubscriptions()); + assertEquals(Arrays.asList(groupId), db.getSubscriptions()); db.unsubscribe(groupId); // Listeners called db.removeContact(contactId); // Listeners called db.removeListener(listener); @@ -203,7 +203,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { will(returnValue(UNRATED)); // The sendability of the author's messages should be incremented oneOf(database).getMessagesByAuthor(txn, authorId); - will(returnValue(Collections.singletonList(messageId))); + will(returnValue(Arrays.asList(messageId))); oneOf(database).getSendability(txn, messageId); will(returnValue(0)); oneOf(database).setSendability(txn, messageId, 1); @@ -235,7 +235,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { will(returnValue(UNRATED)); // The sendability of the author's messages should be incremented oneOf(database).getMessagesByAuthor(txn, authorId); - will(returnValue(Collections.singletonList(messageId))); + will(returnValue(Arrays.asList(messageId))); oneOf(database).getSendability(txn, messageId); will(returnValue(0)); oneOf(database).setSendability(txn, messageId, 1); @@ -272,7 +272,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { will(returnValue(UNRATED)); // The sendability of the author's messages should be incremented oneOf(database).getMessagesByAuthor(txn, authorId); - will(returnValue(Collections.singletonList(messageId))); + will(returnValue(Arrays.asList(messageId))); oneOf(database).getSendability(txn, messageId); will(returnValue(0)); oneOf(database).setSendability(txn, messageId, 1); @@ -361,7 +361,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { oneOf(database).addGroupMessage(txn, message); will(returnValue(true)); oneOf(database).getContacts(txn); - will(returnValue(Collections.singletonList(contactId))); + will(returnValue(Arrays.asList(contactId))); oneOf(database).addStatus(txn, contactId, messageId, false); // The author is unrated and there are no sendable children oneOf(database).getRating(txn, authorId); @@ -396,7 +396,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { oneOf(database).addGroupMessage(txn, message); will(returnValue(true)); oneOf(database).getContacts(txn); - will(returnValue(Collections.singletonList(contactId))); + will(returnValue(Arrays.asList(contactId))); oneOf(database).addStatus(txn, contactId, messageId, false); // The author is rated GOOD and there are two sendable children oneOf(database).getRating(txn, authorId); @@ -589,7 +589,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { } catch(NoSuchContactException expected) {} try { - db.setSeen(contactId, Collections.singletonList(messageId)); + db.setSeen(contactId, Arrays.asList(messageId)); fail(); } catch(NoSuchContactException expected) {} @@ -896,12 +896,12 @@ public abstract class DatabaseComponentTest extends BriarTestCase { will(returnValue(true)); // Get the acked messages oneOf(database).removeOutstandingMessages(txn, contactId, - Collections.singletonList(messageId)); + Arrays.asList(messageId)); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner, shutdown); - db.receiveAck(contactId, new Ack(Collections.singletonList(messageId))); + db.receiveAck(contactId, new Ack(Arrays.asList(messageId))); context.assertIsSatisfied(); } @@ -1046,7 +1046,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { oneOf(database).addStatus(txn, contactId, messageId, true); // Set the status to seen = true for all other contacts (none) oneOf(database).getContacts(txn); - will(returnValue(Collections.singletonList(contactId))); + will(returnValue(Arrays.asList(contactId))); // Calculate the sendability - zero, so ancestors aren't updated oneOf(database).getRating(txn, authorId); will(returnValue(UNRATED)); @@ -1088,7 +1088,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { oneOf(database).addStatus(txn, contactId, messageId, true); // Set the status to seen = true for all other contacts (none) oneOf(database).getContacts(txn); - will(returnValue(Collections.singletonList(contactId))); + will(returnValue(Arrays.asList(contactId))); // Calculate the sendability - ancestors are updated oneOf(database).getRating(txn, authorId); will(returnValue(GOOD)); @@ -1213,7 +1213,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { oneOf(database).addGroupMessage(txn, message); will(returnValue(true)); oneOf(database).getContacts(txn); - will(returnValue(Collections.singletonList(contactId))); + will(returnValue(Arrays.asList(contactId))); oneOf(database).addStatus(txn, contactId, messageId, false); oneOf(database).getRating(txn, authorId); will(returnValue(UNRATED)); @@ -1391,13 +1391,13 @@ public abstract class DatabaseComponentTest extends BriarTestCase { allowing(database).commitTransaction(txn); allowing(database).containsContact(txn, contactId); will(returnValue(true)); - // setSeen(contactId, Collections.singletonList(messageId)) + // setSeen(contactId, Arrays.asList(messageId)) oneOf(database).setStatusSeenIfVisible(txn, contactId, messageId); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner, shutdown); - db.setSeen(contactId, Collections.singletonList(messageId)); + db.setSeen(contactId, Arrays.asList(messageId)); context.assertIsSatisfied(); } @@ -1430,7 +1430,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { shutdown); db.addListener(listener); - db.setVisibility(groupId, Collections.singletonList(contactId)); + db.setVisibility(groupId, Arrays.asList(contactId)); context.assertIsSatisfied(); } @@ -1481,22 +1481,20 @@ public abstract class DatabaseComponentTest extends BriarTestCase { will(returnValue(true)); oneOf(database).containsTransport(txn, transportId); will(returnValue(true)); - oneOf(database).addSecrets(txn, - Collections.singletonList(temporarySecret)); + oneOf(database).addSecrets(txn, Arrays.asList(temporarySecret)); oneOf(database).commitTransaction(txn); // getSecrets() oneOf(database).startTransaction(); will(returnValue(txn)); oneOf(database).getSecrets(txn); - will(returnValue(Collections.singletonList(temporarySecret))); + will(returnValue(Arrays.asList(temporarySecret))); oneOf(database).commitTransaction(txn); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner, shutdown); - db.addSecrets(Collections.singletonList(temporarySecret)); - assertEquals(Collections.singletonList(temporarySecret), - db.getSecrets()); + db.addSecrets(Arrays.asList(temporarySecret)); + assertEquals(Arrays.asList(temporarySecret), db.getSecrets()); context.assertIsSatisfied(); } diff --git a/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java b/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java index cbe723448c18f530668b0802277724d3c334b817..a4ebd5158f2d01a9c7f1be1c60c451a0f7e63d4a 100644 --- a/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java +++ b/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java @@ -490,11 +490,10 @@ public class H2DatabaseTest extends BriarTestCase { // The message ID should only be returned once Collection<MessageId> ids = db.getMessagesToAck(txn, contactId, 1234); - assertEquals(Collections.singletonList(messageId), ids); + assertEquals(Arrays.asList(messageId), ids); // Remove the message ID - db.removeMessagesToAck(txn, contactId, - Collections.singletonList(messageId)); + db.removeMessagesToAck(txn, contactId, Arrays.asList(messageId)); // The message ID should have been removed assertEquals(Collections.emptyList(), db.getMessagesToAck(txn, @@ -532,8 +531,7 @@ public class H2DatabaseTest extends BriarTestCase { assertFalse(it.hasNext()); // Pretend that the message was acked - db.removeOutstandingMessages(txn, contactId, - Collections.singletonList(messageId)); + db.removeOutstandingMessages(txn, contactId, Arrays.asList(messageId)); // The message still should not be sendable it = db.getSendableMessages(txn, contactId, ONE_MEGABYTE).iterator(); @@ -1108,8 +1106,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(Collections.emptyList(), db.getVisibility(txn, groupId)); // Make the group visible to the contact db.addVisibility(txn, contactId, groupId); - assertEquals(Collections.singletonList(contactId), - db.getVisibility(txn, groupId)); + assertEquals(Arrays.asList(contactId), db.getVisibility(txn, groupId)); // Make the group invisible again db.removeVisibility(txn, contactId, groupId); assertEquals(Collections.emptyList(), db.getVisibility(txn, groupId)); diff --git a/briar-tests/src/net/sf/briar/messaging/simplex/OutgoingSimplexConnectionTest.java b/briar-tests/src/net/sf/briar/messaging/simplex/OutgoingSimplexConnectionTest.java index 8843642c004b2664dadee81779233a15fa353ea5..31e5270ace230f265c4a30dd7f4530ae53ad1091 100644 --- a/briar-tests/src/net/sf/briar/messaging/simplex/OutgoingSimplexConnectionTest.java +++ b/briar-tests/src/net/sf/briar/messaging/simplex/OutgoingSimplexConnectionTest.java @@ -8,7 +8,6 @@ import static net.sf.briar.api.transport.TransportConstants.TAG_LENGTH; import java.io.ByteArrayOutputStream; import java.util.Arrays; -import java.util.Collections; import java.util.concurrent.Executor; import java.util.concurrent.Executors; @@ -29,8 +28,6 @@ import net.sf.briar.clock.ClockModule; import net.sf.briar.crypto.CryptoModule; import net.sf.briar.messaging.MessagingModule; import net.sf.briar.messaging.duplex.DuplexMessagingModule; -import net.sf.briar.messaging.simplex.OutgoingSimplexConnection; -import net.sf.briar.messaging.simplex.SimplexMessagingModule; import net.sf.briar.serial.SerialModule; import net.sf.briar.transport.TransportModule; @@ -186,7 +183,7 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase { // One message to send oneOf(db).generateBatch(with(contactId), with(any(int.class)), with(any(long.class))); - will(returnValue(Collections.singletonList(raw))); + will(returnValue(Arrays.asList(raw))); // No more messages oneOf(db).generateBatch(with(contactId), with(any(int.class)), with(any(long.class))); diff --git a/briar-tests/src/net/sf/briar/transport/ConnectionRegistryImplTest.java b/briar-tests/src/net/sf/briar/transport/ConnectionRegistryImplTest.java index b46ec1fd23f69065eab250a939f623bf9808eeb3..9e63803aab55efec53dcb543f444a612ba83f30b 100644 --- a/briar-tests/src/net/sf/briar/transport/ConnectionRegistryImplTest.java +++ b/briar-tests/src/net/sf/briar/transport/ConnectionRegistryImplTest.java @@ -34,19 +34,19 @@ public class ConnectionRegistryImplTest extends BriarTestCase { c.getConnectedContacts(transportId1)); // Check that a registered connection shows up c.registerConnection(contactId, transportId); - assertEquals(Collections.singletonList(contactId), + assertEquals(Arrays.asList(contactId), c.getConnectedContacts(transportId)); assertEquals(Collections.emptyList(), c.getConnectedContacts(transportId1)); // Register an identical connection - lookup should be unaffected c.registerConnection(contactId, transportId); - assertEquals(Collections.singletonList(contactId), + assertEquals(Arrays.asList(contactId), c.getConnectedContacts(transportId)); assertEquals(Collections.emptyList(), c.getConnectedContacts(transportId1)); // Unregister one of the connections - lookup should be unaffected c.unregisterConnection(contactId, transportId); - assertEquals(Collections.singletonList(contactId), + assertEquals(Arrays.asList(contactId), c.getConnectedContacts(transportId)); assertEquals(Collections.emptyList(), c.getConnectedContacts(transportId1)); @@ -67,7 +67,7 @@ public class ConnectionRegistryImplTest extends BriarTestCase { c.registerConnection(contactId1, transportId1); assertEquals(Arrays.asList(contactId, contactId1), c.getConnectedContacts(transportId)); - assertEquals(Collections.singletonList(contactId1), + assertEquals(Arrays.asList(contactId1), c.getConnectedContacts(transportId1)); } }