Type-safe transport IDs.

This commit is contained in:
akwizgran
2011-09-30 12:52:29 +01:00
parent 7190509ede
commit 72b594d270
32 changed files with 292 additions and 188 deletions

View File

@@ -11,6 +11,7 @@ import javax.crypto.spec.IvParameterSpec;
import junit.framework.TestCase;
import net.sf.briar.TestUtils;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.crypto.CryptoComponent;
import net.sf.briar.crypto.CryptoModule;
@@ -26,7 +27,7 @@ public class ConnectionDecrypterImplTest extends TestCase {
private final Cipher ivCipher, frameCipher;
private final SecretKey ivKey, frameKey;
private final int transportId = 1234;
private final TransportId transportId = new TransportId(123);
private final long connection = 12345L;
public ConnectionDecrypterImplTest() {

View File

@@ -10,6 +10,7 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import junit.framework.TestCase;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.crypto.CryptoComponent;
import net.sf.briar.crypto.CryptoModule;
@@ -24,7 +25,7 @@ public class ConnectionEncrypterImplTest extends TestCase {
private final Cipher ivCipher, frameCipher;
private final SecretKey ivKey, frameKey;
private final int transportId = 1234;
private final TransportId transportId = new TransportId(123);
private final long connection = 12345L;
public ConnectionEncrypterImplTest() {

View File

@@ -10,6 +10,7 @@ import javax.crypto.SecretKey;
import junit.framework.TestCase;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.crypto.CryptoComponent;
import net.sf.briar.api.db.DatabaseComponent;
import net.sf.briar.api.transport.ConnectionWindow;
@@ -27,7 +28,7 @@ public class ConnectionRecogniserImplTest extends TestCase {
private final CryptoComponent crypto;
private final ContactId contactId;
private final byte[] secret;
private final int transportId;
private final TransportId transportId;
private final ConnectionWindow connectionWindow;
public ConnectionRecogniserImplTest() {
@@ -36,7 +37,7 @@ public class ConnectionRecogniserImplTest extends TestCase {
crypto = i.getInstance(CryptoComponent.class);
contactId = new ContactId(1);
secret = new byte[18];
transportId = 123;
transportId = new TransportId(123);
connectionWindow = new ConnectionWindowImpl(0L, 0);
}

View File

@@ -7,6 +7,7 @@ import java.io.ByteArrayOutputStream;
import junit.framework.TestCase;
import net.sf.briar.TestDatabaseModule;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.transport.ConnectionWriter;
import net.sf.briar.api.transport.ConnectionWriterFactory;
import net.sf.briar.crypto.CryptoModule;
@@ -23,8 +24,8 @@ public class ConnectionWriterTest extends TestCase {
private final ConnectionWriterFactory connectionWriterFactory;
private final byte[] secret = new byte[100];
private final int transportId = 999;
private final long connection = 1234L;
private final TransportId transportId = new TransportId(123);
private final long connection = 12345L;
public ConnectionWriterTest() throws Exception {
super();

View File

@@ -14,6 +14,7 @@ import javax.crypto.Mac;
import javax.crypto.SecretKey;
import junit.framework.TestCase;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.crypto.CryptoComponent;
import net.sf.briar.api.transport.ConnectionReader;
import net.sf.briar.api.transport.ConnectionWriter;
@@ -32,8 +33,8 @@ public class FrameReadWriteTest extends TestCase {
private final Mac mac;
private final Random random;
private final byte[] secret = new byte[100];
private final int transportId = 999;
private final long connection = 1234L;
private final TransportId transportId = new TransportId(123);
private final long connection = 12345L;
public FrameReadWriteTest() {
super();

View File

@@ -12,6 +12,7 @@ import junit.framework.TestCase;
import net.sf.briar.TestDatabaseModule;
import net.sf.briar.TestUtils;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.db.DatabaseComponent;
import net.sf.briar.api.db.DatabaseListener;
import net.sf.briar.api.protocol.Message;
@@ -43,10 +44,10 @@ public class BatchConnectionReadWriteTest extends TestCase {
private final File testDir = TestUtils.getTestDirectory();
private final File aliceDir = new File(testDir, "alice");
private final File bobDir = new File(testDir, "bob");
private final Map<Integer, Map<String, String>> transports =
private final TransportId transportId = new TransportId(123);
private final Map<TransportId, Map<String, String>> transports =
Collections.emptyMap();
private final byte[] aliceSecret, bobSecret;
private final int transportId = 123;
private Injector alice, bob;