diff --git a/briar-api/src/net/sf/briar/api/serial/CountingConsumer.java b/briar-api/src/net/sf/briar/api/serial/CountingConsumer.java index 901bbd5642e681b3259c67009e55bc9e5b355e32..14509e09463cc1749f8347eb9111df3832dc093b 100644 --- a/briar-api/src/net/sf/briar/api/serial/CountingConsumer.java +++ b/briar-api/src/net/sf/briar/api/serial/CountingConsumer.java @@ -11,7 +11,7 @@ import net.sf.briar.api.FormatException; public class CountingConsumer implements Consumer { private final long limit; - private long count = 0L; + private long count = 0; public CountingConsumer(long limit) { this.limit = limit; diff --git a/briar-api/src/net/sf/briar/api/transport/TemporarySecret.java b/briar-api/src/net/sf/briar/api/transport/TemporarySecret.java index 60d10dabbdc3af10db7960c1866be7c88ea77775..d39866d98475594e11ed549b924b495747c86808 100644 --- a/briar-api/src/net/sf/briar/api/transport/TemporarySecret.java +++ b/briar-api/src/net/sf/briar/api/transport/TemporarySecret.java @@ -27,7 +27,7 @@ public class TemporarySecret extends Endpoint { long epoch, long clockDiff, long latency, boolean alice, long period, byte[] secret) { this(contactId, transportId, epoch, clockDiff, latency, alice, period, - secret, 0L, 0L, new byte[CONNECTION_WINDOW_SIZE / 8]); + secret, 0, 0, new byte[CONNECTION_WINDOW_SIZE / 8]); } /** Creates a temporary secret derived from the given endpoint. */ diff --git a/briar-core/src/net/sf/briar/crypto/CryptoComponentImpl.java b/briar-core/src/net/sf/briar/crypto/CryptoComponentImpl.java index bae1e7de85341c0cb71927c2b89d5de5847f77f4..a59ee4924b40684dfc361fa43b3bd0c0cbe08e8b 100644 --- a/briar-core/src/net/sf/briar/crypto/CryptoComponentImpl.java +++ b/briar-core/src/net/sf/briar/crypto/CryptoComponentImpl.java @@ -142,8 +142,8 @@ class CryptoComponentImpl implements CryptoComponent { } public ErasableKey deriveTagKey(byte[] secret, boolean alice) { - if(alice) return deriveKey(secret, A_TAG, 0L); - else return deriveKey(secret, B_TAG, 0L); + if(alice) return deriveKey(secret, A_TAG, 0); + else return deriveKey(secret, B_TAG, 0); } public ErasableKey deriveFrameKey(byte[] secret, long connection, diff --git a/briar-core/src/net/sf/briar/db/DatabaseCleanerImpl.java b/briar-core/src/net/sf/briar/db/DatabaseCleanerImpl.java index d515c1e1a3da291c30e9471a49f6ff0c3148d869..f2720b1b31de30d485d874468138ab1d38435a70 100644 --- a/briar-core/src/net/sf/briar/db/DatabaseCleanerImpl.java +++ b/briar-core/src/net/sf/briar/db/DatabaseCleanerImpl.java @@ -28,7 +28,7 @@ class DatabaseCleanerImpl extends TimerTask implements DatabaseCleaner { public void startCleaning(Callback callback, long msBetweenSweeps) { this.callback = callback; - timer.scheduleAtFixedRate(this, 0L, msBetweenSweeps); + timer.scheduleAtFixedRate(this, 0, msBetweenSweeps); } public void stopCleaning() { diff --git a/briar-core/src/net/sf/briar/db/DatabaseComponentImpl.java b/briar-core/src/net/sf/briar/db/DatabaseComponentImpl.java index faa69037a2d464876f39db10aa7ba08fde30687b..e54a3105363671f35e55808540dd1dc817e42d94 100644 --- a/briar-core/src/net/sf/briar/db/DatabaseComponentImpl.java +++ b/briar-core/src/net/sf/briar/db/DatabaseComponentImpl.java @@ -109,8 +109,8 @@ DatabaseCleaner.Callback { new CopyOnWriteArrayList<DatabaseListener>(); private final Object spaceLock = new Object(); - private long bytesStoredSinceLastCheck = 0L; // Locking: spaceLock - private long timeOfLastCheck = 0L; // Locking: spaceLock + private long bytesStoredSinceLastCheck = 0; // Locking: spaceLock + private long timeOfLastCheck = 0; // Locking: spaceLock private final Object openCloseLock = new Object(); private boolean open = false; // Locking: openCloseLock; @@ -1829,7 +1829,7 @@ DatabaseCleaner.Callback { long now = clock.currentTimeMillis(); if(bytesStoredSinceLastCheck > MAX_BYTES_BETWEEN_SPACE_CHECKS || now - timeOfLastCheck > MAX_MS_BETWEEN_SPACE_CHECKS) { - bytesStoredSinceLastCheck = 0L; + bytesStoredSinceLastCheck = 0; timeOfLastCheck = now; return true; } diff --git a/briar-core/src/net/sf/briar/db/DatabaseConstants.java b/briar-core/src/net/sf/briar/db/DatabaseConstants.java index 16686d41c21a0939fee1350d71d4b1df92a50400..ac31535e14912921e5cf2c7e8c6727830f84b812 100644 --- a/briar-core/src/net/sf/briar/db/DatabaseConstants.java +++ b/briar-core/src/net/sf/briar/db/DatabaseConstants.java @@ -28,7 +28,7 @@ interface DatabaseConstants { * The amount of free space will be checked whenever this many milliseconds * have passed since the last check. */ - long MAX_MS_BETWEEN_SPACE_CHECKS = 60L * 1000L; // 1 min + long MAX_MS_BETWEEN_SPACE_CHECKS = 60 * 1000; // 1 min /** * Up to this many bytes of messages will be expired from the database each @@ -40,11 +40,11 @@ interface DatabaseConstants { * The timestamp of the oldest message in the database is rounded using * this modulus to avoid revealing the presence of any particular message. */ - long RETENTION_MODULUS = 60L * 60L * 1000L; // 1 hour + long RETENTION_MODULUS = 60 * 60 * 1000; // 1 hour /** * The time in milliseconds after which a subscription or transport update * should be sent to a contact even if no changes have occurred. */ - long MAX_UPDATE_INTERVAL = 12L * 60L * 60L * 1000L; // 12 hours + long MAX_UPDATE_INTERVAL = 12 * 60 * 60 * 1000; // 12 hours } diff --git a/briar-core/src/net/sf/briar/db/JdbcDatabase.java b/briar-core/src/net/sf/briar/db/JdbcDatabase.java index 897d7c4733c960c23c606c1a1427e73f0d3e73c1..9c08f814e4889152aacc008238712c88ed010a4a 100644 --- a/briar-core/src/net/sf/briar/db/JdbcDatabase.java +++ b/briar-core/src/net/sf/briar/db/JdbcDatabase.java @@ -1017,7 +1017,7 @@ abstract class JdbcDatabase implements Database<Connection> { } protected long getDiskSpace(File f) { - long total = 0L; + long total = 0; if(f.isDirectory()) { for(File child : f.listFiles()) total += getDiskSpace(child); return total; @@ -1812,7 +1812,7 @@ abstract class JdbcDatabase implements Database<Connection> { ps.setInt(1, c.getInt()); rs = ps.executeQuery(); List<Group> subs = new ArrayList<Group>(); - long version = 0L; + long version = 0; while(rs.next()) { byte[] id = rs.getBytes(1); String name = rs.getString(2); @@ -2053,7 +2053,7 @@ abstract class JdbcDatabase implements Database<Connection> { if(!rs.next()) { rs.close(); ps.close(); - return -1L; + return -1; } long connection = rs.getLong(1); if(rs.next()) throw new DbStateException(); @@ -2492,12 +2492,12 @@ abstract class JdbcDatabase implements Database<Connection> { ps.setInt(1, c.getInt()); ps.setBytes(2, t.getBytes()); rs = ps.executeQuery(); - long currentVersion = rs.next() ? rs.getLong(1) : -1L; + long currentVersion = rs.next() ? rs.getLong(1) : -1; if(rs.next()) throw new DbStateException(); rs.close(); ps.close(); // Mark the update as needing to be acked - if(currentVersion == -1L) { + if(currentVersion == -1) { // The row doesn't exist - create it sql = "INSERT INTO contactTransportVersions (contactId," + " transportId, remoteVersion, remoteAcked)" diff --git a/briar-core/src/net/sf/briar/messaging/MessageReader.java b/briar-core/src/net/sf/briar/messaging/MessageReader.java index 7fa93c2d698d84e38b10367c2ca69f87b5c58396..0345b70c6e34b3315ef0a53825a76c73a8d7f87f 100644 --- a/briar-core/src/net/sf/briar/messaging/MessageReader.java +++ b/briar-core/src/net/sf/briar/messaging/MessageReader.java @@ -59,7 +59,7 @@ class MessageReader implements StructReader<UnverifiedMessage> { String subject = r.readString(MAX_SUBJECT_LENGTH); // Read the timestamp long timestamp = r.readInt64(); - if(timestamp < 0L) throw new FormatException(); + if(timestamp < 0) throw new FormatException(); // Read the salt byte[] salt = r.readBytes(SALT_LENGTH); if(salt.length < SALT_LENGTH) throw new FormatException(); diff --git a/briar-core/src/net/sf/briar/messaging/PacketReaderImpl.java b/briar-core/src/net/sf/briar/messaging/PacketReaderImpl.java index cdd5bdcbb48227b6b00f9070999a239079441366..85244e31174f9c51963b3f31f82bd32f99a2fbb5 100644 --- a/briar-core/src/net/sf/briar/messaging/PacketReaderImpl.java +++ b/briar-core/src/net/sf/briar/messaging/PacketReaderImpl.java @@ -156,7 +156,7 @@ class PacketReaderImpl implements PacketReader { public RetentionAck readRetentionAck() throws IOException { r.readStructId(RETENTION_ACK); long version = r.readInt64(); - if(version < 0L) throw new FormatException(); + if(version < 0) throw new FormatException(); return new RetentionAck(version); } @@ -167,9 +167,9 @@ class PacketReaderImpl implements PacketReader { public RetentionUpdate readRetentionUpdate() throws IOException { r.readStructId(RETENTION_UPDATE); long retention = r.readInt64(); - if(retention < 0L) throw new FormatException(); + if(retention < 0) throw new FormatException(); long version = r.readInt64(); - if(version < 0L) throw new FormatException(); + if(version < 0) throw new FormatException(); return new RetentionUpdate(retention, version); } @@ -180,7 +180,7 @@ class PacketReaderImpl implements PacketReader { public SubscriptionAck readSubscriptionAck() throws IOException { r.readStructId(SUBSCRIPTION_ACK); long version = r.readInt64(); - if(version < 0L) throw new FormatException(); + if(version < 0) throw new FormatException(); return new SubscriptionAck(version); } @@ -201,7 +201,7 @@ class PacketReaderImpl implements PacketReader { byte[] b = r.readBytes(UniqueId.LENGTH); if(b.length < UniqueId.LENGTH) throw new FormatException(); long version = r.readInt64(); - if(version < 0L) throw new FormatException(); + if(version < 0) throw new FormatException(); return new TransportAck(new TransportId(b), version); } @@ -225,7 +225,7 @@ class PacketReaderImpl implements PacketReader { throw new FormatException(); // Read the version number long version = r.readInt64(); - if(version < 0L) throw new FormatException(); + if(version < 0) throw new FormatException(); r.removeConsumer(counting); // Build and return the transport update return new TransportUpdate(id, new TransportProperties(m), version); diff --git a/briar-core/src/net/sf/briar/messaging/SubscriptionUpdateReader.java b/briar-core/src/net/sf/briar/messaging/SubscriptionUpdateReader.java index cfbae5675afe944c24bb8be3519e2cdb8215ac09..d73b86b44ed1011b989b5e3e39de0695d15de55f 100644 --- a/briar-core/src/net/sf/briar/messaging/SubscriptionUpdateReader.java +++ b/briar-core/src/net/sf/briar/messaging/SubscriptionUpdateReader.java @@ -35,7 +35,7 @@ class SubscriptionUpdateReader implements StructReader<SubscriptionUpdate> { r.readListEnd(); // Read the version number long version = r.readInt64(); - if(version < 0L) throw new FormatException(); + if(version < 0) throw new FormatException(); r.removeConsumer(counting); // Build and return the subscription update subs = Collections.unmodifiableList(subs); diff --git a/briar-core/src/net/sf/briar/plugins/bluetooth/BluetoothPluginFactory.java b/briar-core/src/net/sf/briar/plugins/bluetooth/BluetoothPluginFactory.java index 54e813be3c703369c51c1cb6fcbfd88f39b55f29..a3e4beac89753932b1cd92d93cc87f022aa69336 100644 --- a/briar-core/src/net/sf/briar/plugins/bluetooth/BluetoothPluginFactory.java +++ b/briar-core/src/net/sf/briar/plugins/bluetooth/BluetoothPluginFactory.java @@ -12,8 +12,8 @@ import net.sf.briar.api.plugins.duplex.DuplexPluginFactory; public class BluetoothPluginFactory implements DuplexPluginFactory { - private static final long MAX_LATENCY = 60L * 1000L; // 1 minute - private static final long POLLING_INTERVAL = 3L * 60L * 1000L; // 3 minutes + private static final long MAX_LATENCY = 60 * 1000; // 1 minute + private static final long POLLING_INTERVAL = 3 * 60 * 1000; // 3 minutes private final Executor pluginExecutor; private final Clock clock; diff --git a/briar-core/src/net/sf/briar/plugins/droidtooth/DroidtoothPluginFactory.java b/briar-core/src/net/sf/briar/plugins/droidtooth/DroidtoothPluginFactory.java index a0a2b385ef549e3998b660a8951de2b21ddbb2a8..54f8a9c38c69f9502b1209c9b30d17a9fb6e4ae2 100644 --- a/briar-core/src/net/sf/briar/plugins/droidtooth/DroidtoothPluginFactory.java +++ b/briar-core/src/net/sf/briar/plugins/droidtooth/DroidtoothPluginFactory.java @@ -12,8 +12,8 @@ import android.content.Context; public class DroidtoothPluginFactory implements DuplexPluginFactory { - private static final long MAX_LATENCY = 60L * 1000L; // 1 minute - private static final long POLLING_INTERVAL = 3L * 60L * 1000L; // 3 minutes + private static final long MAX_LATENCY = 60 * 1000; // 1 minute + private static final long POLLING_INTERVAL = 3 * 60 * 1000; // 3 minutes private final Executor pluginExecutor; private final AndroidExecutor androidExecutor; diff --git a/briar-core/src/net/sf/briar/plugins/file/FilePlugin.java b/briar-core/src/net/sf/briar/plugins/file/FilePlugin.java index d00b3d353a079f5505038e0bbfa64c54048e098c..11e55d127996024660b7d35e216ae66731ceeec2 100644 --- a/briar-core/src/net/sf/briar/plugins/file/FilePlugin.java +++ b/briar-core/src/net/sf/briar/plugins/file/FilePlugin.java @@ -81,7 +81,7 @@ public abstract class FilePlugin implements SimplexPlugin { } private long getCapacity(String path) throws IOException { - return FileSystemUtils.freeSpaceKb(path) * 1024L; + return FileSystemUtils.freeSpaceKb(path) * 1024; } protected void createReaderFromFile(final File f) { diff --git a/briar-core/src/net/sf/briar/plugins/file/RemovableDrivePluginFactory.java b/briar-core/src/net/sf/briar/plugins/file/RemovableDrivePluginFactory.java index c5a563bb22f1db15f6912bbdbfa5c9f464b4b315..845c38d9c40f4954191467f402b65c27138fc704 100644 --- a/briar-core/src/net/sf/briar/plugins/file/RemovableDrivePluginFactory.java +++ b/briar-core/src/net/sf/briar/plugins/file/RemovableDrivePluginFactory.java @@ -12,8 +12,8 @@ import net.sf.briar.util.OsUtils; public class RemovableDrivePluginFactory implements SimplexPluginFactory { // Maximum latency 14 days (Royal Mail or lackadaisical carrier pigeon) - private static final long MAX_LATENCY = 14L * 24L * 60L * 60L * 1000L; - private static final long POLLING_INTERVAL = 10L * 1000L; // 10 seconds + private static final long MAX_LATENCY = 14 * 24 * 60 * 60 * 1000; + private static final long POLLING_INTERVAL = 10 * 1000; // 10 seconds private final Executor pluginExecutor; diff --git a/briar-core/src/net/sf/briar/plugins/modem/ModemPluginFactory.java b/briar-core/src/net/sf/briar/plugins/modem/ModemPluginFactory.java index 59f684a075cfa4a94e702850e2e803ac5d132781..6a63508df3575a5acf58a96a25abcc11b878638e 100644 --- a/briar-core/src/net/sf/briar/plugins/modem/ModemPluginFactory.java +++ b/briar-core/src/net/sf/briar/plugins/modem/ModemPluginFactory.java @@ -12,8 +12,8 @@ import net.sf.briar.util.StringUtils; public class ModemPluginFactory implements DuplexPluginFactory { - private static final long MAX_LATENCY = 60L * 1000L; // 1 minute - private static final long POLLING_INTERVAL = 60L * 60L * 1000L; // 1 hour + private static final long MAX_LATENCY = 60 * 1000; // 1 minute + private static final long POLLING_INTERVAL = 60 * 60 * 1000; // 1 hour private final Executor pluginExecutor; private final ModemFactory modemFactory; diff --git a/briar-core/src/net/sf/briar/plugins/tcp/LanTcpPluginFactory.java b/briar-core/src/net/sf/briar/plugins/tcp/LanTcpPluginFactory.java index 69e13e9f0abc3747a448b8ce7491dec8d9967606..d743a4831e84788b54f2025ff7383501f3028f6d 100644 --- a/briar-core/src/net/sf/briar/plugins/tcp/LanTcpPluginFactory.java +++ b/briar-core/src/net/sf/briar/plugins/tcp/LanTcpPluginFactory.java @@ -12,8 +12,8 @@ import net.sf.briar.api.plugins.duplex.DuplexPluginFactory; public class LanTcpPluginFactory implements DuplexPluginFactory { - private static final long MAX_LATENCY = 60L * 1000L; // 1 minute - private static final long POLLING_INTERVAL = 60L * 1000L; // 1 minute + private static final long MAX_LATENCY = 60 * 1000; // 1 minute + private static final long POLLING_INTERVAL = 60 * 1000; // 1 minute private final Executor pluginExecutor; private final Clock clock; diff --git a/briar-core/src/net/sf/briar/plugins/tcp/WanTcpPluginFactory.java b/briar-core/src/net/sf/briar/plugins/tcp/WanTcpPluginFactory.java index b36dba318aa7bfd3e3cead15c45989c9273b2240..52dfd215761b29bb42ed830a5e717d9562d444ae 100644 --- a/briar-core/src/net/sf/briar/plugins/tcp/WanTcpPluginFactory.java +++ b/briar-core/src/net/sf/briar/plugins/tcp/WanTcpPluginFactory.java @@ -11,8 +11,8 @@ import net.sf.briar.api.plugins.duplex.DuplexPluginFactory; public class WanTcpPluginFactory implements DuplexPluginFactory { - private static final long MAX_LATENCY = 1L * 60L; // 1 minute - private static final long POLLING_INTERVAL = 5L * 60L * 1000L; // 5 minutes + private static final long MAX_LATENCY = 60 * 1000; // 1 minute + private static final long POLLING_INTERVAL = 5 * 60 * 1000; // 5 minutes private final Executor pluginExecutor; private final ShutdownManager shutdownManager; diff --git a/briar-core/src/net/sf/briar/plugins/tor/TorPluginFactory.java b/briar-core/src/net/sf/briar/plugins/tor/TorPluginFactory.java index 209b81e12df69945e297f2168e120dfe4efc5d3d..65800cff169d18c8d6fd529eefb0f5906cbf09e2 100644 --- a/briar-core/src/net/sf/briar/plugins/tor/TorPluginFactory.java +++ b/briar-core/src/net/sf/briar/plugins/tor/TorPluginFactory.java @@ -11,8 +11,8 @@ import net.sf.briar.util.StringUtils; public class TorPluginFactory implements DuplexPluginFactory { - private static final long MAX_LATENCY = 5L * 60L * 1000L; // 5 minutes - private static final long POLLING_INTERVAL = 15L * 60L * 1000L; // 15 mins + private static final long MAX_LATENCY = 5 * 60 * 1000; // 5 minutes + private static final long POLLING_INTERVAL = 15 * 60 * 1000; // 15 minutes private final Executor pluginExecutor; diff --git a/briar-core/src/net/sf/briar/reliability/Receiver.java b/briar-core/src/net/sf/briar/reliability/Receiver.java index de630fc31017604cd62866f19338a416694fa99b..807a0a9f3840179c64316adb3bac1601c4c42f22 100644 --- a/briar-core/src/net/sf/briar/reliability/Receiver.java +++ b/briar-core/src/net/sf/briar/reliability/Receiver.java @@ -20,7 +20,7 @@ class Receiver implements ReadHandler { private int windowSize = MAX_WINDOW_SIZE; // Locking: this private long finalSequenceNumber = Long.MAX_VALUE; - private long nextSequenceNumber = 1L; + private long nextSequenceNumber = 1; private volatile boolean valid = true; @@ -42,7 +42,7 @@ class Receiver implements ReadHandler { dataFrames.remove(d); // Update the window windowSize += d.getPayloadLength(); - sender.sendAck(0L, windowSize); + sender.sendAck(0, windowSize); nextSequenceNumber++; return d; } else { @@ -92,7 +92,7 @@ class Receiver implements ReadHandler { return; } long sequenceNumber = d.getSequenceNumber(); - if(sequenceNumber == 0L) { + if(sequenceNumber == 0) { // Window probe } else if(sequenceNumber < nextSequenceNumber) { // Duplicate data frame diff --git a/briar-core/src/net/sf/briar/reliability/SenderOutputStream.java b/briar-core/src/net/sf/briar/reliability/SenderOutputStream.java index 3f3df7df1d3ca29daebb427097bf462483fda86a..1e1e079904ff9f72cacb77f2328a9846d09eda23 100644 --- a/briar-core/src/net/sf/briar/reliability/SenderOutputStream.java +++ b/briar-core/src/net/sf/briar/reliability/SenderOutputStream.java @@ -9,7 +9,7 @@ class SenderOutputStream extends OutputStream { private final byte[] buf = new byte[Data.MAX_LENGTH]; private int offset = Data.HEADER_LENGTH; - private long sequenceNumber = 1L; + private long sequenceNumber = 1; SenderOutputStream(Sender sender) { this.sender = sender; diff --git a/briar-core/src/net/sf/briar/transport/FrameEncoder.java b/briar-core/src/net/sf/briar/transport/FrameEncoder.java index 2972064efabef4167f219feeced5176b4dda4124..20979c5ad8201881308468eaf0430a6d252f81e3 100644 --- a/briar-core/src/net/sf/briar/transport/FrameEncoder.java +++ b/briar-core/src/net/sf/briar/transport/FrameEncoder.java @@ -12,7 +12,7 @@ class FrameEncoder { static void encodeIv(byte[] iv, long frameNumber) { if(iv.length < IV_LENGTH) throw new IllegalArgumentException(); - if(frameNumber < 0L || frameNumber > MAX_32_BIT_UNSIGNED) + if(frameNumber < 0 || frameNumber > MAX_32_BIT_UNSIGNED) throw new IllegalArgumentException(); ByteUtils.writeUint32(frameNumber, iv, 0); for(int i = 4; i < IV_LENGTH; i++) iv[i] = 0; @@ -20,7 +20,7 @@ class FrameEncoder { static void encodeAad(byte[] aad, long frameNumber, int plaintextLength) { if(aad.length < AAD_LENGTH) throw new IllegalArgumentException(); - if(frameNumber < 0L || frameNumber > MAX_32_BIT_UNSIGNED) + if(frameNumber < 0 || frameNumber > MAX_32_BIT_UNSIGNED) throw new IllegalArgumentException(); if(plaintextLength < HEADER_LENGTH) throw new IllegalArgumentException(); diff --git a/briar-core/src/net/sf/briar/transport/IncomingEncryptionLayer.java b/briar-core/src/net/sf/briar/transport/IncomingEncryptionLayer.java index 6d446a8a5faeec0795092fc09acd3c0b33c74c08..01dc0cb4353de8267f9b8b5ff0f314d590f82eff 100644 --- a/briar-core/src/net/sf/briar/transport/IncomingEncryptionLayer.java +++ b/briar-core/src/net/sf/briar/transport/IncomingEncryptionLayer.java @@ -35,7 +35,7 @@ class IncomingEncryptionLayer implements FrameReader { iv = new byte[IV_LENGTH]; aad = new byte[AAD_LENGTH]; ciphertext = new byte[frameLength]; - frameNumber = 0L; + frameNumber = 0; finalFrame = false; } diff --git a/briar-core/src/net/sf/briar/transport/OutgoingEncryptionLayer.java b/briar-core/src/net/sf/briar/transport/OutgoingEncryptionLayer.java index 924c09db819159344958a967f85e8dcab33f5d93..658c4a26eaa6fc2a8046520b6a9baa60d48c7731 100644 --- a/briar-core/src/net/sf/briar/transport/OutgoingEncryptionLayer.java +++ b/briar-core/src/net/sf/briar/transport/OutgoingEncryptionLayer.java @@ -40,7 +40,7 @@ class OutgoingEncryptionLayer implements FrameWriter { iv = new byte[IV_LENGTH]; aad = new byte[AAD_LENGTH]; ciphertext = new byte[frameLength]; - frameNumber = 0L; + frameNumber = 0; writeTag = true; } @@ -58,7 +58,7 @@ class OutgoingEncryptionLayer implements FrameWriter { iv = new byte[IV_LENGTH]; aad = new byte[AAD_LENGTH]; ciphertext = new byte[frameLength]; - frameNumber = 0L; + frameNumber = 0; writeTag = false; } diff --git a/briar-core/src/net/sf/briar/util/ByteUtils.java b/briar-core/src/net/sf/briar/util/ByteUtils.java index d858b8f9b07f28d3eb6e2aefe96459bbc2cf8bdf..c64fddf6165764cfc922d0b464e51b5f5d5a0aad 100644 --- a/briar-core/src/net/sf/briar/util/ByteUtils.java +++ b/briar-core/src/net/sf/briar/util/ByteUtils.java @@ -28,7 +28,7 @@ public class ByteUtils { } public static void writeUint32(long i, byte[] b, int offset) { - if(i < 0L) throw new IllegalArgumentException(); + if(i < 0) throw new IllegalArgumentException(); if(i > MAX_32_BIT_UNSIGNED) throw new IllegalArgumentException(); if(b.length < offset + 4) throw new IllegalArgumentException(); b[offset] = (byte) (i >> 24); diff --git a/briar-core/src/net/sf/briar/util/FileUtils.java b/briar-core/src/net/sf/briar/util/FileUtils.java index c94e50a50be5885dd75786948838ddc74bbf9399..6151e1c9a4a6e93d199dd893791a46c666e017ab 100644 --- a/briar-core/src/net/sf/briar/util/FileUtils.java +++ b/briar-core/src/net/sf/briar/util/FileUtils.java @@ -91,7 +91,7 @@ public class FileUtils { StatFs s = new StatFs(f.getAbsolutePath()); return (long) s.getAvailableBlocks() * s.getBlockSize(); } else { - return FileSystemUtils.freeSpaceKb(f.getAbsolutePath()) * 1024L; + return FileSystemUtils.freeSpaceKb(f.getAbsolutePath()) * 1024; } } diff --git a/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java b/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java index dcb14d8047f46d1447a37021390224f7079e7ae2..85e21b7052f2d6da85b6148bf0cc67e26670e066 100644 --- a/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java +++ b/briar-tests/src/net/sf/briar/ProtocolIntegrationTest.java @@ -133,7 +133,7 @@ public class ProtocolIntegrationTest extends BriarTestCase { private byte[] write() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); ConnectionContext ctx = new ConnectionContext(contactId, transportId, - secret.clone(), 0L, true); + secret.clone(), 0, true); ConnectionWriter conn = connectionWriterFactory.createConnectionWriter( out, Long.MAX_VALUE, ctx, false, true); OutputStream out1 = conn.getOutputStream(); @@ -155,11 +155,11 @@ public class ProtocolIntegrationTest extends BriarTestCase { writer.writeRequest(new Request(requested, 4)); SubscriptionUpdate su = new SubscriptionUpdate( - Arrays.asList(group, group1), 1L); + Arrays.asList(group, group1), 1); writer.writeSubscriptionUpdate(su); TransportUpdate tu = new TransportUpdate(transportId, - transportProperties, 1L); + transportProperties, 1); writer.writeTransportUpdate(tu); writer.flush(); @@ -172,7 +172,7 @@ public class ProtocolIntegrationTest extends BriarTestCase { assertEquals(TAG_LENGTH, in.read(tag, 0, TAG_LENGTH)); // FIXME: Check that the expected tag was received ConnectionContext ctx = new ConnectionContext(contactId, transportId, - secret.clone(), 0L, false); + secret.clone(), 0, false); ConnectionReader conn = connectionReaderFactory.createConnectionReader( in, ctx, true, true); InputStream in1 = conn.getInputStream(); @@ -217,14 +217,14 @@ public class ProtocolIntegrationTest extends BriarTestCase { assertTrue(reader.hasSubscriptionUpdate()); SubscriptionUpdate su = reader.readSubscriptionUpdate(); assertEquals(Arrays.asList(group, group1), su.getGroups()); - assertEquals(1L, su.getVersion()); + assertEquals(1, su.getVersion()); // Read the transport update assertTrue(reader.hasTransportUpdate()); TransportUpdate tu = reader.readTransportUpdate(); assertEquals(transportId, tu.getId()); assertEquals(transportProperties, tu.getProperties()); - assertEquals(1L, tu.getVersion()); + assertEquals(1, tu.getVersion()); in.close(); } diff --git a/briar-tests/src/net/sf/briar/db/DatabaseCleanerImplTest.java b/briar-tests/src/net/sf/briar/db/DatabaseCleanerImplTest.java index cbe77eda24e55292e8ef8825d69703d01002ac34..a2c761e016ea02ddbded6ce294ff781d3b72dace 100644 --- a/briar-tests/src/net/sf/briar/db/DatabaseCleanerImplTest.java +++ b/briar-tests/src/net/sf/briar/db/DatabaseCleanerImplTest.java @@ -31,7 +31,7 @@ public class DatabaseCleanerImplTest extends BriarTestCase { Timer timer = new SystemTimer(); DatabaseCleanerImpl cleaner = new DatabaseCleanerImpl(timer); // Start the cleaner - cleaner.startCleaning(callback, 10L); + cleaner.startCleaning(callback, 10); // The database should be cleaned five times (allow 5s for system load) assertTrue(latch.await(5, SECONDS)); // Stop the cleaner @@ -55,13 +55,13 @@ public class DatabaseCleanerImplTest extends BriarTestCase { DatabaseCleanerImpl cleaner = new DatabaseCleanerImpl(timer); long start = System.currentTimeMillis(); // Start the cleaner - cleaner.startCleaning(callback, 10L * 1000L); + cleaner.startCleaning(callback, 10 * 1000); // The database should be cleaned once at startup assertTrue(latch.await(5, SECONDS)); // Stop the cleaner (it should be waiting between sweeps) cleaner.stopCleaning(); long end = System.currentTimeMillis(); // Check that much less than 10 seconds expired - assertTrue(end - start < 10L * 1000L); + assertTrue(end - start < 10 * 1000); } } diff --git a/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java b/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java index 0286a9798f597ac1e96af5e957c764798705417c..c19e6670c5bb1eb1b3b0f8eeae5925f02ab98d08 100644 --- a/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java +++ b/briar-tests/src/net/sf/briar/db/DatabaseComponentTest.java @@ -78,9 +78,9 @@ public abstract class DatabaseComponentTest extends BriarTestCase { transportId = new TransportId(TestUtils.getRandomId()); transportProperties = new TransportProperties( Collections.singletonMap("foo", "bar")); - endpoint = new Endpoint(contactId, transportId, 123L, 234L, 345L, true); - temporarySecret = new TemporarySecret(contactId, transportId, 1L, 2L, - 3L, false, 4L, new byte[32], 5L, 6L, new byte[4]); + endpoint = new Endpoint(contactId, transportId, 123, 234, 345, true); + temporarySecret = new TemporarySecret(contactId, transportId, 1, 2, + 3, false, 4, new byte[32], 5, 6, new byte[4]); } protected abstract <T> DatabaseComponent createDatabaseComponent( @@ -569,14 +569,14 @@ public abstract class DatabaseComponentTest extends BriarTestCase { try { SubscriptionUpdate u = new SubscriptionUpdate( - Collections.<Group>emptyList(), 1L); + Collections.<Group>emptyList(), 1); db.receiveSubscriptionUpdate(contactId, u); fail(); } catch(NoSuchContactException expected) {} try { TransportUpdate u = new TransportUpdate(transportId, - transportProperties, 1L); + transportProperties, 1); db.receiveTransportUpdate(contactId, u); fail(); } catch(NoSuchContactException expected) {} @@ -625,12 +625,12 @@ public abstract class DatabaseComponentTest extends BriarTestCase { assertEquals(contactId, db.addContact()); try { - db.incrementConnectionCounter(contactId, transportId, 0L); + db.incrementConnectionCounter(contactId, transportId, 0); fail(); } catch(NoSuchTransportException expected) {} try { - db.setConnectionWindow(contactId, transportId, 0L, 0L, new byte[4]); + db.setConnectionWindow(contactId, transportId, 0, 0, new byte[4]); fail(); } catch(NoSuchTransportException expected) {} @@ -809,14 +809,14 @@ public abstract class DatabaseComponentTest extends BriarTestCase { allowing(database).containsContact(txn, contactId); will(returnValue(true)); oneOf(database).getSubscriptionUpdate(txn, contactId); - will(returnValue(new SubscriptionUpdate(Arrays.asList(group), 1L))); + will(returnValue(new SubscriptionUpdate(Arrays.asList(group), 1))); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner, shutdown); SubscriptionUpdate u = db.generateSubscriptionUpdate(contactId); assertEquals(Arrays.asList(group), u.getGroups()); - assertEquals(1L, u.getVersion()); + assertEquals(1, u.getVersion()); context.assertIsSatisfied(); } @@ -860,7 +860,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { will(returnValue(true)); oneOf(database).getTransportUpdates(txn, contactId); will(returnValue(Arrays.asList(new TransportUpdate(transportId, - transportProperties, 1L)))); + transportProperties, 1)))); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner, shutdown); @@ -872,7 +872,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase { TransportUpdate u = updates.iterator().next(); assertEquals(transportId, u.getId()); assertEquals(transportProperties, u.getProperties()); - assertEquals(1L, u.getVersion()); + assertEquals(1, u.getVersion()); context.assertIsSatisfied(); } @@ -1155,12 +1155,12 @@ public abstract class DatabaseComponentTest extends BriarTestCase { allowing(database).containsContact(txn, contactId); will(returnValue(true)); oneOf(database).setSubscriptions(txn, contactId, - Arrays.asList(group), 1L); + Arrays.asList(group), 1); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner, shutdown); - SubscriptionUpdate u = new SubscriptionUpdate(Arrays.asList(group), 1L); + SubscriptionUpdate u = new SubscriptionUpdate(Arrays.asList(group), 1); db.receiveSubscriptionUpdate(contactId, u); context.assertIsSatisfied(); @@ -1180,13 +1180,13 @@ public abstract class DatabaseComponentTest extends BriarTestCase { allowing(database).containsContact(txn, contactId); will(returnValue(true)); oneOf(database).setRemoteProperties(txn, contactId, transportId, - transportProperties, 1L); + transportProperties, 1); }}); DatabaseComponent db = createDatabaseComponent(database, cleaner, shutdown); TransportUpdate u = new TransportUpdate(transportId, - transportProperties, 1L); + transportProperties, 1); db.receiveTransportUpdate(contactId, u); 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 05fa70c6fb34fa7bcc07b50b750ad7e7dd841704..8be2af1b08a205f4475bf686718122ab240a3be8 100644 --- a/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java +++ b/briar-tests/src/net/sf/briar/db/H2DatabaseTest.java @@ -296,7 +296,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); db.setStatus(txn, contactId, messageId, Status.NEW); @@ -334,7 +334,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); @@ -387,7 +387,7 @@ public class H2DatabaseTest extends BriarTestCase { assertFalse(it.hasNext()); // The contact subscribing should make the message sendable - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); assertTrue(db.hasSendableMessages(txn, contactId)); it = db.getSendableMessages(txn, contactId, ONE_MEGABYTE).iterator(); assertTrue(it.hasNext()); @@ -395,7 +395,7 @@ public class H2DatabaseTest extends BriarTestCase { assertFalse(it.hasNext()); // The contact unsubscribing should make the message unsendable - db.setSubscriptions(txn, contactId, Collections.<Group>emptyList(), 2L); + db.setSubscriptions(txn, contactId, Collections.<Group>emptyList(), 2); assertFalse(db.hasSendableMessages(txn, contactId)); it = db.getSendableMessages(txn, contactId, ONE_MEGABYTE).iterator(); assertFalse(it.hasNext()); @@ -413,7 +413,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); db.setStatus(txn, contactId, messageId, Status.NEW); @@ -443,7 +443,7 @@ public class H2DatabaseTest extends BriarTestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); db.setStatus(txn, contactId, messageId, Status.NEW); @@ -527,7 +527,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); db.setSendability(txn, messageId, 1); db.setStatus(txn, contactId, messageId, Status.NEW); @@ -668,7 +668,7 @@ public class H2DatabaseTest extends BriarTestCase { // Sanity check: there should be enough space on disk for this test String path = testDir.getAbsolutePath(); - assertTrue(FileSystemUtils.freeSpaceKb(path) * 1024L > MAX_SIZE); + assertTrue(FileSystemUtils.freeSpaceKb(path) * 1024 > MAX_SIZE); // The free space should not be more than the allowed maximum size long free = db.getFreeSpace(); @@ -766,20 +766,20 @@ public class H2DatabaseTest extends BriarTestCase { TransportProperties p = new TransportProperties( Collections.singletonMap("foo", "bar")); assertEquals(contactId, db.addContact(txn)); - db.setRemoteProperties(txn, contactId, transportId, p, 1L); + db.setRemoteProperties(txn, contactId, transportId, p, 1); assertEquals(Collections.singletonMap(contactId, p), db.getRemoteProperties(txn, transportId)); // Replace the transport properties TransportProperties p1 = new TransportProperties( Collections.singletonMap("baz", "bam")); - db.setRemoteProperties(txn, contactId, transportId, p1, 2L); + db.setRemoteProperties(txn, contactId, transportId, p1, 2); assertEquals(Collections.singletonMap(contactId, p1), db.getRemoteProperties(txn, transportId)); // Remove the transport properties TransportProperties p2 = new TransportProperties(); - db.setRemoteProperties(txn, contactId, transportId, p2, 3L); + db.setRemoteProperties(txn, contactId, transportId, p2, 3); assertEquals(Collections.emptyMap(), db.getRemoteProperties(txn, transportId)); @@ -856,21 +856,21 @@ public class H2DatabaseTest extends BriarTestCase { TransportProperties p = new TransportProperties( Collections.singletonMap("foo", "bar")); assertEquals(contactId, db.addContact(txn)); - db.setRemoteProperties(txn, contactId, transportId, p, 1L); + db.setRemoteProperties(txn, contactId, transportId, p, 1); assertEquals(Collections.singletonMap(contactId, p), db.getRemoteProperties(txn, transportId)); // Replace the transport properties with version 2 TransportProperties p1 = new TransportProperties( Collections.singletonMap("baz", "bam")); - db.setRemoteProperties(txn, contactId, transportId, p1, 2L); + db.setRemoteProperties(txn, contactId, transportId, p1, 2); assertEquals(Collections.singletonMap(contactId, p1), db.getRemoteProperties(txn, transportId)); // Try to replace the transport properties with version 1 TransportProperties p2 = new TransportProperties( Collections.singletonMap("quux", "etc")); - db.setRemoteProperties(txn, contactId, transportId, p2, 1L); + db.setRemoteProperties(txn, contactId, transportId, p2, 1); // Version 2 of the properties should still be there assertEquals(Collections.singletonMap(contactId, p1), @@ -889,7 +889,7 @@ public class H2DatabaseTest extends BriarTestCase { // Add a contact and subscribe to a group assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); // The message is not in the database assertNull(db.getRawMessageIfSendable(txn, contactId, messageId)); @@ -906,7 +906,7 @@ public class H2DatabaseTest extends BriarTestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); // Set the sendability to > 0 and the status to SEEN @@ -929,7 +929,7 @@ public class H2DatabaseTest extends BriarTestCase { // Add a contact, subscribe to a group and store a message assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); // Set the sendability to 0 and the status to NEW @@ -953,8 +953,8 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); - db.setRetentionTime(txn, contactId, timestamp + 1, 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); + db.setRetentionTime(txn, contactId, timestamp + 1, 1); db.addGroupMessage(txn, message); // Set the sendability to > 0 and the status to NEW @@ -977,7 +977,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); // Set the sendability to > 0 and the status to NEW @@ -1002,7 +1002,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); // The message is not in the database assertFalse(db.setStatusSeenIfVisible(txn, contactId, messageId)); @@ -1019,7 +1019,7 @@ public class H2DatabaseTest extends BriarTestCase { // Add a contact with a subscription assertEquals(contactId, db.addContact(txn)); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); // There's no local subscription for the group assertFalse(db.setStatusSeenIfVisible(txn, contactId, messageId)); @@ -1057,7 +1057,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addGroupMessage(txn, message); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.setStatus(txn, contactId, messageId, Status.NEW); // The subscription is not visible @@ -1077,7 +1077,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); // The message has already been seen by the contact @@ -1099,7 +1099,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(contactId, db.addContact(txn)); db.addSubscription(txn, group); db.addVisibility(txn, contactId, groupId); - db.setSubscriptions(txn, contactId, Arrays.asList(group), 1L); + db.setSubscriptions(txn, contactId, Arrays.asList(group), 1); db.addGroupMessage(txn, message); // The message has not been seen by the contact @@ -1511,11 +1511,11 @@ public class H2DatabaseTest extends BriarTestCase { @Test public void testTemporarySecrets() throws Exception { // Create an endpoint and three consecutive temporary secrets - long epoch = 123L, clockDiff = 234L, latency = 345L; + long epoch = 123, clockDiff = 234, latency = 345; boolean alice = false; - long outgoing1 = 456L, centre1 = 567L; - long outgoing2 = 678L, centre2 = 789L; - long outgoing3 = 890L, centre3 = 901L; + long outgoing1 = 456, centre1 = 567; + long outgoing2 = 678, centre2 = 789; + long outgoing3 = 890, centre3 = 901; Endpoint ep = new Endpoint(contactId, transportId, epoch, clockDiff, latency, alice); Random random = new Random(); @@ -1523,19 +1523,19 @@ public class H2DatabaseTest extends BriarTestCase { random.nextBytes(secret1); random.nextBytes(bitmap1); TemporarySecret s1 = new TemporarySecret(contactId, transportId, epoch, - clockDiff, latency, alice, 0L, secret1, outgoing1, centre1, + clockDiff, latency, alice, 0, secret1, outgoing1, centre1, bitmap1); byte[] secret2 = new byte[32], bitmap2 = new byte[4]; random.nextBytes(secret2); random.nextBytes(bitmap2); TemporarySecret s2 = new TemporarySecret(contactId, transportId, epoch, - clockDiff, latency, alice, 1L, secret2, outgoing2, centre2, + clockDiff, latency, alice, 1, secret2, outgoing2, centre2, bitmap2); byte[] secret3 = new byte[32], bitmap3 = new byte[4]; random.nextBytes(secret3); random.nextBytes(bitmap3); TemporarySecret s3 = new TemporarySecret(contactId, transportId, epoch, - clockDiff, latency, alice, 2L, secret3, outgoing3, centre3, + clockDiff, latency, alice, 2, secret3, outgoing3, centre3, bitmap3); Database<Connection> db = open(false); @@ -1562,13 +1562,13 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(clockDiff, s.getClockDifference()); assertEquals(latency, s.getLatency()); assertEquals(alice, s.getAlice()); - if(s.getPeriod() == 0L) { + if(s.getPeriod() == 0) { assertArrayEquals(secret1, s.getSecret()); assertEquals(outgoing1, s.getOutgoingConnectionCounter()); assertEquals(centre1, s.getWindowCentre()); assertArrayEquals(bitmap1, s.getWindowBitmap()); foundFirst = true; - } else if(s.getPeriod() == 1L) { + } else if(s.getPeriod() == 1) { assertArrayEquals(secret2, s.getSecret()); assertEquals(outgoing2, s.getOutgoingConnectionCounter()); assertEquals(centre2, s.getWindowCentre()); @@ -1594,13 +1594,13 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(clockDiff, s.getClockDifference()); assertEquals(latency, s.getLatency()); assertEquals(alice, s.getAlice()); - if(s.getPeriod() == 1L) { + if(s.getPeriod() == 1) { assertArrayEquals(secret2, s.getSecret()); assertEquals(outgoing2, s.getOutgoingConnectionCounter()); assertEquals(centre2, s.getWindowCentre()); assertArrayEquals(bitmap2, s.getWindowBitmap()); foundSecond = true; - } else if(s.getPeriod() == 2L) { + } else if(s.getPeriod() == 2) { assertArrayEquals(secret3, s.getSecret()); assertEquals(outgoing3, s.getOutgoingConnectionCounter()); assertEquals(centre3, s.getWindowCentre()); @@ -1624,9 +1624,9 @@ public class H2DatabaseTest extends BriarTestCase { @Test public void testIncrementConnectionCounter() throws Exception { // Create an endpoint and a temporary secret - long epoch = 123L, clockDiff = 234L, latency = 345L; + long epoch = 123, clockDiff = 234, latency = 345; boolean alice = false; - long period = 456L, outgoing = 567L, centre = 678L; + long period = 456, outgoing = 567, centre = 678; Endpoint ep = new Endpoint(contactId, transportId, epoch, clockDiff, latency, alice); Random random = new Random(); @@ -1660,7 +1660,7 @@ public class H2DatabaseTest extends BriarTestCase { // Increment the connection counter twice and retrieve the secret again assertEquals(outgoing, db.incrementConnectionCounter(txn, s.getContactId(), s.getTransportId(), s.getPeriod())); - assertEquals(outgoing + 1L, db.incrementConnectionCounter(txn, + assertEquals(outgoing + 1, db.incrementConnectionCounter(txn, s.getContactId(), s.getTransportId(), s.getPeriod())); secrets = db.getSecrets(txn); assertEquals(1, secrets.size()); @@ -1669,7 +1669,7 @@ public class H2DatabaseTest extends BriarTestCase { assertEquals(transportId, s.getTransportId()); assertEquals(period, s.getPeriod()); assertArrayEquals(secret, s.getSecret()); - assertEquals(outgoing + 2L, s.getOutgoingConnectionCounter()); + assertEquals(outgoing + 2, s.getOutgoingConnectionCounter()); assertEquals(centre, s.getWindowCentre()); assertArrayEquals(bitmap, s.getWindowBitmap()); @@ -1680,9 +1680,9 @@ public class H2DatabaseTest extends BriarTestCase { @Test public void testSetConnectionWindow() throws Exception { // Create an endpoint and a temporary secret - long epoch = 123L, clockDiff = 234L, latency = 345L; + long epoch = 123, clockDiff = 234, latency = 345; boolean alice = false; - long period = 456L, outgoing = 567L, centre = 678L; + long period = 456, outgoing = 567, centre = 678; Endpoint ep = new Endpoint(contactId, transportId, epoch, clockDiff, latency, alice); Random random = new Random(); @@ -1729,7 +1729,7 @@ public class H2DatabaseTest extends BriarTestCase { assertArrayEquals(bitmap, s.getWindowBitmap()); // Updating a nonexistent window should not throw an exception - db.setConnectionWindow(txn, contactId, transportId, period + 1L, 1L, + db.setConnectionWindow(txn, contactId, transportId, period + 1, 1, bitmap); // The nonexistent window should not have been created secrets = db.getSecrets(txn); @@ -1750,8 +1750,8 @@ public class H2DatabaseTest extends BriarTestCase { @Test public void testContactTransports() throws Exception { // Create some endpoints - long epoch1 = 123L, clockDiff1 = 234L, latency1 = 345L; - long epoch2 = 456L, clockDiff2 = 567L, latency2 = 678L; + long epoch1 = 123, clockDiff1 = 234, latency1 = 345; + long epoch2 = 456, clockDiff2 = 567, latency2 = 678; boolean alice1 = true, alice2 = false; TransportId transportId1 = new TransportId(TestUtils.getRandomId()); TransportId transportId2 = new TransportId(TestUtils.getRandomId()); 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 746cbfb153b23cc120edd8d265649d3c53edcbaf..6e6d261c7a64726dcb2f6ab8b2a1f6fac34ece99 100644 --- a/briar-tests/src/net/sf/briar/messaging/simplex/OutgoingSimplexConnectionTest.java +++ b/briar-tests/src/net/sf/briar/messaging/simplex/OutgoingSimplexConnectionTest.java @@ -89,7 +89,7 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase { TestSimplexTransportWriter transport = new TestSimplexTransportWriter( out, MAX_PACKET_LENGTH, true); ConnectionContext ctx = new ConnectionContext(contactId, transportId, - secret, 0L, true); + secret, 0, true); OutgoingSimplexConnection connection = new OutgoingSimplexConnection(db, connRegistry, connWriterFactory, packetWriterFactory, ctx, transport); @@ -107,7 +107,7 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase { TestSimplexTransportWriter transport = new TestSimplexTransportWriter( out, MIN_CONNECTION_LENGTH, true); ConnectionContext ctx = new ConnectionContext(contactId, transportId, - secret, 0L, true); + secret, 0, true); OutgoingSimplexConnection connection = new OutgoingSimplexConnection(db, connRegistry, connWriterFactory, packetWriterFactory, ctx, transport); @@ -152,7 +152,7 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase { TestSimplexTransportWriter transport = new TestSimplexTransportWriter( out, MIN_CONNECTION_LENGTH, true); ConnectionContext ctx = new ConnectionContext(contactId, transportId, - secret, 0L, true); + secret, 0, true); OutgoingSimplexConnection connection = new OutgoingSimplexConnection(db, connRegistry, connWriterFactory, packetWriterFactory, ctx, transport); diff --git a/briar-tests/src/net/sf/briar/messaging/simplex/SimplexMessagingIntegrationTest.java b/briar-tests/src/net/sf/briar/messaging/simplex/SimplexMessagingIntegrationTest.java index 81322d93d258861f3d0d6eb55043490f5633cb61..15affd913bf1464b28e2e9c60359aad9f636381c 100644 --- a/briar-tests/src/net/sf/briar/messaging/simplex/SimplexMessagingIntegrationTest.java +++ b/briar-tests/src/net/sf/briar/messaging/simplex/SimplexMessagingIntegrationTest.java @@ -47,8 +47,8 @@ import com.google.inject.Injector; public class SimplexMessagingIntegrationTest extends BriarTestCase { - private static final long CLOCK_DIFFERENCE = 60 * 1000L; - private static final long LATENCY = 60 * 1000L; + private static final long CLOCK_DIFFERENCE = 60 * 1000; + private static final long LATENCY = 60 * 1000; private final File testDir = TestUtils.getTestDirectory(); private final File aliceDir = new File(testDir, "alice"); diff --git a/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothClientTest.java b/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothClientTest.java index c01cf4fe1ba55a64d6633ef959f6f44357751d7c..0bf02af7549f6070e9d8079b4071213eef5c4333 100644 --- a/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothClientTest.java +++ b/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothClientTest.java @@ -26,8 +26,8 @@ public class BluetoothClientTest extends DuplexClientTest { // Create the plugin callback = new ClientCallback(new TransportConfig(), new TransportProperties(), remote); - plugin = new BluetoothPlugin(executor, new SystemClock(), callback, 0L, - 0L); + plugin = new BluetoothPlugin(executor, new SystemClock(), callback, 0, + 0); } public static void main(String[] args) throws Exception { diff --git a/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothServerTest.java b/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothServerTest.java index 8dbe021c50ec803a420c587ea5aeaefa2c3c22ff..2adf38df66c6e227a17276a041a737de391738ae 100644 --- a/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothServerTest.java +++ b/briar-tests/src/net/sf/briar/plugins/bluetooth/BluetoothServerTest.java @@ -21,8 +21,8 @@ public class BluetoothServerTest extends DuplexServerTest { // Create the plugin callback = new ServerCallback(new TransportConfig(), local, Collections.singletonMap(contactId, new TransportProperties())); - plugin = new BluetoothPlugin(executor, new SystemClock(), callback, 0L, - 0L); + plugin = new BluetoothPlugin(executor, new SystemClock(), callback, 0, + 0); } public static void main(String[] args) throws Exception { diff --git a/briar-tests/src/net/sf/briar/plugins/file/RemovableDrivePluginTest.java b/briar-tests/src/net/sf/briar/plugins/file/RemovableDrivePluginTest.java index ba81586efe1dcb0d5c1dd1333b96fc48fbed5816..27d8220c4f05b06e7d2b1bd9c818876f2a9fd221 100644 --- a/briar-tests/src/net/sf/briar/plugins/file/RemovableDrivePluginTest.java +++ b/briar-tests/src/net/sf/briar/plugins/file/RemovableDrivePluginTest.java @@ -54,7 +54,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); plugin.start(); assertNull(plugin.createWriter(contactId)); @@ -89,7 +89,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); plugin.start(); assertNull(plugin.createWriter(contactId)); @@ -126,7 +126,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); plugin.start(); assertNull(plugin.createWriter(contactId)); @@ -165,7 +165,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); plugin.start(); assertNull(plugin.createWriter(contactId)); @@ -204,7 +204,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); plugin.start(); assertNotNull(plugin.createWriter(contactId)); @@ -212,7 +212,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { File[] files = drive1.listFiles(); assertNotNull(files); assertEquals(1, files.length); - assertEquals(0L, files[0].length()); + assertEquals(0, files[0].length()); context.assertIsSatisfied(); } @@ -247,7 +247,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); plugin.start(); SimplexTransportWriter writer = plugin.createWriter(contactId); @@ -256,7 +256,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { File[] files = drive1.listFiles(); assertNotNull(files); assertEquals(1, files.length); - assertEquals(0L, files[0].length()); + assertEquals(0, files[0].length()); // Writing to the output stream should increase the size of the file OutputStream out = writer.getOutputStream(); out.write(new byte[123]); @@ -265,7 +265,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { // Disposing of the writer should not delete the file writer.dispose(false); assertTrue(files[0].exists()); - assertEquals(123L, files[0].length()); + assertEquals(123, files[0].length()); context.assertIsSatisfied(); } @@ -286,7 +286,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); plugin.start(); plugin.driveInserted(testDir); @@ -306,7 +306,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { context.mock(RemovableDriveMonitor.class); RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor, - callback, finder, monitor, 0L); + callback, finder, monitor, 0); assertFalse(plugin.isPossibleConnectionFilename("abcdefg.dat")); assertFalse(plugin.isPossibleConnectionFilename("abcdefghi.dat")); @@ -334,7 +334,7 @@ public class RemovableDrivePluginTest extends BriarTestCase { }}); RemovableDrivePlugin plugin = new RemovableDrivePlugin( - new ImmediateExecutor(), callback, finder, monitor, 0L); + new ImmediateExecutor(), callback, finder, monitor, 0); plugin.start(); File f = new File(testDir, "abcdefgh.dat"); diff --git a/briar-tests/src/net/sf/briar/plugins/modem/ModemPluginTest.java b/briar-tests/src/net/sf/briar/plugins/modem/ModemPluginTest.java index aae603511fc9a6551f16dfe3dd1217ef8b45c02c..7707760015f6fdd8dfde6fcac5f0d602b6ec50e7 100644 --- a/briar-tests/src/net/sf/briar/plugins/modem/ModemPluginTest.java +++ b/briar-tests/src/net/sf/briar/plugins/modem/ModemPluginTest.java @@ -37,7 +37,7 @@ public class ModemPluginTest extends BriarTestCase { final SerialPortList serialPortList = context.mock(SerialPortList.class); final ModemPlugin plugin = new ModemPlugin(null, modemFactory, - serialPortList, null, 0L, 0L, true); + serialPortList, null, 0, 0, true); final Modem modem = context.mock(Modem.class); context.checking(new Expectations() {{ oneOf(serialPortList).getPortNames(); @@ -71,7 +71,7 @@ public class ModemPluginTest extends BriarTestCase { final DuplexPluginCallback callback = context.mock(DuplexPluginCallback.class); final ModemPlugin plugin = new ModemPlugin(null, modemFactory, - serialPortList, callback, 0L, 0L, true); + serialPortList, callback, 0, 0, true); final Modem modem = context.mock(Modem.class); final TransportProperties local = new TransportProperties(); local.put("iso3166", ISO_1336); @@ -112,7 +112,7 @@ public class ModemPluginTest extends BriarTestCase { final DuplexPluginCallback callback = context.mock(DuplexPluginCallback.class); final ModemPlugin plugin = new ModemPlugin(null, modemFactory, - serialPortList, callback, 0L, 0L, true); + serialPortList, callback, 0, 0, true); final Modem modem = context.mock(Modem.class); final TransportProperties local = new TransportProperties(); local.put("iso3166", ISO_1336); @@ -153,7 +153,7 @@ public class ModemPluginTest extends BriarTestCase { final DuplexPluginCallback callback = context.mock(DuplexPluginCallback.class); final ModemPlugin plugin = new ModemPlugin(null, modemFactory, - serialPortList, callback, 0L, 0L, true); + serialPortList, callback, 0, 0, true); final Modem modem = context.mock(Modem.class); final TransportProperties local = new TransportProperties(); local.put("iso3166", ISO_1336); @@ -204,7 +204,7 @@ public class ModemPluginTest extends BriarTestCase { context.mock(DuplexPluginCallback.class); // Disable shuffling for this test, it confuses jMock final ModemPlugin plugin = new ModemPlugin(pluginExecutor, modemFactory, - serialPortList, callback, 0L, 0L, false); + serialPortList, callback, 0, 0, false); final Modem modem = context.mock(Modem.class); final TransportProperties local = new TransportProperties(); local.put("iso3166", ISO_1336); diff --git a/briar-tests/src/net/sf/briar/serial/ReaderImplTest.java b/briar-tests/src/net/sf/briar/serial/ReaderImplTest.java index dc7382d9c15d488fbd33427b0040dc68f7cbe3bf..2fff6c6cbe8476bf12e7515d1f3294934774ddee 100644 --- a/briar-tests/src/net/sf/briar/serial/ReaderImplTest.java +++ b/briar-tests/src/net/sf/briar/serial/ReaderImplTest.java @@ -62,8 +62,8 @@ public class ReaderImplTest extends BriarTestCase { public void testReadInt64() throws Exception { setContents("FA0000000000000000" + "FAFFFFFFFFFFFFFFFF" + "FA7FFFFFFFFFFFFFFF" + "FA8000000000000000"); - assertEquals(0L, r.readInt64()); - assertEquals(-1L, r.readInt64()); + assertEquals(0, r.readInt64()); + assertEquals(-1, r.readInt64()); assertEquals(Long.MAX_VALUE, r.readInt64()); assertEquals(Long.MIN_VALUE, r.readInt64()); assertTrue(r.eof()); @@ -73,14 +73,14 @@ public class ReaderImplTest extends BriarTestCase { public void testReadIntAny() throws Exception { setContents("00" + "7F" + "FD80" + "FDFF" + "FC0080" + "FC7FFF" + "FB00008000" + "FB7FFFFFFF" + "FA0000000080000000"); - assertEquals(0L, r.readIntAny()); - assertEquals(127L, r.readIntAny()); - assertEquals(-128L, r.readIntAny()); - assertEquals(-1L, r.readIntAny()); - assertEquals(128L, r.readIntAny()); - assertEquals(32767L, r.readIntAny()); - assertEquals(32768L, r.readIntAny()); - assertEquals(2147483647L, r.readIntAny()); + assertEquals(0, r.readIntAny()); + assertEquals(127, r.readIntAny()); + assertEquals(-128, r.readIntAny()); + assertEquals(-1, r.readIntAny()); + assertEquals(128, r.readIntAny()); + assertEquals(32767, r.readIntAny()); + assertEquals(32768, r.readIntAny()); + assertEquals(2147483647, r.readIntAny()); assertEquals(2147483648L, r.readIntAny()); assertTrue(r.eof()); } diff --git a/briar-tests/src/net/sf/briar/serial/WriterImplTest.java b/briar-tests/src/net/sf/briar/serial/WriterImplTest.java index 7c9112e9d0fedb68072371a369755f2120266654..ec3958baf5b4ca930d78e213c42dab159e8d51cc 100644 --- a/briar-tests/src/net/sf/briar/serial/WriterImplTest.java +++ b/briar-tests/src/net/sf/briar/serial/WriterImplTest.java @@ -75,8 +75,8 @@ public class WriterImplTest extends BriarTestCase { @Test public void testWriteInt64() throws IOException { - w.writeInt64(0L); - w.writeInt64(-1L); + w.writeInt64(0); + w.writeInt64(-1); w.writeInt64(Long.MIN_VALUE); w.writeInt64(Long.MAX_VALUE); // INT64 tag, 0, INT64 tag, -1, etc diff --git a/briar-tests/src/net/sf/briar/transport/IncomingEncryptionLayerTest.java b/briar-tests/src/net/sf/briar/transport/IncomingEncryptionLayerTest.java index 7638bea2c66a4edaa610855e5882439ccdee2057..65ed6844e0287a1549a3193809e4c1445bb9f17f 100644 --- a/briar-tests/src/net/sf/briar/transport/IncomingEncryptionLayerTest.java +++ b/briar-tests/src/net/sf/briar/transport/IncomingEncryptionLayerTest.java @@ -43,8 +43,8 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testReadValidFrames() throws Exception { // Generate two valid frames - byte[] frame = generateFrame(0L, FRAME_LENGTH, 123, false, false); - byte[] frame1 = generateFrame(1L, FRAME_LENGTH, 123, false, false); + byte[] frame = generateFrame(0, FRAME_LENGTH, 123, false, false); + byte[] frame1 = generateFrame(1, FRAME_LENGTH, 123, false, false); // Concatenate the frames byte[] valid = new byte[FRAME_LENGTH * 2]; System.arraycopy(frame, 0, valid, 0, FRAME_LENGTH); @@ -61,7 +61,7 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testTruncatedFrameThrowsException() throws Exception { // Generate a valid frame - byte[] frame = generateFrame(0L, FRAME_LENGTH, 123, false, false); + byte[] frame = generateFrame(0, FRAME_LENGTH, 123, false, false); // Chop off the last byte byte[] truncated = new byte[FRAME_LENGTH - 1]; System.arraycopy(frame, 0, truncated, 0, FRAME_LENGTH - 1); @@ -78,7 +78,7 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testModifiedFrameThrowsException() throws Exception { // Generate a valid frame - byte[] frame = generateFrame(0L, FRAME_LENGTH, 123, false, false); + byte[] frame = generateFrame(0, FRAME_LENGTH, 123, false, false); // Modify a randomly chosen byte of the frame frame[(int) (Math.random() * FRAME_LENGTH)] ^= 1; // Try to read the frame, which should fail due to modification @@ -94,7 +94,7 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testShortNonFinalFrameThrowsException() throws Exception { // Generate a short non-final frame - byte[] frame = generateFrame(0L, FRAME_LENGTH - 1, 123, false, false); + byte[] frame = generateFrame(0, FRAME_LENGTH - 1, 123, false, false); // Try to read the frame, which should fail due to invalid length ByteArrayInputStream in = new ByteArrayInputStream(frame); IncomingEncryptionLayer i = new IncomingEncryptionLayer(in, frameCipher, @@ -108,7 +108,7 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testShortFinalFrameDoesNotThrowException() throws Exception { // Generate a short final frame - byte[] frame = generateFrame(0L, FRAME_LENGTH - 1, 123, true, false); + byte[] frame = generateFrame(0, FRAME_LENGTH - 1, 123, true, false); // Read the frame ByteArrayInputStream in = new ByteArrayInputStream(frame); IncomingEncryptionLayer i = new IncomingEncryptionLayer(in, frameCipher, @@ -120,7 +120,7 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testInvalidPayloadLengthThrowsException() throws Exception { // Generate a frame with an invalid payload length - byte[] frame = generateFrame(0L, FRAME_LENGTH, MAX_PAYLOAD_LENGTH + 1, + byte[] frame = generateFrame(0, FRAME_LENGTH, MAX_PAYLOAD_LENGTH + 1, false, false); // Try to read the frame, which should fail due to invalid length ByteArrayInputStream in = new ByteArrayInputStream(frame); @@ -135,7 +135,7 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testNonZeroPaddingThrowsException() throws Exception { // Generate a frame with bad padding - byte[] frame = generateFrame(0L, FRAME_LENGTH, 123, false, true); + byte[] frame = generateFrame(0, FRAME_LENGTH, 123, false, true); // Try to read the frame, which should fail due to bad padding ByteArrayInputStream in = new ByteArrayInputStream(frame); IncomingEncryptionLayer i = new IncomingEncryptionLayer(in, frameCipher, @@ -149,9 +149,9 @@ public class IncomingEncryptionLayerTest extends BriarTestCase { @Test public void testCannotReadBeyondFinalFrame() throws Exception { // Generate a valid final frame and another valid final frame after it - byte[] frame = generateFrame(0L, FRAME_LENGTH, MAX_PAYLOAD_LENGTH, true, + byte[] frame = generateFrame(0, FRAME_LENGTH, MAX_PAYLOAD_LENGTH, true, false); - byte[] frame1 = generateFrame(1L, FRAME_LENGTH, 123, true, false); + byte[] frame1 = generateFrame(1, FRAME_LENGTH, 123, true, false); // Concatenate the frames byte[] extraFrame = new byte[FRAME_LENGTH * 2]; System.arraycopy(frame, 0, extraFrame, 0, FRAME_LENGTH); diff --git a/briar-tests/src/net/sf/briar/transport/TransportConnectionRecogniserTest.java b/briar-tests/src/net/sf/briar/transport/TransportConnectionRecogniserTest.java index c70831635287ab833f29c840d573de717ca336a3..31a8152e7abfad51abbe720f973209c1ca3d2acb 100644 --- a/briar-tests/src/net/sf/briar/transport/TransportConnectionRecogniserTest.java +++ b/briar-tests/src/net/sf/briar/transport/TransportConnectionRecogniserTest.java @@ -62,12 +62,12 @@ public class TransportConnectionRecogniserTest extends BriarTestCase { will(new EncodeTagAction()); oneOf(tagKey).erase(); }}); - TemporarySecret s = new TemporarySecret(contactId, transportId, 0L, - 0L, 0L, alice, 0L, secret, 0L, 0L, new byte[4]); + TemporarySecret s = new TemporarySecret(contactId, transportId, 0, 0, 0, + alice, 0, secret, 0, 0, new byte[4]); TransportConnectionRecogniser recogniser = new TransportConnectionRecogniser(crypto, db, transportId); recogniser.addSecret(s); - recogniser.removeSecret(contactId, 0L); + recogniser.removeSecret(contactId, 0); // The secret should have been erased assertArrayEquals(new byte[32], secret); context.assertIsSatisfied(); @@ -103,13 +103,13 @@ public class TransportConnectionRecogniserTest extends BriarTestCase { with(tagKey), with(16L)); will(new EncodeTagAction()); // The updated window should be stored - oneOf(db).setConnectionWindow(contactId, transportId, 0L, 1L, + oneOf(db).setConnectionWindow(contactId, transportId, 0, 1, new byte[] {0, 1, 0, 0}); oneOf(tagKey).erase(); // Accept connection again - no expectations }}); - TemporarySecret s = new TemporarySecret(contactId, transportId, 0L, - 0L, 0L, alice, 0L, secret, 0L, 0L, new byte[4]); + TemporarySecret s = new TemporarySecret(contactId, transportId, 0, 0, 0, + alice, 0, secret, 0, 0, new byte[4]); TransportConnectionRecogniser recogniser = new TransportConnectionRecogniser(crypto, db, transportId); recogniser.addSecret(s); @@ -120,7 +120,7 @@ public class TransportConnectionRecogniserTest extends BriarTestCase { assertEquals(contactId, ctx.getContactId()); assertEquals(transportId, ctx.getTransportId()); assertArrayEquals(secret, ctx.getSecret()); - assertEquals(0L, ctx.getConnectionNumber()); + assertEquals(0, ctx.getConnectionNumber()); assertEquals(alice, ctx.getAlice()); context.assertIsSatisfied(); } diff --git a/briar-tests/src/net/sf/briar/transport/TransportIntegrationTest.java b/briar-tests/src/net/sf/briar/transport/TransportIntegrationTest.java index 9780992164e9a59127af1d2cda5581765464bfd8..11eae9905a3efcb35a6bebcd60ca4624d21c7d18 100644 --- a/briar-tests/src/net/sf/briar/transport/TransportIntegrationTest.java +++ b/briar-tests/src/net/sf/briar/transport/TransportIntegrationTest.java @@ -61,7 +61,7 @@ public class TransportIntegrationTest extends BriarTestCase { // Since we're sending frames to ourselves, we only need outgoing keys secret = new byte[32]; random.nextBytes(secret); - frameKey = crypto.deriveFrameKey(secret, 0L, true, true); + frameKey = crypto.deriveFrameKey(secret, 0, true, true); } @Test @@ -127,7 +127,7 @@ public class TransportIntegrationTest extends BriarTestCase { ByteArrayOutputStream out = new ByteArrayOutputStream(MIN_CONNECTION_LENGTH); ConnectionContext ctx = new ConnectionContext(contactId, transportId, - secret, 0L, true); + secret, 0, true); ConnectionWriter w = connectionWriterFactory.createConnectionWriter(out, MIN_CONNECTION_LENGTH, ctx, false, true); // Check that the connection writer thinks there's room for a packet @@ -148,7 +148,7 @@ public class TransportIntegrationTest extends BriarTestCase { ByteArrayOutputStream out = new ByteArrayOutputStream(MIN_CONNECTION_LENGTH); ConnectionContext ctx = new ConnectionContext(contactId, transportId, - secret, 0L, true); + secret, 0, true); ConnectionWriter w = connectionWriterFactory.createConnectionWriter(out, MIN_CONNECTION_LENGTH, ctx, false, false); // Check that the connection writer thinks there's room for a packet diff --git a/briar-tests/src/net/sf/briar/util/ByteUtilsTest.java b/briar-tests/src/net/sf/briar/util/ByteUtilsTest.java index c672bc0e2af7e72bbcce2171f27a72952cbfa775..7020e020e81114735f16e9f7d6482788876ab22b 100644 --- a/briar-tests/src/net/sf/briar/util/ByteUtilsTest.java +++ b/briar-tests/src/net/sf/briar/util/ByteUtilsTest.java @@ -19,9 +19,9 @@ public class ByteUtilsTest extends BriarTestCase { @Test public void testReadUint32() { byte[] b = StringUtils.fromHexString("0000000000"); - assertEquals(0L, ByteUtils.readUint32(b, 1)); + assertEquals(0, ByteUtils.readUint32(b, 1)); b = StringUtils.fromHexString("0000000001"); - assertEquals(1L, ByteUtils.readUint32(b, 1)); + assertEquals(1, ByteUtils.readUint32(b, 1)); b = StringUtils.fromHexString("00FFFFFFFF"); assertEquals(4294967295L, ByteUtils.readUint32(b, 1)); } @@ -41,9 +41,9 @@ public class ByteUtilsTest extends BriarTestCase { @Test public void testWriteUint32() { byte[] b = new byte[5]; - ByteUtils.writeUint32(0L, b, 1); + ByteUtils.writeUint32(0, b, 1); assertEquals("0000000000", StringUtils.toHexString(b)); - ByteUtils.writeUint32(1L, b, 1); + ByteUtils.writeUint32(1, b, 1); assertEquals("0000000001", StringUtils.toHexString(b)); ByteUtils.writeUint32(4294967295L, b, 1); assertEquals("00FFFFFFFF", StringUtils.toHexString(b)); diff --git a/briar-tests/src/net/sf/briar/util/FileUtilsTest.java b/briar-tests/src/net/sf/briar/util/FileUtilsTest.java index 251d78a6e8aec8ce28c5779972237dac8832ab80..24f1ff894133f4a1a6a686c84e0d8aaa74496a4a 100644 --- a/briar-tests/src/net/sf/briar/util/FileUtilsTest.java +++ b/briar-tests/src/net/sf/briar/util/FileUtilsTest.java @@ -30,7 +30,7 @@ public class FileUtilsTest extends BriarTestCase { File temp = FileUtils.createTempFile(); assertTrue(temp.exists()); assertTrue(temp.isFile()); - assertEquals(0L, temp.length()); + assertEquals(0, temp.length()); temp.delete(); }