mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Code cleanup, complain about lack of unit tests.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'/>
|
||||
|
||||
@@ -108,7 +108,7 @@ public class LockFairnessTest extends BriarTestCase {
|
||||
}
|
||||
};
|
||||
first.start();
|
||||
// BdfWriter
|
||||
// Writer
|
||||
Thread writer = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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]);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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() {{
|
||||
|
||||
Reference in New Issue
Block a user