Connection readers and writers don't need the connection context.

This commit is contained in:
akwizgran
2011-12-02 14:23:45 +00:00
parent 51d58fadad
commit c8338f9866
10 changed files with 35 additions and 64 deletions

View File

@@ -10,10 +10,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import junit.framework.TestCase;
import net.sf.briar.TestDatabaseModule;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.protocol.TransportIndex;
import net.sf.briar.api.transport.ConnectionContext;
import net.sf.briar.api.transport.ConnectionContextFactory;
import net.sf.briar.api.transport.ConnectionWriter;
import net.sf.briar.api.transport.ConnectionWriterFactory;
import net.sf.briar.crypto.CryptoModule;
@@ -34,12 +30,8 @@ import com.google.inject.Module;
public class ConnectionWriterTest extends TestCase {
private final ConnectionContextFactory connectionContextFactory;
private final ConnectionWriterFactory connectionWriterFactory;
private final byte[] secret;
private final ContactId contactId = new ContactId(13);
private final TransportIndex transportIndex = new TransportIndex(13);
private final long connection = 12345L;
public ConnectionWriterTest() throws Exception {
super();
@@ -56,8 +48,6 @@ public class ConnectionWriterTest extends TestCase {
new SerialModule(), new TestDatabaseModule(),
new TransportBatchModule(), new TransportModule(),
new TransportStreamModule());
connectionContextFactory =
i.getInstance(ConnectionContextFactory.class);
connectionWriterFactory = i.getInstance(ConnectionWriterFactory.class);
secret = new byte[32];
new Random().nextBytes(secret);
@@ -67,11 +57,8 @@ public class ConnectionWriterTest extends TestCase {
public void testOverhead() throws Exception {
ByteArrayOutputStream out =
new ByteArrayOutputStream(MIN_CONNECTION_LENGTH);
ConnectionContext ctx =
connectionContextFactory.createConnectionContext(contactId,
transportIndex, connection, secret);
ConnectionWriter w = connectionWriterFactory.createConnectionWriter(out,
MIN_CONNECTION_LENGTH, ctx);
MIN_CONNECTION_LENGTH, secret);
// Check that the connection writer thinks there's room for a packet
long capacity = w.getRemainingCapacity();
assertTrue(capacity >= MAX_PACKET_LENGTH);