diff --git a/briar-core/src/org/briarproject/data/MetadataParserImpl.java b/briar-core/src/org/briarproject/data/MetadataParserImpl.java index ff9258f14934d0d92328a53b2f422ec922dd9c99..e4624dc6037881562a6ea7dff91a0c12ad9e076d 100644 --- a/briar-core/src/org/briarproject/data/MetadataParserImpl.java +++ b/briar-core/src/org/briarproject/data/MetadataParserImpl.java @@ -10,6 +10,7 @@ import org.briarproject.util.StringUtils; import java.io.ByteArrayInputStream; import java.util.Map.Entry; +import static org.briarproject.api.db.Metadata.REMOVE; import static org.briarproject.data.Types.DICTIONARY; import static org.briarproject.data.Types.END; import static org.briarproject.data.Types.FALSE; @@ -39,7 +40,7 @@ class MetadataParserImpl implements MetadataParser { } private Object parseObject(byte[] b) throws FormatException { - if (b == null) return null; + if (b == REMOVE) return null; ByteArrayInputStream in = new ByteArrayInputStream(b); Object o = parseObject(in); if (in.available() > 0) throw new FormatException(); diff --git a/briar-core/src/org/briarproject/invitation/AliceConnector.java b/briar-core/src/org/briarproject/invitation/AliceConnector.java index c282dff575fd7cca98331e7827c1ff0687efbf76..794f542ec7eaa2df0ac52448ff9a668d41aeeb16 100644 --- a/briar-core/src/org/briarproject/invitation/AliceConnector.java +++ b/briar-core/src/org/briarproject/invitation/AliceConnector.java @@ -42,7 +42,8 @@ class AliceConnector extends Connector { Logger.getLogger(AliceConnector.class.getName()); AliceConnector(CryptoComponent crypto, - BdfReaderFactory bdfReaderFactory, BdfWriterFactory bdfWriterFactory, + BdfReaderFactory bdfReaderFactory, + BdfWriterFactory bdfWriterFactory, StreamReaderFactory streamReaderFactory, StreamWriterFactory streamWriterFactory, AuthorFactory authorFactory, GroupFactory groupFactory, diff --git a/briar-core/src/org/briarproject/invitation/BobConnector.java b/briar-core/src/org/briarproject/invitation/BobConnector.java index 55bb7da882da2af7b11fb6d3c736cc120827f422..270ecfbf197f06f4a546ba6185efe7cb18d137da 100644 --- a/briar-core/src/org/briarproject/invitation/BobConnector.java +++ b/briar-core/src/org/briarproject/invitation/BobConnector.java @@ -42,7 +42,8 @@ class BobConnector extends Connector { Logger.getLogger(BobConnector.class.getName()); BobConnector(CryptoComponent crypto, - BdfReaderFactory bdfReaderFactory, BdfWriterFactory bdfWriterFactory, + BdfReaderFactory bdfReaderFactory, + BdfWriterFactory bdfWriterFactory, StreamReaderFactory streamReaderFactory, StreamWriterFactory streamWriterFactory, AuthorFactory authorFactory, GroupFactory groupFactory, diff --git a/briar-core/src/org/briarproject/invitation/Connector.java b/briar-core/src/org/briarproject/invitation/Connector.java index ae1af77f366ccf7e268664de8d493faee64204e1..bd2d8a32545b5e57cb6437953cc9013fbe4e86ce 100644 --- a/briar-core/src/org/briarproject/invitation/Connector.java +++ b/briar-core/src/org/briarproject/invitation/Connector.java @@ -83,7 +83,8 @@ abstract class Connector extends Thread { private volatile ContactId contactId = null; Connector(CryptoComponent crypto, - BdfReaderFactory bdfReaderFactory, BdfWriterFactory bdfWriterFactory, + BdfReaderFactory bdfReaderFactory, + BdfWriterFactory bdfWriterFactory, StreamReaderFactory streamReaderFactory, StreamWriterFactory streamWriterFactory, AuthorFactory authorFactory, GroupFactory groupFactory, @@ -147,8 +148,8 @@ abstract class Connector extends Thread { if (LOG.isLoggable(INFO)) LOG.info(pluginName + " sent key"); } - protected byte[] receivePublicKey(BdfReader r) throws GeneralSecurityException, - IOException { + protected byte[] receivePublicKey(BdfReader r) + throws GeneralSecurityException, IOException { byte[] b = r.readRaw(MAX_PUBLIC_KEY_LENGTH); keyParser.parsePublicKey(b); if (LOG.isLoggable(INFO)) LOG.info(pluginName + " received key"); @@ -221,7 +222,8 @@ abstract class Connector extends Thread { return authorFactory.createAuthor(name, publicKey); } - protected void sendTimestamp(BdfWriter w, long timestamp) throws IOException { + protected void sendTimestamp(BdfWriter w, long timestamp) + throws IOException { w.writeInteger(timestamp); w.flush(); if (LOG.isLoggable(INFO)) LOG.info(pluginName + " sent timestamp"); @@ -236,7 +238,8 @@ abstract class Connector extends Thread { protected void sendTransportProperties(BdfWriter w) throws IOException { w.writeListStart(); - for (Entry<TransportId, TransportProperties> e : localProps.entrySet()) { + for (Entry<TransportId, TransportProperties> e : + localProps.entrySet()) { w.writeString(e.getKey().getString()); w.writeDictionary(e.getValue()); } diff --git a/briar-core/src/org/briarproject/invitation/ConnectorGroup.java b/briar-core/src/org/briarproject/invitation/ConnectorGroup.java index 863c24ed74145f3dcdc422c41c9f2009db079c78..378fc54a5b421dc01b62c6119f897cb6f698a4c8 100644 --- a/briar-core/src/org/briarproject/invitation/ConnectorGroup.java +++ b/briar-core/src/org/briarproject/invitation/ConnectorGroup.java @@ -78,7 +78,8 @@ class ConnectorGroup extends Thread implements InvitationTask { private String remoteName = null; ConnectorGroup(CryptoComponent crypto, - BdfReaderFactory bdfReaderFactory, BdfWriterFactory bdfWriterFactory, + BdfReaderFactory bdfReaderFactory, + BdfWriterFactory bdfWriterFactory, StreamReaderFactory streamReaderFactory, StreamWriterFactory streamWriterFactory, AuthorFactory authorFactory, GroupFactory groupFactory, diff --git a/briar-tests/build.xml b/briar-tests/build.xml index bf96f04c59816fd626ad52163d56d8a6d832ee7b..29cc7dce912093911fd26be55c73180ad9981ca2 100644 --- a/briar-tests/build.xml +++ b/briar-tests/build.xml @@ -107,6 +107,8 @@ <test name='org.briarproject.crypto.XSalsa20Poly1305AuthenticatedCipherTest'/> <test name='org.briarproject.data.BdfReaderImplTest'/> <test name='org.briarproject.data.BdfWriterImplTest'/> + <test name='org.briarproject.data.MetadataEncoderImplTest'/> + <test name='org.briarproject.data.MetadataParserImplTest'/> <test name='org.briarproject.db.BasicH2Test'/> <test name='org.briarproject.db.DatabaseComponentImplTest'/> <test name='org.briarproject.db.ExponentialBackoffTest'/> diff --git a/briar-tests/src/org/briarproject/LockFairnessTest.java b/briar-tests/src/org/briarproject/LockFairnessTest.java index d8edd213e2e0b19550a270ffd45b8c86f7c098f3..7daaf557e08b15ed9cb8b822528d113a93596d31 100644 --- a/briar-tests/src/org/briarproject/LockFairnessTest.java +++ b/briar-tests/src/org/briarproject/LockFairnessTest.java @@ -108,7 +108,7 @@ public class LockFairnessTest extends BriarTestCase { } }; first.start(); - // BdfWriter + // Writer Thread writer = new Thread() { @Override public void run() { diff --git a/briar-tests/src/org/briarproject/data/MetadataEncoderImplTest.java b/briar-tests/src/org/briarproject/data/MetadataEncoderImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c0ab879def193ba9de00e83b6e758ef65b64c34d --- /dev/null +++ b/briar-tests/src/org/briarproject/data/MetadataEncoderImplTest.java @@ -0,0 +1,14 @@ +package org.briarproject.data; + +import org.briarproject.BriarTestCase; +import org.junit.Test; + +import static org.junit.Assert.fail; + +public class MetadataEncoderImplTest extends BriarTestCase { + + @Test + public void testUnitTestsExist() { + fail(); // FIXME: Write tests + } +} diff --git a/briar-tests/src/org/briarproject/data/MetadataParserImplTest.java b/briar-tests/src/org/briarproject/data/MetadataParserImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5e3518fb509cc41e266048c9eef7356a29cccd61 --- /dev/null +++ b/briar-tests/src/org/briarproject/data/MetadataParserImplTest.java @@ -0,0 +1,14 @@ +package org.briarproject.data; + +import org.briarproject.BriarTestCase; +import org.junit.Test; + +import static org.junit.Assert.fail; + +public class MetadataParserImplTest extends BriarTestCase { + + @Test + public void testUnitTestsExist() { + fail(); // FIXME: Write tests + } +} diff --git a/briar-tests/src/org/briarproject/sync/ConsumersTest.java b/briar-tests/src/org/briarproject/sync/ConsumersTest.java index a9d4ed67ba770354205ce4a22b1ef677de7a6fb3..f8e3bfe4d7af8d219f18edd0827e1e5592dd93fe 100644 --- a/briar-tests/src/org/briarproject/sync/ConsumersTest.java +++ b/briar-tests/src/org/briarproject/sync/ConsumersTest.java @@ -23,8 +23,7 @@ public class ConsumersTest extends BriarTestCase { messageDigest.update(data); byte[] dig = messageDigest.digest(); // Check that feeding a DigestingConsumer generates the same digest - org.briarproject.sync.DigestingConsumer - dc = new org.briarproject.sync.DigestingConsumer(messageDigest); + DigestingConsumer dc = new DigestingConsumer(messageDigest); dc.write(data[0]); dc.write(data, 1, data.length - 2); dc.write(data[data.length - 1]); @@ -35,8 +34,7 @@ public class ConsumersTest extends BriarTestCase { @Test public void testCountingConsumer() throws Exception { byte[] data = new byte[1234]; - org.briarproject.sync.CountingConsumer - cc = new org.briarproject.sync.CountingConsumer(data.length); + CountingConsumer cc = new CountingConsumer(data.length); cc.write(data[0]); cc.write(data, 1, data.length - 2); cc.write(data[data.length - 1]); @@ -54,8 +52,7 @@ public class ConsumersTest extends BriarTestCase { byte[] data = new byte[1234]; new Random().nextBytes(data); // Check that a CopyingConsumer creates a faithful copy - org.briarproject.sync.CopyingConsumer - cc = new org.briarproject.sync.CopyingConsumer(); + CopyingConsumer cc = new CopyingConsumer(); cc.write(data[0]); cc.write(data, 1, data.length - 2); cc.write(data[data.length - 1]); diff --git a/briar-tests/src/org/briarproject/sync/PacketReaderImplTest.java b/briar-tests/src/org/briarproject/sync/PacketReaderImplTest.java index ac38110834a6ccd75423ff906f7ede62841661cd..314bf4bd3b625eda2671eb317c3f8947bb298461 100644 --- a/briar-tests/src/org/briarproject/sync/PacketReaderImplTest.java +++ b/briar-tests/src/org/briarproject/sync/PacketReaderImplTest.java @@ -43,9 +43,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testFormatExceptionIfAckIsTooLarge() throws Exception { byte[] b = createAck(true); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); try { reader.readAck(); @@ -59,9 +57,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testNoFormatExceptionIfAckIsMaximumSize() throws Exception { byte[] b = createAck(false); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); reader.readAck(); } @@ -70,9 +66,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testEmptyAck() throws Exception { byte[] b = createEmptyAck(); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); try { reader.readAck(); @@ -86,9 +80,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testFormatExceptionIfOfferIsTooLarge() throws Exception { byte[] b = createOffer(true); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); try { reader.readOffer(); @@ -102,8 +94,8 @@ public class PacketReaderImplTest extends BriarTestCase { public void testNoFormatExceptionIfOfferIsMaximumSize() throws Exception { byte[] b = createOffer(false); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( + PacketReaderImpl + reader = new PacketReaderImpl( bdfReaderFactory, null, null, in); reader.readOffer(); @@ -113,9 +105,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testEmptyOffer() throws Exception { byte[] b = createEmptyOffer(); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); try { reader.readOffer(); @@ -129,9 +119,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testFormatExceptionIfRequestIsTooLarge() throws Exception { byte[] b = createRequest(true); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); try { reader.readRequest(); @@ -145,9 +133,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testNoFormatExceptionIfRequestIsMaximumSize() throws Exception { byte[] b = createRequest(false); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); reader.readRequest(); } @@ -156,9 +142,7 @@ public class PacketReaderImplTest extends BriarTestCase { public void testEmptyRequest() throws Exception { byte[] b = createEmptyRequest(); ByteArrayInputStream in = new ByteArrayInputStream(b); - org.briarproject.sync.PacketReaderImpl - reader = new org.briarproject.sync.PacketReaderImpl( - bdfReaderFactory, null, + PacketReaderImpl reader = new PacketReaderImpl(bdfReaderFactory, null, null, in); try { reader.readRequest(); diff --git a/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java b/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java index 1848bad7fcc1d9b7f32ee4516c05f8bdcfa98b0d..3cffb9feb6d3464170fe07b265c4be4b828c1d49 100644 --- a/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java +++ b/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java @@ -46,8 +46,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase { @Test public void testNothingToSend() throws Exception { - final org.briarproject.sync.SimplexOutgoingSession - session = new org.briarproject.sync.SimplexOutgoingSession(db, + final SimplexOutgoingSession session = new SimplexOutgoingSession(db, dbExecutor, eventBus, contactId, transportId, maxLatency, packetWriter); context.checking(new Expectations() {{ @@ -87,8 +86,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase { public void testSomethingToSend() throws Exception { final Ack ack = new Ack(Collections.singletonList(messageId)); final byte[] raw = new byte[1234]; - final org.briarproject.sync.SimplexOutgoingSession - session = new org.briarproject.sync.SimplexOutgoingSession(db, + final SimplexOutgoingSession session = new SimplexOutgoingSession(db, dbExecutor, eventBus, contactId, transportId, maxLatency, packetWriter); context.checking(new Expectations() {{