Move all unit tests to their modules and remove briar-tests

This commit is contained in:
Torsten Grote
2016-12-12 17:06:30 -02:00
parent 32be148c7a
commit 1081a08ea9
130 changed files with 441 additions and 433 deletions

View File

@@ -5,18 +5,37 @@ targetCompatibility = 1.6
apply plugin: 'witness'
dependencies {
compile "com.google.dagger:dagger:2.0.2"
compile 'com.google.dagger:dagger-compiler:2.0.2'
compile "com.google.dagger:dagger:2.8"
compile 'com.google.dagger:dagger-compiler:2.8'
compile 'com.google.code.findbugs:jsr305:3.0.1'
testCompile 'junit:junit:4.12'
testCompile "org.jmock:jmock:2.8.1"
testCompile "org.jmock:jmock-junit4:2.8.1"
testCompile "org.jmock:jmock-legacy:2.8.1"
testCompile "org.hamcrest:hamcrest-library:1.3"
testCompile "org.hamcrest:hamcrest-core:1.3"
}
dependencyVerification {
verify = [
'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9',
'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3',
'com.google.dagger:dagger:5070e1dff5c551a4908ba7b93125c0243de2a688aed3d2f475357d86d9d7c0ad',
'com.google.dagger:dagger-compiler:7b2686f94907868c5364e9965601ffe2f020ba4af1849ad9b57dad5fe3fa6242',
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd',
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
'com.google.dagger:dagger-producers:99ec15e8a0507ba569e7655bc1165ee5e5ca5aa914b3c8f7e2c2458f724edd6b',
'com.google.guava:guava:d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99',
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd'
'com.google.dagger:dagger-producers:1e4043e85f67de381d19e22c7932aaf7ff1611091be7e1aaae93f2c37f331cf2',
'com.google.guava:guava:ff89d4a4a6b303c4084194975a5a35f55a8af6f7337678b4cc8ddbea9005c323',
]
}
// needed to make test output available to bramble-core and briar-core
configurations {
testOutput.extendsFrom(testCompile)
}
task jarTest (type: Jar, dependsOn: testClasses) {
from sourceSets.test.output
classifier = 'test'
}
artifacts {
testOutput jarTest
}

View File

@@ -1,9 +1,10 @@
package org.briarproject;
package org.briarproject.bramble;
import org.jmock.Mockery;
import org.junit.After;
public abstract class BriarMockTestCase extends BriarTestCase {
public abstract class BrambleMockTestCase extends
BrambleTestCase {
protected final Mockery context = new Mockery();

View File

@@ -1,12 +1,12 @@
package org.briarproject;
package org.briarproject.bramble;
import java.lang.Thread.UncaughtExceptionHandler;
import static org.junit.Assert.fail;
public abstract class BriarTestCase {
public abstract class BrambleTestCase {
public BriarTestCase() {
public BrambleTestCase() {
// Ensure exceptions thrown on worker threads cause tests to fail
UncaughtExceptionHandler fail = new UncaughtExceptionHandler() {
@Override

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.bramble;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.bramble;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DatabaseConfig;

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.bramble;
import org.briarproject.bramble.api.db.DatabaseConfig;
import org.briarproject.bramble.api.db.DatabaseExecutor;

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.bramble;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.system.SeedProvider;

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.bramble;
import org.briarproject.bramble.api.system.SeedProvider;

View File

@@ -1,19 +1,13 @@
package org.briarproject;
package org.briarproject.bramble;
import org.briarproject.bramble.api.UniqueId;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.bramble.util.IoUtils;
import org.briarproject.briar.api.client.MessageTracker;
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
import java.io.File;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertEquals;
public class TestUtils {
private static final AtomicInteger nextTestDir =
@@ -51,19 +45,4 @@ public class TestUtils {
return new SecretKey(getRandomBytes(SecretKey.LENGTH));
}
public static void assertGroupCount(MessageTracker tracker, GroupId g,
long msgCount, long unreadCount, long latestMsgTime)
throws DbException {
GroupCount groupCount = tracker.getGroupCount(g);
assertEquals(msgCount, groupCount.getMsgCount());
assertEquals(unreadCount, groupCount.getUnreadCount());
assertEquals(latestMsgTime, groupCount.getLatestMsgTime());
}
public static void assertGroupCount(MessageTracker tracker, GroupId g,
long msgCount, long unreadCount) throws DbException {
GroupCount c1 = tracker.getGroupCount(g);
assertEquals(msgCount, c1.getMsgCount());
assertEquals(unreadCount, c1.getUnreadCount());
}
}

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.bramble;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.data.MetadataEncoder;
@@ -10,7 +10,7 @@ import org.briarproject.bramble.api.sync.Message;
import org.briarproject.bramble.api.sync.MessageId;
import org.briarproject.bramble.api.system.Clock;
public abstract class ValidatorTestCase extends BriarMockTestCase {
public abstract class ValidatorTestCase extends BrambleMockTestCase {
protected final ClientHelper clientHelper =
context.mock(ClientHelper.class);

View File

@@ -1,9 +1,7 @@
package org.briarproject.bramble.data;
package org.briarproject.bramble.api.data;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.Bytes;
import org.briarproject.bramble.api.data.BdfDictionary;
import org.briarproject.bramble.api.data.BdfEntry;
import org.junit.Test;
import java.util.Collections;
@@ -15,7 +13,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class BdfDictionaryTest extends BriarTestCase {
public class BdfDictionaryTest extends BrambleTestCase {
@Test
public void testConstructors() {

View File

@@ -1,11 +1,8 @@
package org.briarproject.bramble.data;
package org.briarproject.bramble.api.data;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.Bytes;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.data.BdfDictionary;
import org.briarproject.bramble.api.data.BdfEntry;
import org.briarproject.bramble.api.data.BdfList;
import org.junit.Test;
import java.util.Arrays;
@@ -15,7 +12,7 @@ import static org.briarproject.bramble.api.data.BdfDictionary.NULL_VALUE;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class BdfListTest extends BriarTestCase {
public class BdfListTest extends BrambleTestCase {
@Test
public void testConstructors() {

View File

@@ -1,3 +1,4 @@
bin
build
test.tmp
.settings

View File

@@ -14,10 +14,7 @@ dependencies {
compile 'com.madgag.spongycastle:core:1.54.0.0'
compile 'com.h2database:h2:1.4.190'
testCompile project(':briar-tests') // TODO remove when moving unit tests (#778)
testCompile 'junit:junit:4.12'
testCompile 'com.google.dagger:dagger-compiler:2.8'
testApt 'com.google.dagger:dagger-compiler:2.8'
testCompile project(path: ':bramble-api', configuration: 'testOutput')
}
dependencyVerification {
@@ -26,3 +23,15 @@ dependencyVerification {
'com.h2database:h2:23ba495a07bbbb3bd6c3084d10a96dad7a23741b8b6d64b213459a784195a98c'
]
}
// needed to make test output available to bramble-j2se
configurations {
testOutput.extendsFrom(testCompile)
}
task jarTest (type: Jar, dependsOn: testClasses) {
from sourceSets.test.output
classifier = 'test'
}
artifacts {
testOutput jarTest
}

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.bramble;
import org.hamcrest.Description;
import org.jmock.api.Action;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.client;
import org.briarproject.ValidatorTestCase;
import org.briarproject.bramble.ValidatorTestCase;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.client.BdfMessageContext;
import org.briarproject.bramble.api.client.BdfMessageValidator;

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.client;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.crypto.CryptoComponent;
@@ -32,13 +32,13 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static org.briarproject.TestUtils.getRandomBytes;
import static org.briarproject.TestUtils.getRandomId;
import static org.briarproject.bramble.TestUtils.getRandomBytes;
import static org.briarproject.bramble.TestUtils.getRandomId;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class ClientHelperImplTest extends BriarTestCase {
public class ClientHelperImplTest extends BrambleTestCase {
private final Mockery context = new Mockery();
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
@@ -165,7 +165,8 @@ public class ClientHelperImplTest extends BriarTestCase {
@Test
public void testGetMessageMetadataAsDictionaryMap() throws Exception {
final Map<MessageId, BdfDictionary> map = new HashMap<>();
final Map<MessageId, BdfDictionary> map =
new HashMap<MessageId, BdfDictionary>();
map.put(messageId, dictionary);
final Transaction txn = new Transaction(null, true);
@@ -187,7 +188,8 @@ public class ClientHelperImplTest extends BriarTestCase {
@Test
public void testGetMessageMetadataAsDictionaryQuery() throws Exception {
final Map<MessageId, BdfDictionary> map = new HashMap<>();
final Map<MessageId, BdfDictionary> map =
new HashMap<MessageId, BdfDictionary>();
map.put(messageId, dictionary);
final BdfDictionary query =
BdfDictionary.of(new BdfEntry("query", "me"));

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.contact;
import org.briarproject.BriarMockTestCase;
import org.briarproject.bramble.BrambleMockTestCase;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.contact.ContactManager;
@@ -19,13 +19,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import static org.briarproject.TestUtils.getRandomBytes;
import static org.briarproject.TestUtils.getRandomId;
import static org.briarproject.TestUtils.getSecretKey;
import static org.briarproject.bramble.TestUtils.getRandomBytes;
import static org.briarproject.bramble.TestUtils.getRandomId;
import static org.briarproject.bramble.TestUtils.getSecretKey;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ContactManagerImplTest extends BriarMockTestCase {
public class ContactManagerImplTest extends BrambleMockTestCase {
private final Mockery context = new Mockery();
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
@@ -132,7 +132,8 @@ public class ContactManagerImplTest extends BriarMockTestCase {
@Test
public void testActiveContacts() throws Exception {
Collection<Contact> activeContacts = Collections.singletonList(contact);
final Collection<Contact> contacts = new ArrayList<>(activeContacts);
final Collection<Contact> contacts =
new ArrayList<Contact>(activeContacts);
contacts.add(new Contact(new ContactId(3), remote, local, true, false));
final Transaction txn = new Transaction(null, true);
context.checking(new Expectations() {{

View File

@@ -1,12 +1,12 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class AsciiArmourTest extends BriarTestCase {
public class AsciiArmourTest extends BrambleTestCase {
@Test
public void testWrapOnSingleLine() {

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.util.StringUtils;
import org.junit.Test;
@@ -8,7 +8,7 @@ import java.util.Random;
import static org.junit.Assert.assertArrayEquals;
public class Blake2sDigestTest extends BriarTestCase {
public class Blake2sDigestTest extends BrambleTestCase {
// Vectors from BLAKE2 web site: https://blake2.net/blake2s-test.txt
private static final String[][] keyedTestVectors = {

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import org.spongycastle.asn1.teletrust.TeleTrusTNamedCurves;
import org.spongycastle.asn1.x9.X9ECParameters;
@@ -20,7 +20,7 @@ import java.security.SecureRandom;
import static org.briarproject.bramble.crypto.EllipticCurveConstants.PARAMETERS;
import static org.junit.Assert.assertEquals;
public class EllipticCurveMultiplicationTest extends BriarTestCase {
public class EllipticCurveMultiplicationTest extends BrambleTestCase {
@Test
public void testMultiplierProducesSameResultsAsDefault() throws Exception {

View File

@@ -69,7 +69,7 @@ public class EllipticCurvePerformanceTest {
ECPublicKeyParameters public2 =
(ECPublicKeyParameters) keyPair2.getPublic();
// Time some ECDH key agreements
List<Long> samples = new ArrayList<>();
List<Long> samples = new ArrayList<Long>();
for (int i = 0; i < SAMPLES; i++) {
ECDHCBasicAgreement agreement = new ECDHCBasicAgreement();
long start = System.nanoTime();
@@ -79,7 +79,7 @@ public class EllipticCurvePerformanceTest {
}
long agreementMedian = median(samples);
// Time some signatures
List<byte[]> signatures = new ArrayList<>();
List<byte[]> signatures = new ArrayList<byte[]>();
samples.clear();
for (int i = 0; i < SAMPLES; i++) {
Digest digest = new Blake2sDigest();

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import org.spongycastle.crypto.BlockCipher;
import org.spongycastle.crypto.engines.AESLightEngine;
@@ -9,7 +9,7 @@ import org.spongycastle.crypto.params.KeyParameter;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class FortunaGeneratorTest extends BriarTestCase {
public class FortunaGeneratorTest extends BrambleTestCase {
@Test
public void testCounterInitialisedToOne() {

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import org.spongycastle.crypto.BlockCipher;
import org.spongycastle.crypto.digests.SHA256Digest;
@@ -13,7 +13,7 @@ import static org.briarproject.bramble.crypto.FortunaSecureRandom.SELF_TEST_VECT
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertTrue;
public class FortunaSecureRandomTest extends BriarTestCase {
public class FortunaSecureRandomTest extends BrambleTestCase {
@Test
public void testClassPassesSelfTest() {

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestSeedProvider;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestSeedProvider;
import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.KeyPair;
import org.briarproject.bramble.api.crypto.SecretKey;
@@ -10,7 +10,7 @@ import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class KeyAgreementTest extends BriarTestCase {
public class KeyAgreementTest extends BrambleTestCase {
@Test
public void testDeriveMasterSecret() throws Exception {

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestSeedProvider;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestSeedProvider;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.plugin.TransportId;
@@ -16,7 +16,7 @@ import java.util.List;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
public class KeyDerivationTest extends BriarTestCase {
public class KeyDerivationTest extends BrambleTestCase {
private final TransportId transportId = new TransportId("id");
private final CryptoComponent crypto;
@@ -141,7 +141,7 @@ public class KeyDerivationTest extends BriarTestCase {
}
private void assertAllDifferent(TransportKeys... transportKeys) {
List<SecretKey> secretKeys = new ArrayList<>();
List<SecretKey> secretKeys = new ArrayList<SecretKey>();
for (TransportKeys k : transportKeys) {
secretKeys.add(k.getPreviousIncomingKeys().getTagKey());
secretKeys.add(k.getPreviousIncomingKeys().getHeaderKey());

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestSeedProvider;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestSeedProvider;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.KeyPair;
import org.briarproject.bramble.api.crypto.KeyParser;
import org.briarproject.bramble.api.crypto.PrivateKey;
@@ -16,7 +16,7 @@ import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_SIGNATUR
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertTrue;
public class KeyEncodingAndParsingTest extends BriarTestCase {
public class KeyEncodingAndParsingTest extends BrambleTestCase {
private final CryptoComponentImpl crypto =
new CryptoComponentImpl(new TestSeedProvider());

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestSeedProvider;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestSeedProvider;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.junit.Test;
@@ -12,7 +12,7 @@ import java.util.Arrays;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
public class MacTest extends BriarTestCase {
public class MacTest extends BrambleTestCase {
private final CryptoComponent crypto;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.crypto.KeyPair;
import org.briarproject.bramble.api.crypto.PrivateKey;
import org.briarproject.bramble.api.crypto.PublicKey;
@@ -11,7 +11,7 @@ import java.security.SecureRandom;
import static org.junit.Assert.assertArrayEquals;
public class MessageEncrypterTest extends BriarTestCase {
public class MessageEncrypterTest extends BrambleTestCase {
private final SecureRandom random = new SecureRandom();

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestSeedProvider;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestSeedProvider;
import org.briarproject.bramble.TestUtils;
import org.junit.Test;
import java.util.Random;
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class PasswordBasedKdfTest extends BriarTestCase {
public class PasswordBasedKdfTest extends BrambleTestCase {
private final CryptoComponentImpl crypto =
new CryptoComponentImpl(new TestSeedProvider());

View File

@@ -1,13 +1,13 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
import org.junit.Test;
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
import static org.junit.Assert.assertTrue;
public class PasswordStrengthEstimatorImplTest extends BriarTestCase {
public class PasswordStrengthEstimatorImplTest extends BrambleTestCase {
@Test
public void testWeakPasswords() {

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestSeedProvider;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestSeedProvider;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.KeyPair;
import org.junit.Test;
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class SignatureTest extends BriarTestCase {
public class SignatureTest extends BrambleTestCase {
private final CryptoComponent crypto;

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.util.ByteUtils;
import org.junit.Test;
@@ -18,7 +18,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.STREAM_H
import static org.briarproject.bramble.util.ByteUtils.INT_16_BYTES;
import static org.junit.Assert.assertArrayEquals;
public class StreamDecrypterImplTest extends BriarTestCase {
public class StreamDecrypterImplTest extends BrambleTestCase {
private final AuthenticatedCipher cipher;
private final SecretKey streamHeaderKey, frameKey;

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.junit.Test;
@@ -13,7 +13,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.STREAM_H
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
import static org.junit.Assert.assertArrayEquals;
public class StreamEncrypterImplTest extends BriarTestCase {
public class StreamEncrypterImplTest extends BrambleTestCase {
private final AuthenticatedCipher cipher;
private final SecretKey streamHeaderKey, frameKey;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.crypto;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.util.StringUtils;
import org.junit.Test;
@@ -11,7 +11,7 @@ import java.util.Random;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class XSalsa20Poly1305AuthenticatedCipherTest extends BriarTestCase {
public class XSalsa20Poly1305AuthenticatedCipherTest extends BrambleTestCase {
// Test vectors from the NaCl paper
// http://cr.yp.to/highspeed/naclcrypto-20090310.pdf

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.data;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.data.BdfDictionary;
import org.briarproject.bramble.api.data.BdfList;
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class BdfReaderImplTest extends BriarTestCase {
public class BdfReaderImplTest extends BrambleTestCase {
private BdfReaderImpl r = null;

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.data;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.util.StringUtils;
import org.junit.Before;
import org.junit.Test;
@@ -16,7 +16,7 @@ import java.util.Map;
import static org.briarproject.bramble.api.data.BdfDictionary.NULL_VALUE;
import static org.junit.Assert.assertArrayEquals;
public class BdfWriterImplTest extends BriarTestCase {
public class BdfWriterImplTest extends BrambleTestCase {
private ByteArrayOutputStream out = null;
private BdfWriterImpl w = null;
@@ -155,7 +155,7 @@ public class BdfWriterImplTest extends BriarTestCase {
@Test
public void testWriteList() throws IOException {
List<Object> l = new ArrayList<>();
List<Object> l = new ArrayList<Object>();
for (int i = 0; i < 3; i++) l.add(i);
w.writeList(l);
// LIST tag, elements as integers, END tag
@@ -164,7 +164,7 @@ public class BdfWriterImplTest extends BriarTestCase {
@Test
public void testListCanContainNull() throws IOException {
List<Object> l = new ArrayList<>();
List<Object> l = new ArrayList<Object>();
l.add(1);
l.add(null);
l.add(NULL_VALUE);
@@ -177,7 +177,7 @@ public class BdfWriterImplTest extends BriarTestCase {
@Test
public void testWriteDictionary() throws IOException {
// Use LinkedHashMap to get predictable iteration order
Map<String, Object> m = new LinkedHashMap<>();
Map<String, Object> m = new LinkedHashMap<String, Object>();
for (int i = 0; i < 4; i++) m.put(String.valueOf(i), i);
w.writeDictionary(m);
// DICTIONARY tag, keys as strings and values as integers, END tag
@@ -216,12 +216,12 @@ public class BdfWriterImplTest extends BriarTestCase {
@Test
public void testWriteNestedDictionariesAndLists() throws IOException {
Map<String, Object> inner = new LinkedHashMap<>();
Map<String, Object> inner = new LinkedHashMap<String, Object>();
inner.put("bar", new byte[0]);
List<Object> list = new ArrayList<>();
List<Object> list = new ArrayList<Object>();
list.add(1);
list.add(inner);
Map<String, Object> outer = new LinkedHashMap<>();
Map<String, Object> outer = new LinkedHashMap<String, Object>();
outer.put("foo", list);
w.writeDictionary(outer);
// DICTIONARY tag, "foo" as string, LIST tag, 1 as integer,

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.data;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.data.BdfDictionary;
import org.briarproject.bramble.api.db.Metadata;
@@ -15,7 +15,7 @@ import java.util.Map;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
public class MetadataEncoderParserIntegrationTest extends BrambleTestCase {
private MetadataEncoderImpl e;
private MetadataParserImpl p;
@@ -99,7 +99,7 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
@Test
public void testList() throws FormatException {
List<Long> l = new ArrayList<>(4);
List<Long> l = new ArrayList<Long>(4);
l.add(42L);
l.add(1337L);
l.add(Long.MIN_VALUE);
@@ -114,7 +114,7 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
@Test
public void testDictionary() throws FormatException {
Map<String, Boolean> m = new HashMap<>();
Map<String, Boolean> m = new HashMap<String, Boolean>();
m.put("1", true);
m.put("2", false);
@@ -130,19 +130,19 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
@Test
public void testComplexDictionary() throws FormatException {
Map<String, List> m = new HashMap<>();
List<String> one = new ArrayList<>(3);
Map<String, List> m = new HashMap<String, List>();
List<String> one = new ArrayList<String>(3);
one.add("\uFDD0");
one.add("\uFDD1");
one.add("\uFDD2");
m.put("One", one);
List<String> two = new ArrayList<>(2);
List<String> two = new ArrayList<String>(2);
two.add("\u0080");
two.add("\uD800\uDC00");
m.put("Two", two);
d.put("test", m);
Map<String, Boolean> m2 = new HashMap<>();
Map<String, Boolean> m2 = new HashMap<String, Boolean>();
m2.put("should be true", true);
d.put("another test", m2);

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.db;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class BasicH2Test extends BriarTestCase {
public class BasicH2Test extends BrambleTestCase {
private static final String CREATE_TABLE =
"CREATE TABLE foo (uniqueId BINARY(32), name VARCHAR NOT NULL)";
@@ -322,7 +322,7 @@ public class BasicH2Test extends BriarTestCase {
private List<String> getNames() throws SQLException {
String sql = "SELECT name FROM foo ORDER BY uniqueId";
List<String> names = new ArrayList<>();
List<String> names = new ArrayList<String>();
try {
PreparedStatement ps = connection.prepareStatement(sql);
ResultSet rs = ps.executeQuery();

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.db;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.contact.event.ContactAddedEvent;
@@ -72,7 +72,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
public class DatabaseComponentImplTest extends BriarTestCase {
public class DatabaseComponentImplTest extends BrambleTestCase {
private final Object txn = new Object();
private final ClientId clientId;
@@ -118,8 +118,8 @@ public class DatabaseComponentImplTest extends BriarTestCase {
private DatabaseComponent createDatabaseComponent(Database<Object> database,
EventBus eventBus, ShutdownManager shutdown) {
return new DatabaseComponentImpl<>(database, Object.class, eventBus,
shutdown);
return new DatabaseComponentImpl<Object>(database, Object.class,
eventBus, shutdown);
}
@Test
@@ -1701,7 +1701,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
Transaction transaction = db.startTransaction(false);
try {
db.addLocalMessage(transaction, message, metadata, true);
Collection<MessageId> dependencies = new ArrayList<>(2);
Collection<MessageId> dependencies = new ArrayList<MessageId>(2);
dependencies.add(messageId1);
dependencies.add(messageId2);
db.addMessageDependencies(transaction, message, dependencies);

View File

@@ -1,11 +1,11 @@
package org.briarproject.bramble.db;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ExponentialBackoffTest extends BriarTestCase {
public class ExponentialBackoffTest extends BrambleTestCase {
private static final int ONE_HOUR = 60 * 60 * 1000;

View File

@@ -1,8 +1,7 @@
package org.briarproject.bramble.db;
import org.briarproject.BriarTestCase;
import org.briarproject.TestDatabaseConfig;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.crypto.SecretKey;
@@ -24,6 +23,7 @@ import org.briarproject.bramble.api.transport.IncomingKeys;
import org.briarproject.bramble.api.transport.OutgoingKeys;
import org.briarproject.bramble.api.transport.TransportKeys;
import org.briarproject.bramble.system.SystemClock;
import org.briarproject.bramble.TestDatabaseConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -61,7 +61,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class H2DatabaseTest extends BriarTestCase {
public class H2DatabaseTest extends BrambleTestCase {
private static final int ONE_MEGABYTE = 1024 * 1024;
private static final int MAX_SIZE = 5 * ONE_MEGABYTE;
@@ -868,7 +868,7 @@ public class H2DatabaseTest extends BriarTestCase {
assertEquals(0, db.countOfferedMessages(txn, contactId));
// Add some offered messages and count them
List<MessageId> ids = new ArrayList<>();
List<MessageId> ids = new ArrayList<MessageId>();
for (int i = 0; i < 10; i++) {
MessageId m = new MessageId(TestUtils.getRandomId());
db.addOfferedMessage(txn, contactId, m);

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.db;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class LockFairnessTest extends BriarTestCase {
public class LockFairnessTest extends BrambleTestCase {
@Test
public void testReadersCanShareTheLock() throws Exception {

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.db;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class TransactionIsolationTest extends BriarTestCase {
public class TransactionIsolationTest extends BrambleTestCase {
private static final String DROP_TABLE = "DROP TABLE foo IF EXISTS";
private static final String CREATE_TABLE = "CREATE TABLE foo"

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.identity;
import org.briarproject.BriarMockTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleMockTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.db.DatabaseComponent;
@@ -24,7 +24,7 @@ import static org.briarproject.bramble.api.identity.Author.Status.UNVERIFIED;
import static org.briarproject.bramble.api.identity.Author.Status.VERIFIED;
import static org.junit.Assert.assertEquals;
public class IdentityManagerImplTest extends BriarMockTestCase {
public class IdentityManagerImplTest extends BrambleMockTestCase {
private final IdentityManager identityManager;
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
@@ -79,7 +79,7 @@ public class IdentityManagerImplTest extends BriarMockTestCase {
@Test
public void testGetAuthorStatus() throws DbException {
final AuthorId authorId = new AuthorId(TestUtils.getRandomId());
final Collection<Contact> contacts = new ArrayList<>();
final Collection<Contact> contacts = new ArrayList<Contact>();
context.checking(new Expectations() {{
oneOf(db).startTransaction(true);

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.keyagreement;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.KeyPair;
import org.briarproject.bramble.api.crypto.PublicKey;
@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class KeyAgreementProtocolTest extends BriarTestCase {
public class KeyAgreementProtocolTest extends BrambleTestCase {
@Rule
public JUnitRuleMockery context = new JUnitRuleMockery() {{

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.lifecycle;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.lifecycle.ShutdownManager;
import org.junit.Test;
@@ -10,12 +10,12 @@ import java.util.Set;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class ShutdownManagerImplTest extends BriarTestCase {
public class ShutdownManagerImplTest extends BrambleTestCase {
@Test
public void testAddAndRemove() {
ShutdownManager s = createShutdownManager();
Set<Integer> handles = new HashSet<>();
Set<Integer> handles = new HashSet<Integer>();
for (int i = 0; i < 100; i++) {
int handle = s.addShutdownHook(new Runnable() {
@Override

View File

@@ -1,12 +1,12 @@
package org.briarproject.bramble.plugin;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class BackoffImplTest extends BriarTestCase {
public class BackoffImplTest extends BrambleTestCase {
private static final int MIN_INTERVAL = 60 * 1000;
private static final int MAX_INTERVAL = 60 * 60 * 1000;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.plugin;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.event.EventBus;
import org.briarproject.bramble.api.plugin.ConnectionRegistry;
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class ConnectionRegistryImplTest extends BriarTestCase {
public class ConnectionRegistryImplTest extends BrambleTestCase {
private final ContactId contactId, contactId1;
private final TransportId transportId, transportId1;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.plugin;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.event.EventBus;
import org.briarproject.bramble.api.plugin.ConnectionManager;
import org.briarproject.bramble.api.plugin.PluginConfig;
@@ -23,7 +23,7 @@ import java.util.Arrays;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public class PluginManagerImplTest extends BriarTestCase {
public class PluginManagerImplTest extends BrambleTestCase {
@Test
public void testStartAndStop() throws Exception {

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.plugin;
import org.briarproject.BriarTestCase;
import org.briarproject.ImmediateExecutor;
import org.briarproject.RunAction;
import org.briarproject.bramble.RunAction;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.ImmediateExecutor;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.contact.event.ContactStatusChangedEvent;
import org.briarproject.bramble.api.plugin.ConnectionManager;
@@ -32,7 +32,7 @@ import java.util.concurrent.ScheduledExecutorService;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
public class PollerTest extends BriarTestCase {
public class PollerTest extends BrambleTestCase {
private final ContactId contactId = new ContactId(234);
private final int pollingInterval = 60 * 1000;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.plugin.tcp;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.data.BdfList;
import org.briarproject.bramble.api.keyagreement.KeyAgreementConnection;
@@ -39,7 +39,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class LanTcpPluginTest extends BriarTestCase {
public class LanTcpPluginTest extends BrambleTestCase {
private final ContactId contactId = new ContactId(234);
private final Backoff backoff = new TestBackoff();
@@ -194,7 +194,8 @@ public class LanTcpPluginTest extends BriarTestCase {
plugin.createKeyAgreementListener(new byte[COMMIT_LENGTH]);
assertNotNull(kal);
Callable<KeyAgreementConnection> c = kal.listen();
FutureTask<KeyAgreementConnection> f = new FutureTask<>(c);
FutureTask<KeyAgreementConnection> f =
new FutureTask<KeyAgreementConnection>(c);
new Thread(f).start();
// The plugin should have bound a socket and stored the port number
BdfList descriptor = kal.getDescriptor();
@@ -290,7 +291,7 @@ public class LanTcpPluginTest extends BriarTestCase {
private static class Callback implements DuplexPluginCallback {
private final Map<ContactId, TransportProperties> remote =
new Hashtable<>();
new Hashtable<ContactId, TransportProperties>();
private final CountDownLatch propertiesLatch = new CountDownLatch(1);
private final CountDownLatch connectionsLatch = new CountDownLatch(1);
private final TransportProperties local = new TransportProperties();

View File

@@ -1,11 +1,11 @@
package org.briarproject.bramble.properties;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.fail;
public class TransportPropertyManagerImplTest extends BriarTestCase {
public class TransportPropertyManagerImplTest extends BrambleTestCase {
@Test
public void testUnitTestsExist() {

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.properties;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.data.BdfDictionary;
@@ -23,7 +23,7 @@ import static org.briarproject.bramble.api.plugin.TransportId.MAX_TRANSPORT_ID_L
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT;
import static org.junit.Assert.assertEquals;
public class TransportPropertyValidatorTest extends BriarTestCase {
public class TransportPropertyValidatorTest extends BrambleTestCase {
private final TransportId transportId;
private final BdfDictionary bdfDictionary;

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.sync;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.UniqueId;
import org.briarproject.bramble.util.ByteUtils;
@@ -17,7 +17,7 @@ import static org.briarproject.bramble.api.sync.SyncConstants.MAX_PACKET_PAYLOAD
import static org.briarproject.bramble.api.sync.SyncConstants.PACKET_HEADER_LENGTH;
import static org.junit.Assert.assertEquals;
public class PacketReaderImplTest extends BriarTestCase {
public class PacketReaderImplTest extends BrambleTestCase {
@Test(expected = FormatException.class)
public void testFormatExceptionIfAckIsTooLarge() throws Exception {

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.sync;
import org.briarproject.BriarTestCase;
import org.briarproject.ImmediateExecutor;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.ImmediateExecutor;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.db.DatabaseComponent;
import org.briarproject.bramble.api.db.Transaction;
@@ -20,7 +20,7 @@ import java.util.concurrent.Executor;
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_IDS;
public class SimplexOutgoingSessionTest extends BriarTestCase {
public class SimplexOutgoingSessionTest extends BrambleTestCase {
private final Mockery context;
private final DatabaseComponent db;

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.sync;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.SecretKey;
@@ -39,7 +39,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class SyncIntegrationTest extends BriarTestCase {
public class SyncIntegrationTest extends BrambleTestCase {
@Inject
GroupFactory groupFactory;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.sync;
import org.briarproject.TestSeedProviderModule;
import org.briarproject.bramble.TestSeedProviderModule;
import org.briarproject.bramble.crypto.CryptoModule;
import org.briarproject.bramble.transport.TransportModule;

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.sync;
import org.briarproject.BriarTestCase;
import org.briarproject.ImmediateExecutor;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.ImmediateExecutor;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.UniqueId;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.db.DatabaseComponent;
@@ -38,7 +38,7 @@ import static org.briarproject.bramble.api.sync.ValidationManager.State.INVALID;
import static org.briarproject.bramble.api.sync.ValidationManager.State.PENDING;
import static org.briarproject.bramble.api.sync.ValidationManager.State.UNKNOWN;
public class ValidationManagerImplTest extends BriarTestCase {
public class ValidationManagerImplTest extends BrambleTestCase {
private final ClientId clientId =
new ClientId(TestUtils.getRandomString(5));
@@ -831,7 +831,8 @@ public class ValidationManagerImplTest extends BriarTestCase {
context.mock(IncomingMessageHook.class);
final MessageId messageId3 = new MessageId(TestUtils.getRandomId());
final MessageId messageId4 = new MessageId(TestUtils.getRandomId());
final Map<MessageId, State> twoDependents = new LinkedHashMap<>();
final Map<MessageId, State> twoDependents =
new LinkedHashMap<MessageId, State>();
twoDependents.put(messageId1, PENDING);
twoDependents.put(messageId2, PENDING);
final Transaction txn = new Transaction(null, true);
@@ -952,10 +953,12 @@ public class ValidationManagerImplTest extends BriarTestCase {
raw);
final Message message4 = new Message(messageId4, groupId, timestamp,
raw);
final Map<MessageId, State> twoDependents = new LinkedHashMap<>();
final Map<MessageId, State> twoDependents =
new LinkedHashMap<MessageId, State>();
twoDependents.put(messageId1, PENDING);
twoDependents.put(messageId2, PENDING);
final Map<MessageId, State> twoDependencies = new LinkedHashMap<>();
final Map<MessageId, State> twoDependencies =
new LinkedHashMap<MessageId, State>();
twoDependencies.put(messageId1, DELIVERED);
twoDependencies.put(messageId2, DELIVERED);
final Transaction txn = new Transaction(null, true);
@@ -1117,7 +1120,8 @@ public class ValidationManagerImplTest extends BriarTestCase {
final MessageValidator validator = context.mock(MessageValidator.class);
final IncomingMessageHook hook =
context.mock(IncomingMessageHook.class);
final Map<MessageId, State> twoDependencies = new LinkedHashMap<>();
final Map<MessageId, State> twoDependencies =
new LinkedHashMap<MessageId, State>();
twoDependencies.put(messageId, DELIVERED);
twoDependencies.put(messageId2, UNKNOWN);
final Transaction txn = new Transaction(null, true);

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.system;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.Bytes;
import org.briarproject.bramble.util.OsUtils;
import org.junit.After;
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class LinuxSeedProviderTest extends BriarTestCase {
public class LinuxSeedProviderTest extends BrambleTestCase {
private final File testDir = TestUtils.getTestDirectory();
@@ -33,7 +33,7 @@ public class LinuxSeedProviderTest extends BriarTestCase {
System.err.println("WARNING: Skipping test, can't run on this OS");
return;
}
Set<Bytes> seeds = new HashSet<>();
Set<Bytes> seeds = new HashSet<Bytes>();
LinuxSeedProvider p = new LinuxSeedProvider();
for (int i = 0; i < 1000; i++) {
byte[] seed = p.getSeed();

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.transport;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.contact.event.ContactRemovedEvent;
@@ -24,13 +24,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import static org.briarproject.TestUtils.getRandomBytes;
import static org.briarproject.TestUtils.getRandomId;
import static org.briarproject.TestUtils.getSecretKey;
import static org.briarproject.bramble.TestUtils.getRandomBytes;
import static org.briarproject.bramble.TestUtils.getRandomId;
import static org.briarproject.bramble.TestUtils.getSecretKey;
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
import static org.junit.Assert.assertEquals;
public class KeyManagerImplTest extends BriarTestCase {
public class KeyManagerImplTest extends BrambleTestCase {
private final Mockery context = new Mockery();
private final KeyManagerImpl keyManager;
@@ -63,7 +63,7 @@ public class KeyManagerImplTest extends BriarTestCase {
Author remoteAuthor = new Author(remoteAuthorId, "author",
getRandomBytes(42));
AuthorId localAuthorId = new AuthorId(getRandomId());
final Collection<Contact> contacts = new ArrayList<>();
final Collection<Contact> contacts = new ArrayList<Contact>();
contacts.add(new Contact(contactId, remoteAuthor, localAuthorId, true,
true));
contacts.add(new Contact(inactiveContactId, remoteAuthor, localAuthorId,

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.transport;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.transport.ReorderingWindow.Change;
import org.junit.Test;
@@ -12,7 +12,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.REORDERI
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class ReorderingWindowTest extends BriarTestCase {
public class ReorderingWindowTest extends BrambleTestCase {
private static final int BITMAP_BYTES = REORDERING_WINDOW_SIZE / 8;

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.transport;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.crypto.StreamDecrypter;
import org.jmock.Expectations;
import org.jmock.Mockery;
@@ -9,7 +9,7 @@ import org.junit.Test;
import static org.briarproject.bramble.api.transport.TransportConstants.MAX_PAYLOAD_LENGTH;
import static org.junit.Assert.assertEquals;
public class StreamReaderImplTest extends BriarTestCase {
public class StreamReaderImplTest extends BrambleTestCase {
@Test
public void testEmptyFramesAreSkipped() throws Exception {

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.transport;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.crypto.StreamDecrypter;
import org.briarproject.bramble.api.crypto.StreamEncrypter;
import org.junit.Test;
@@ -19,7 +19,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENG
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class StreamReaderWriterIntegrationTest extends BriarTestCase {
public class StreamReaderWriterIntegrationTest extends BrambleTestCase {
@Test
public void testWriteAndRead() throws Exception {

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.transport;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.crypto.StreamEncrypter;
import org.jmock.Expectations;
import org.jmock.Mockery;
@@ -9,7 +9,7 @@ import org.junit.Test;
import static org.briarproject.bramble.api.transport.TransportConstants.MAX_PAYLOAD_LENGTH;
import static org.junit.Assert.assertEquals;
public class StreamWriterImplTest extends BriarTestCase {
public class StreamWriterImplTest extends BrambleTestCase {
@Test
public void testCloseWithoutWritingWritesFinalFrame() throws Exception {

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.transport;
import org.briarproject.BriarTestCase;
import org.briarproject.RunAction;
import org.briarproject.TestUtils;
import org.briarproject.bramble.RunAction;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.SecretKey;
@@ -40,7 +40,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
public class TransportKeyManagerImplTest extends BriarTestCase {
public class TransportKeyManagerImplTest extends BrambleTestCase {
private final TransportId transportId = new TransportId("id");
private final long maxLatency = 30 * 1000; // 30 seconds
@@ -62,7 +62,8 @@ public class TransportKeyManagerImplTest extends BriarTestCase {
context.mock(ScheduledExecutorService.class);
final Clock clock = context.mock(Clock.class);
final Map<ContactId, TransportKeys> loaded = new LinkedHashMap<>();
final Map<ContactId, TransportKeys> loaded =
new LinkedHashMap<ContactId, TransportKeys>();
final TransportKeys shouldRotate = createTransportKeys(900, 0);
final TransportKeys shouldNotRotate = createTransportKeys(1000, 0);
loaded.put(contactId, shouldRotate);
@@ -341,7 +342,7 @@ public class TransportKeyManagerImplTest extends BriarTestCase {
final boolean alice = true;
final TransportKeys transportKeys = createTransportKeys(1000, 0);
// Keep a copy of the tags
final List<byte[]> tags = new ArrayList<>();
final List<byte[]> tags = new ArrayList<byte[]>();
final Transaction txn = new Transaction(null, false);
context.checking(new Expectations() {{

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.util;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.briarproject.bramble.util.ByteUtils.MAX_16_BIT_UNSIGNED;
@@ -8,7 +8,7 @@ import static org.briarproject.bramble.util.ByteUtils.MAX_32_BIT_UNSIGNED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class ByteUtilsTest extends BriarTestCase {
public class ByteUtilsTest extends BrambleTestCase {
@Test
public void testReadUint16() {

View File

@@ -1,13 +1,13 @@
package org.briarproject.bramble.util;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
public class StringUtilsTest extends BriarTestCase {
public class StringUtilsTest extends BrambleTestCase {
@Test
public void testToHexString() {

View File

@@ -7,4 +7,10 @@ apply plugin: 'witness'
dependencies {
compile project(':bramble-core')
compile fileTree(dir: 'libs', include: '*.jar')
testCompile project(path: ':bramble-core', configuration: 'testOutput')
}
tasks.withType(Test) {
systemProperty 'java.library.path', 'libs'
}

View File

@@ -1,11 +1,11 @@
package org.briarproject.bramble.plugin.file;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class LinuxRemovableDriveFinderTest extends BriarTestCase {
public class LinuxRemovableDriveFinderTest extends BrambleTestCase {
@Test
public void testParseMountPoint() {

View File

@@ -1,11 +1,11 @@
package org.briarproject.bramble.plugin.file;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class MacRemovableDriveFinderTest extends BriarTestCase {
public class MacRemovableDriveFinderTest extends BrambleTestCase {
@Test
public void testParseMountPoint() {

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.plugin.file;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
import org.junit.Test;
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class PollingRemovableDriveMonitorTest extends BriarTestCase {
public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
@Test
public void testOneCallbackPerFile() throws Exception {
@@ -41,7 +41,7 @@ public class PollingRemovableDriveMonitorTest extends BriarTestCase {
};
// Create a callback that waits for two files
final CountDownLatch latch = new CountDownLatch(2);
final List<File> detected = new ArrayList<>();
final List<File> detected = new ArrayList<File>();
@NotNullByDefault
Callback callback = new Callback() {

View File

@@ -1,8 +1,8 @@
package org.briarproject.bramble.plugin.file;
import org.briarproject.BriarTestCase;
import org.briarproject.ImmediateExecutor;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.ImmediateExecutor;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
import org.briarproject.bramble.api.plugin.simplex.SimplexPluginCallback;
@@ -29,7 +29,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class RemovableDrivePluginTest extends BriarTestCase {
public class RemovableDrivePluginTest extends BrambleTestCase {
private final File testDir = TestUtils.getTestDirectory();
private final ContactId contactId = new ContactId(234);
@@ -73,7 +73,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
public void testWriterIsNullIfNoDriveIsChosen() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
final List<File> drives = new ArrayList<File>();
drives.add(drive1);
drives.add(drive2);
@@ -112,7 +112,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
public void testWriterIsNullIfOutputDirDoesNotExist() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
final List<File> drives = new ArrayList<File>();
drives.add(drive1);
drives.add(drive2);
@@ -151,7 +151,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
public void testWriterIsNullIfOutputDirIsAFile() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
final List<File> drives = new ArrayList<File>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a file rather than a directory
@@ -192,7 +192,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
public void testWriterIsNotNullIfOutputDirIsADir() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
final List<File> drives = new ArrayList<File>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a directory
@@ -236,7 +236,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
public void testWritingToWriter() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
final List<File> drives = new ArrayList<File>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a directory

View File

@@ -1,7 +1,7 @@
package org.briarproject.bramble.plugin.file;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
import org.briarproject.bramble.util.OsUtils;
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class UnixRemovableDriveMonitorTest extends BriarTestCase {
public class UnixRemovableDriveMonitorTest extends BrambleTestCase {
private final File testDir = TestUtils.getTestDirectory();
@@ -61,7 +61,7 @@ public class UnixRemovableDriveMonitorTest extends BriarTestCase {
return;
}
// Create a callback that will wait for two files before stopping
final List<File> detected = new ArrayList<>();
final List<File> detected = new ArrayList<File>();
final CountDownLatch latch = new CountDownLatch(2);
@NotNullByDefault
final Callback callback = new Callback() {

View File

@@ -1,12 +1,12 @@
package org.briarproject.bramble.plugin.modem;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class CountryCodesTest extends BriarTestCase {
public class CountryCodesTest extends BrambleTestCase {
@Test
public void testTranslation() {

View File

@@ -1,6 +1,6 @@
package org.briarproject.bramble.plugin.modem;
import org.briarproject.BriarTestCase;
import org.briarproject.bramble.BrambleTestCase;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
import org.briarproject.bramble.api.properties.TransportProperties;
@@ -16,7 +16,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class ModemPluginTest extends BriarTestCase {
public class ModemPluginTest extends BrambleTestCase {
private static final String ISO_1336 = "GB";
private static final String NUMBER = "0123456789";

View File

@@ -30,14 +30,13 @@ dependencies {
compile 'info.guardianproject.trustedintents:trustedintents:0.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.zxing:core:3.2.1'
apt 'com.google.dagger:dagger-compiler:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.8'
provided 'javax.annotation:jsr250-api:1.0'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'uk.co.samuelwall:material-tap-target-prompt:1.3.0'
testCompile 'junit:junit:4.12'
testCompile project(path: ':briar-tests')
testCompile project(path: ':bramble-core', configuration: 'testOutput')
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.mockito:mockito-core:1.10.19'
}

View File

@@ -4,7 +4,7 @@ import android.content.Intent;
import junit.framework.Assert;
import org.briarproject.TestUtils;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.identity.Author;
import org.briarproject.bramble.api.identity.AuthorId;

View File

@@ -1,3 +1,4 @@
bin
build
test.tmp
.settings

View File

@@ -16,11 +16,10 @@ dependencies {
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'org.jsoup:jsoup:1.9.2'
testCompile project(':briar-tests') // TODO remove when moving unit tests (#778)
testCompile 'junit:junit:4.12'
testCompile project(':bramble-core') // TODO get rid of this dependency
testCompile project(path: ':bramble-api', configuration: 'testOutput')
testCompile 'net.jodah:concurrentunit:0.4.2'
testCompile 'com.google.dagger:dagger-compiler:2.8'
testApt 'com.google.dagger:dagger-compiler:2.8'
}
dependencyVerification {

View File

@@ -2,8 +2,7 @@ package org.briarproject.briar;
import net.jodah.concurrentunit.Waiter;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.client.ContactGroupFactory;
import org.briarproject.bramble.api.contact.Contact;
@@ -60,11 +59,11 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
import static junit.framework.Assert.assertNotNull;
import static org.briarproject.TestPluginConfigModule.MAX_LATENCY;
import static org.briarproject.TestUtils.getSecretKey;
import static org.briarproject.bramble.TestUtils.getSecretKey;
import static org.briarproject.bramble.api.sync.ValidationManager.State.DELIVERED;
import static org.briarproject.bramble.api.sync.ValidationManager.State.INVALID;
import static org.briarproject.bramble.api.sync.ValidationManager.State.PENDING;
import static org.briarproject.briar.TestPluginConfigModule.MAX_LATENCY;
import static org.junit.Assert.assertTrue;
@MethodsNotNullByDefault

View File

@@ -1,8 +1,7 @@
package org.briarproject.briar;
import org.briarproject.TestDatabaseModule;
import org.briarproject.TestPluginConfigModule;
import org.briarproject.TestSeedProviderModule;
import org.briarproject.bramble.TestDatabaseModule;
import org.briarproject.bramble.TestSeedProviderModule;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.contact.ContactManager;
import org.briarproject.bramble.api.db.DatabaseComponent;

View File

@@ -0,0 +1,11 @@
package org.briarproject.briar;
import org.briarproject.bramble.BrambleTestCase;
public abstract class BriarTestCase extends BrambleTestCase {
public BriarTestCase() {
super();
}
}

View File

@@ -0,0 +1,28 @@
package org.briarproject.briar;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.briar.api.client.MessageTracker;
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
import static org.junit.Assert.assertEquals;
public class BriarTestUtils {
public static void assertGroupCount(MessageTracker tracker, GroupId g,
long msgCount, long unreadCount, long latestMsgTime)
throws DbException {
GroupCount groupCount = tracker.getGroupCount(g);
assertEquals(msgCount, groupCount.getMsgCount());
assertEquals(unreadCount, groupCount.getUnreadCount());
assertEquals(latestMsgTime, groupCount.getLatestMsgTime());
}
public static void assertGroupCount(MessageTracker tracker, GroupId g,
long msgCount, long unreadCount) throws DbException {
GroupCount c1 = tracker.getGroupCount(g);
assertEquals(msgCount, c1.getMsgCount());
assertEquals(unreadCount, c1.getUnreadCount());
}
}

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.briar;
import org.hamcrest.Description;
import org.jmock.api.Action;

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.briar;
import org.briarproject.bramble.api.lifecycle.IoExecutor;
import org.briarproject.bramble.api.lifecycle.LifecycleManager;

View File

@@ -1,4 +1,4 @@
package org.briarproject;
package org.briarproject.briar;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.plugin.PluginConfig;

View File

@@ -1,6 +1,6 @@
package org.briarproject.briar.blog;
import org.briarproject.BriarTestCase;
import org.briarproject.briar.BriarTestCase;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.contact.Contact;
@@ -34,8 +34,8 @@ import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
import static org.briarproject.TestUtils.getRandomBytes;
import static org.briarproject.TestUtils.getRandomId;
import static org.briarproject.bramble.TestUtils.getRandomBytes;
import static org.briarproject.bramble.TestUtils.getRandomId;
import static org.briarproject.bramble.api.identity.Author.Status.VERIFIED;
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;

View File

@@ -1,6 +1,6 @@
package org.briarproject.briar.blog;
import org.briarproject.TestDatabaseModule;
import org.briarproject.bramble.TestDatabaseModule;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.sync.MessageId;
import org.briarproject.briar.BriarIntegrationTest;
@@ -21,7 +21,7 @@ import java.util.Iterator;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static org.briarproject.TestUtils.getRandomString;
import static org.briarproject.bramble.TestUtils.getRandomString;
import static org.briarproject.briar.api.blog.MessageType.COMMENT;
import static org.briarproject.briar.api.blog.MessageType.POST;
import static org.briarproject.briar.api.blog.MessageType.WRAPPED_COMMENT;

View File

@@ -1,7 +1,7 @@
package org.briarproject.briar.blog;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.briar.BriarTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.data.BdfDictionary;

View File

@@ -1,8 +1,8 @@
package org.briarproject.briar.client;
import org.briarproject.BriarTestCase;
import org.briarproject.CaptureArgumentAction;
import org.briarproject.TestUtils;
import org.briarproject.briar.BriarTestCase;
import org.briarproject.briar.CaptureArgumentAction;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.data.BdfDictionary;
import org.briarproject.bramble.api.data.BdfList;
@@ -130,7 +130,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.mock(ValidationManager.class);
final AtomicReference<MessageValidator> captured =
new AtomicReference<>();
new AtomicReference<MessageValidator>();
final QueueMessageValidator queueMessageValidator =
context.mock(QueueMessageValidator.class);
// The message is too short to be a valid queue message
@@ -141,7 +141,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerMessageValidator(with(clientId),
with(any(MessageValidator.class)));
will(new CaptureArgumentAction<>(captured,
will(new CaptureArgumentAction<MessageValidator>(captured,
MessageValidator.class, 1));
}});
@@ -174,7 +174,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.mock(ValidationManager.class);
final AtomicReference<MessageValidator> captured =
new AtomicReference<>();
new AtomicReference<MessageValidator>();
final QueueMessageValidator queueMessageValidator =
context.mock(QueueMessageValidator.class);
// The message has a negative queue position
@@ -187,7 +187,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerMessageValidator(with(clientId),
with(any(MessageValidator.class)));
will(new CaptureArgumentAction<>(captured,
will(new CaptureArgumentAction<MessageValidator>(captured,
MessageValidator.class, 1));
}});
@@ -220,7 +220,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.mock(ValidationManager.class);
final AtomicReference<MessageValidator> captured =
new AtomicReference<>();
new AtomicReference<MessageValidator>();
final QueueMessageValidator queueMessageValidator =
context.mock(QueueMessageValidator.class);
final Metadata metadata = new Metadata();
@@ -234,7 +234,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerMessageValidator(with(clientId),
with(any(MessageValidator.class)));
will(new CaptureArgumentAction<>(captured,
will(new CaptureArgumentAction<MessageValidator>(captured,
MessageValidator.class, 1));
// The message should be delegated
oneOf(queueMessageValidator).validateMessage(
@@ -267,7 +267,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<>();
new AtomicReference<IncomingMessageHook>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -283,7 +283,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<>(captured,
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));
@@ -319,7 +319,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<>();
new AtomicReference<IncomingMessageHook>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -337,7 +337,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<>(captured,
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));
@@ -375,7 +375,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<>();
new AtomicReference<IncomingMessageHook>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -392,7 +392,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<>(captured,
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));
@@ -433,7 +433,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<>();
new AtomicReference<IncomingMessageHook>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -457,7 +457,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<>(captured,
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));

View File

@@ -1,6 +1,6 @@
package org.briarproject.briar.client;
import org.briarproject.TestUtils;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.sync.MessageId;
import org.briarproject.briar.api.client.MessageTree;
@@ -19,7 +19,7 @@ public class MessageTreeImplTest {
@Test
public void testMessageTree() {
tree = new MessageTreeImpl<>();
tree = new MessageTreeImpl<TestNode>();
testSimpleTree();
tree.clear();
testSimpleTree();

View File

@@ -1,6 +1,6 @@
package org.briarproject.briar.forum;
import org.briarproject.BriarTestCase;
import org.briarproject.briar.BriarTestCase;
import org.junit.Test;
import static org.junit.Assert.fail;

View File

@@ -1,6 +1,6 @@
package org.briarproject.briar.forum;
import org.briarproject.TestDatabaseModule;
import org.briarproject.bramble.TestDatabaseModule;
import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.briar.BriarIntegrationTest;
import org.briarproject.briar.BriarIntegrationTestComponent;
@@ -17,7 +17,7 @@ import java.util.Collection;
import javax.annotation.Nullable;
import static org.briarproject.TestUtils.assertGroupCount;
import static org.briarproject.briar.BriarTestUtils.assertGroupCount;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;

View File

@@ -1,7 +1,7 @@
package org.briarproject.briar.forum;
import org.briarproject.TestUtils;
import org.briarproject.ValidatorTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.ValidatorTestCase;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.UniqueId;
import org.briarproject.bramble.api.client.BdfMessageContext;

View File

@@ -1,7 +1,7 @@
package org.briarproject.briar.introduction;
import org.briarproject.BriarTestCase;
import org.briarproject.TestUtils;
import org.briarproject.briar.BriarTestCase;
import org.briarproject.bramble.TestUtils;
import org.briarproject.bramble.api.Bytes;
import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.client.ClientHelper;

Some files were not shown because too many files have changed in this diff Show More