Code cleanup, complain about lack of unit tests.

This commit is contained in:
akwizgran
2016-01-05 11:32:24 +00:00
parent ed23bd6c11
commit a847b30ed3
12 changed files with 62 additions and 46 deletions

View File

@@ -108,7 +108,7 @@ public class LockFairnessTest extends BriarTestCase {
}
};
first.start();
// BdfWriter
// Writer
Thread writer = new Thread() {
@Override
public void run() {

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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]);

View File

@@ -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();

View File

@@ -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() {{