mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Move all unit tests to their modules and remove briar-tests
This commit is contained in:
@@ -5,18 +5,37 @@ targetCompatibility = 1.6
|
|||||||
apply plugin: 'witness'
|
apply plugin: 'witness'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "com.google.dagger:dagger:2.0.2"
|
compile "com.google.dagger:dagger:2.8"
|
||||||
compile 'com.google.dagger:dagger-compiler:2.0.2'
|
compile 'com.google.dagger:dagger-compiler:2.8'
|
||||||
compile 'com.google.code.findbugs:jsr305:3.0.1'
|
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 {
|
dependencyVerification {
|
||||||
verify = [
|
verify = [
|
||||||
'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9',
|
'com.google.dagger:dagger:5070e1dff5c551a4908ba7b93125c0243de2a688aed3d2f475357d86d9d7c0ad',
|
||||||
'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3',
|
'com.google.dagger:dagger-compiler:7b2686f94907868c5364e9965601ffe2f020ba4af1849ad9b57dad5fe3fa6242',
|
||||||
|
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd',
|
||||||
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
||||||
'com.google.dagger:dagger-producers:99ec15e8a0507ba569e7655bc1165ee5e5ca5aa914b3c8f7e2c2458f724edd6b',
|
'com.google.dagger:dagger-producers:1e4043e85f67de381d19e22c7932aaf7ff1611091be7e1aaae93f2c37f331cf2',
|
||||||
'com.google.guava:guava:d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99',
|
'com.google.guava:guava:ff89d4a4a6b303c4084194975a5a35f55a8af6f7337678b4cc8ddbea9005c323',
|
||||||
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd'
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.jmock.Mockery;
|
import org.jmock.Mockery;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
|
||||||
public abstract class BriarMockTestCase extends BriarTestCase {
|
public abstract class BrambleMockTestCase extends
|
||||||
|
BrambleTestCase {
|
||||||
|
|
||||||
protected final Mockery context = new Mockery();
|
protected final Mockery context = new Mockery();
|
||||||
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
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
|
// Ensure exceptions thrown on worker threads cause tests to fail
|
||||||
UncaughtExceptionHandler fail = new UncaughtExceptionHandler() {
|
UncaughtExceptionHandler fail = new UncaughtExceptionHandler() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.system.SeedProvider;
|
import org.briarproject.bramble.api.system.SeedProvider;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.system.SeedProvider;
|
import org.briarproject.bramble.api.system.SeedProvider;
|
||||||
|
|
||||||
@@ -1,19 +1,13 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.UniqueId;
|
import org.briarproject.bramble.api.UniqueId;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
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.bramble.util.IoUtils;
|
||||||
import org.briarproject.briar.api.client.MessageTracker;
|
|
||||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class TestUtils {
|
public class TestUtils {
|
||||||
|
|
||||||
private static final AtomicInteger nextTestDir =
|
private static final AtomicInteger nextTestDir =
|
||||||
@@ -51,19 +45,4 @@ public class TestUtils {
|
|||||||
return new SecretKey(getRandomBytes(SecretKey.LENGTH));
|
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.data.MetadataEncoder;
|
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.sync.MessageId;
|
||||||
import org.briarproject.bramble.api.system.Clock;
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
|
|
||||||
public abstract class ValidatorTestCase extends BriarMockTestCase {
|
public abstract class ValidatorTestCase extends BrambleMockTestCase {
|
||||||
|
|
||||||
protected final ClientHelper clientHelper =
|
protected final ClientHelper clientHelper =
|
||||||
context.mock(ClientHelper.class);
|
context.mock(ClientHelper.class);
|
||||||
@@ -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.Bytes;
|
||||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
|
||||||
import org.briarproject.bramble.api.data.BdfEntry;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class BdfDictionaryTest extends BriarTestCase {
|
public class BdfDictionaryTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructors() {
|
public void testConstructors() {
|
||||||
@@ -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.Bytes;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
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 org.junit.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class BdfListTest extends BriarTestCase {
|
public class BdfListTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructors() {
|
public void testConstructors() {
|
||||||
1
bramble-core/.gitignore
vendored
1
bramble-core/.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
bin
|
bin
|
||||||
build
|
build
|
||||||
|
test.tmp
|
||||||
.settings
|
.settings
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ dependencies {
|
|||||||
compile 'com.madgag.spongycastle:core:1.54.0.0'
|
compile 'com.madgag.spongycastle:core:1.54.0.0'
|
||||||
compile 'com.h2database:h2:1.4.190'
|
compile 'com.h2database:h2:1.4.190'
|
||||||
|
|
||||||
testCompile project(':briar-tests') // TODO remove when moving unit tests (#778)
|
testCompile project(path: ':bramble-api', configuration: 'testOutput')
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
testCompile 'com.google.dagger:dagger-compiler:2.8'
|
|
||||||
testApt 'com.google.dagger:dagger-compiler:2.8'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyVerification {
|
dependencyVerification {
|
||||||
@@ -26,3 +23,15 @@ dependencyVerification {
|
|||||||
'com.h2database:h2:23ba495a07bbbb3bd6c3084d10a96dad7a23741b8b6d64b213459a784195a98c'
|
'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
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.bramble;
|
||||||
|
|
||||||
import org.hamcrest.Description;
|
import org.hamcrest.Description;
|
||||||
import org.jmock.api.Action;
|
import org.jmock.api.Action;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.client;
|
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.FormatException;
|
||||||
import org.briarproject.bramble.api.client.BdfMessageContext;
|
import org.briarproject.bramble.api.client.BdfMessageContext;
|
||||||
import org.briarproject.bramble.api.client.BdfMessageValidator;
|
import org.briarproject.bramble.api.client.BdfMessageValidator;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.client;
|
package org.briarproject.bramble.client;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
@@ -32,13 +32,13 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.briarproject.TestUtils.getRandomBytes;
|
import static org.briarproject.bramble.TestUtils.getRandomBytes;
|
||||||
import static org.briarproject.TestUtils.getRandomId;
|
import static org.briarproject.bramble.TestUtils.getRandomId;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class ClientHelperImplTest extends BriarTestCase {
|
public class ClientHelperImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final Mockery context = new Mockery();
|
private final Mockery context = new Mockery();
|
||||||
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||||
@@ -165,7 +165,8 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMessageMetadataAsDictionaryMap() throws Exception {
|
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);
|
map.put(messageId, dictionary);
|
||||||
final Transaction txn = new Transaction(null, true);
|
final Transaction txn = new Transaction(null, true);
|
||||||
|
|
||||||
@@ -187,7 +188,8 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMessageMetadataAsDictionaryQuery() throws Exception {
|
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);
|
map.put(messageId, dictionary);
|
||||||
final BdfDictionary query =
|
final BdfDictionary query =
|
||||||
BdfDictionary.of(new BdfEntry("query", "me"));
|
BdfDictionary.of(new BdfEntry("query", "me"));
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.contact;
|
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.Contact;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.contact.ContactManager;
|
import org.briarproject.bramble.api.contact.ContactManager;
|
||||||
@@ -19,13 +19,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.briarproject.TestUtils.getRandomBytes;
|
import static org.briarproject.bramble.TestUtils.getRandomBytes;
|
||||||
import static org.briarproject.TestUtils.getRandomId;
|
import static org.briarproject.bramble.TestUtils.getRandomId;
|
||||||
import static org.briarproject.TestUtils.getSecretKey;
|
import static org.briarproject.bramble.TestUtils.getSecretKey;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ContactManagerImplTest extends BriarMockTestCase {
|
public class ContactManagerImplTest extends BrambleMockTestCase {
|
||||||
|
|
||||||
private final Mockery context = new Mockery();
|
private final Mockery context = new Mockery();
|
||||||
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||||
@@ -132,7 +132,8 @@ public class ContactManagerImplTest extends BriarMockTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testActiveContacts() throws Exception {
|
public void testActiveContacts() throws Exception {
|
||||||
Collection<Contact> activeContacts = Collections.singletonList(contact);
|
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));
|
contacts.add(new Contact(new ContactId(3), remote, local, true, false));
|
||||||
final Transaction txn = new Transaction(null, true);
|
final Transaction txn = new Transaction(null, true);
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class AsciiArmourTest extends BriarTestCase {
|
public class AsciiArmourTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapOnSingleLine() {
|
public void testWrapOnSingleLine() {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.bramble.util.StringUtils;
|
import org.briarproject.bramble.util.StringUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
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
|
// Vectors from BLAKE2 web site: https://blake2.net/blake2s-test.txt
|
||||||
private static final String[][] keyedTestVectors = {
|
private static final String[][] keyedTestVectors = {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.spongycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
import org.spongycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
||||||
import org.spongycastle.asn1.x9.X9ECParameters;
|
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.briarproject.bramble.crypto.EllipticCurveConstants.PARAMETERS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class EllipticCurveMultiplicationTest extends BriarTestCase {
|
public class EllipticCurveMultiplicationTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiplierProducesSameResultsAsDefault() throws Exception {
|
public void testMultiplierProducesSameResultsAsDefault() throws Exception {
|
||||||
@@ -69,7 +69,7 @@ public class EllipticCurvePerformanceTest {
|
|||||||
ECPublicKeyParameters public2 =
|
ECPublicKeyParameters public2 =
|
||||||
(ECPublicKeyParameters) keyPair2.getPublic();
|
(ECPublicKeyParameters) keyPair2.getPublic();
|
||||||
// Time some ECDH key agreements
|
// Time some ECDH key agreements
|
||||||
List<Long> samples = new ArrayList<>();
|
List<Long> samples = new ArrayList<Long>();
|
||||||
for (int i = 0; i < SAMPLES; i++) {
|
for (int i = 0; i < SAMPLES; i++) {
|
||||||
ECDHCBasicAgreement agreement = new ECDHCBasicAgreement();
|
ECDHCBasicAgreement agreement = new ECDHCBasicAgreement();
|
||||||
long start = System.nanoTime();
|
long start = System.nanoTime();
|
||||||
@@ -79,7 +79,7 @@ public class EllipticCurvePerformanceTest {
|
|||||||
}
|
}
|
||||||
long agreementMedian = median(samples);
|
long agreementMedian = median(samples);
|
||||||
// Time some signatures
|
// Time some signatures
|
||||||
List<byte[]> signatures = new ArrayList<>();
|
List<byte[]> signatures = new ArrayList<byte[]>();
|
||||||
samples.clear();
|
samples.clear();
|
||||||
for (int i = 0; i < SAMPLES; i++) {
|
for (int i = 0; i < SAMPLES; i++) {
|
||||||
Digest digest = new Blake2sDigest();
|
Digest digest = new Blake2sDigest();
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.spongycastle.crypto.BlockCipher;
|
import org.spongycastle.crypto.BlockCipher;
|
||||||
import org.spongycastle.crypto.engines.AESLightEngine;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class FortunaGeneratorTest extends BriarTestCase {
|
public class FortunaGeneratorTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCounterInitialisedToOne() {
|
public void testCounterInitialisedToOne() {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.spongycastle.crypto.BlockCipher;
|
import org.spongycastle.crypto.BlockCipher;
|
||||||
import org.spongycastle.crypto.digests.SHA256Digest;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class FortunaSecureRandomTest extends BriarTestCase {
|
public class FortunaSecureRandomTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClassPassesSelfTest() {
|
public void testClassPassesSelfTest() {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestSeedProvider;
|
import org.briarproject.bramble.TestSeedProvider;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
@@ -10,7 +10,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
|
||||||
public class KeyAgreementTest extends BriarTestCase {
|
public class KeyAgreementTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeriveMasterSecret() throws Exception {
|
public void testDeriveMasterSecret() throws Exception {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestSeedProvider;
|
import org.briarproject.bramble.TestSeedProvider;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
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 TransportId transportId = new TransportId("id");
|
||||||
private final CryptoComponent crypto;
|
private final CryptoComponent crypto;
|
||||||
@@ -141,7 +141,7 @@ public class KeyDerivationTest extends BriarTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertAllDifferent(TransportKeys... transportKeys) {
|
private void assertAllDifferent(TransportKeys... transportKeys) {
|
||||||
List<SecretKey> secretKeys = new ArrayList<>();
|
List<SecretKey> secretKeys = new ArrayList<SecretKey>();
|
||||||
for (TransportKeys k : transportKeys) {
|
for (TransportKeys k : transportKeys) {
|
||||||
secretKeys.add(k.getPreviousIncomingKeys().getTagKey());
|
secretKeys.add(k.getPreviousIncomingKeys().getTagKey());
|
||||||
secretKeys.add(k.getPreviousIncomingKeys().getHeaderKey());
|
secretKeys.add(k.getPreviousIncomingKeys().getHeaderKey());
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestSeedProvider;
|
import org.briarproject.bramble.TestSeedProvider;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||||
import org.briarproject.bramble.api.crypto.KeyParser;
|
import org.briarproject.bramble.api.crypto.KeyParser;
|
||||||
import org.briarproject.bramble.api.crypto.PrivateKey;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class KeyEncodingAndParsingTest extends BriarTestCase {
|
public class KeyEncodingAndParsingTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final CryptoComponentImpl crypto =
|
private final CryptoComponentImpl crypto =
|
||||||
new CryptoComponentImpl(new TestSeedProvider());
|
new CryptoComponentImpl(new TestSeedProvider());
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestSeedProvider;
|
import org.briarproject.bramble.TestSeedProvider;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -12,7 +12,7 @@ import java.util.Arrays;
|
|||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
public class MacTest extends BriarTestCase {
|
public class MacTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final CryptoComponent crypto;
|
private final CryptoComponent crypto;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
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.KeyPair;
|
||||||
import org.briarproject.bramble.api.crypto.PrivateKey;
|
import org.briarproject.bramble.api.crypto.PrivateKey;
|
||||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||||
@@ -11,7 +11,7 @@ import java.security.SecureRandom;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
|
||||||
public class MessageEncrypterTest extends BriarTestCase {
|
public class MessageEncrypterTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final SecureRandom random = new SecureRandom();
|
private final SecureRandom random = new SecureRandom();
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestSeedProvider;
|
import org.briarproject.bramble.TestSeedProvider;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Random;
|
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.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class PasswordBasedKdfTest extends BriarTestCase {
|
public class PasswordBasedKdfTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final CryptoComponentImpl crypto =
|
private final CryptoComponentImpl crypto =
|
||||||
new CryptoComponentImpl(new TestSeedProvider());
|
new CryptoComponentImpl(new TestSeedProvider());
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class PasswordStrengthEstimatorImplTest extends BriarTestCase {
|
public class PasswordStrengthEstimatorImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWeakPasswords() {
|
public void testWeakPasswords() {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestSeedProvider;
|
import org.briarproject.bramble.TestSeedProvider;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||||
import org.junit.Test;
|
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.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class SignatureTest extends BriarTestCase {
|
public class SignatureTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final CryptoComponent crypto;
|
private final CryptoComponent crypto;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
import org.briarproject.bramble.util.ByteUtils;
|
import org.briarproject.bramble.util.ByteUtils;
|
||||||
import org.junit.Test;
|
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.briarproject.bramble.util.ByteUtils.INT_16_BYTES;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
|
||||||
public class StreamDecrypterImplTest extends BriarTestCase {
|
public class StreamDecrypterImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final AuthenticatedCipher cipher;
|
private final AuthenticatedCipher cipher;
|
||||||
private final SecretKey streamHeaderKey, frameKey;
|
private final SecretKey streamHeaderKey, frameKey;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
package org.briarproject.bramble.crypto;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
import org.junit.Test;
|
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.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
|
||||||
public class StreamEncrypterImplTest extends BriarTestCase {
|
public class StreamEncrypterImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final AuthenticatedCipher cipher;
|
private final AuthenticatedCipher cipher;
|
||||||
private final SecretKey streamHeaderKey, frameKey;
|
private final SecretKey streamHeaderKey, frameKey;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.crypto;
|
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.api.crypto.SecretKey;
|
||||||
import org.briarproject.bramble.util.StringUtils;
|
import org.briarproject.bramble.util.StringUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -11,7 +11,7 @@ import java.util.Random;
|
|||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class XSalsa20Poly1305AuthenticatedCipherTest extends BriarTestCase {
|
public class XSalsa20Poly1305AuthenticatedCipherTest extends BrambleTestCase {
|
||||||
|
|
||||||
// Test vectors from the NaCl paper
|
// Test vectors from the NaCl paper
|
||||||
// http://cr.yp.to/highspeed/naclcrypto-20090310.pdf
|
// http://cr.yp.to/highspeed/naclcrypto-20090310.pdf
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.data;
|
package org.briarproject.bramble.data;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||||
import org.briarproject.bramble.api.data.BdfList;
|
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.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class BdfReaderImplTest extends BriarTestCase {
|
public class BdfReaderImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private BdfReaderImpl r = null;
|
private BdfReaderImpl r = null;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.data;
|
package org.briarproject.bramble.data;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.util.StringUtils;
|
import org.briarproject.bramble.util.StringUtils;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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.briarproject.bramble.api.data.BdfDictionary.NULL_VALUE;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
|
||||||
public class BdfWriterImplTest extends BriarTestCase {
|
public class BdfWriterImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private ByteArrayOutputStream out = null;
|
private ByteArrayOutputStream out = null;
|
||||||
private BdfWriterImpl w = null;
|
private BdfWriterImpl w = null;
|
||||||
@@ -155,7 +155,7 @@ public class BdfWriterImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriteList() throws IOException {
|
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);
|
for (int i = 0; i < 3; i++) l.add(i);
|
||||||
w.writeList(l);
|
w.writeList(l);
|
||||||
// LIST tag, elements as integers, END tag
|
// LIST tag, elements as integers, END tag
|
||||||
@@ -164,7 +164,7 @@ public class BdfWriterImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCanContainNull() throws IOException {
|
public void testListCanContainNull() throws IOException {
|
||||||
List<Object> l = new ArrayList<>();
|
List<Object> l = new ArrayList<Object>();
|
||||||
l.add(1);
|
l.add(1);
|
||||||
l.add(null);
|
l.add(null);
|
||||||
l.add(NULL_VALUE);
|
l.add(NULL_VALUE);
|
||||||
@@ -177,7 +177,7 @@ public class BdfWriterImplTest extends BriarTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testWriteDictionary() throws IOException {
|
public void testWriteDictionary() throws IOException {
|
||||||
// Use LinkedHashMap to get predictable iteration order
|
// 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);
|
for (int i = 0; i < 4; i++) m.put(String.valueOf(i), i);
|
||||||
w.writeDictionary(m);
|
w.writeDictionary(m);
|
||||||
// DICTIONARY tag, keys as strings and values as integers, END tag
|
// DICTIONARY tag, keys as strings and values as integers, END tag
|
||||||
@@ -216,12 +216,12 @@ public class BdfWriterImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriteNestedDictionariesAndLists() throws IOException {
|
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]);
|
inner.put("bar", new byte[0]);
|
||||||
List<Object> list = new ArrayList<>();
|
List<Object> list = new ArrayList<Object>();
|
||||||
list.add(1);
|
list.add(1);
|
||||||
list.add(inner);
|
list.add(inner);
|
||||||
Map<String, Object> outer = new LinkedHashMap<>();
|
Map<String, Object> outer = new LinkedHashMap<String, Object>();
|
||||||
outer.put("foo", list);
|
outer.put("foo", list);
|
||||||
w.writeDictionary(outer);
|
w.writeDictionary(outer);
|
||||||
// DICTIONARY tag, "foo" as string, LIST tag, 1 as integer,
|
// DICTIONARY tag, "foo" as string, LIST tag, 1 as integer,
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.data;
|
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.FormatException;
|
||||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||||
import org.briarproject.bramble.api.db.Metadata;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
public class MetadataEncoderParserIntegrationTest extends BrambleTestCase {
|
||||||
|
|
||||||
private MetadataEncoderImpl e;
|
private MetadataEncoderImpl e;
|
||||||
private MetadataParserImpl p;
|
private MetadataParserImpl p;
|
||||||
@@ -99,7 +99,7 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testList() throws FormatException {
|
public void testList() throws FormatException {
|
||||||
List<Long> l = new ArrayList<>(4);
|
List<Long> l = new ArrayList<Long>(4);
|
||||||
l.add(42L);
|
l.add(42L);
|
||||||
l.add(1337L);
|
l.add(1337L);
|
||||||
l.add(Long.MIN_VALUE);
|
l.add(Long.MIN_VALUE);
|
||||||
@@ -114,7 +114,7 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDictionary() throws FormatException {
|
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("1", true);
|
||||||
m.put("2", false);
|
m.put("2", false);
|
||||||
|
|
||||||
@@ -130,19 +130,19 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComplexDictionary() throws FormatException {
|
public void testComplexDictionary() throws FormatException {
|
||||||
Map<String, List> m = new HashMap<>();
|
Map<String, List> m = new HashMap<String, List>();
|
||||||
List<String> one = new ArrayList<>(3);
|
List<String> one = new ArrayList<String>(3);
|
||||||
one.add("\uFDD0");
|
one.add("\uFDD0");
|
||||||
one.add("\uFDD1");
|
one.add("\uFDD1");
|
||||||
one.add("\uFDD2");
|
one.add("\uFDD2");
|
||||||
m.put("One", one);
|
m.put("One", one);
|
||||||
List<String> two = new ArrayList<>(2);
|
List<String> two = new ArrayList<String>(2);
|
||||||
two.add("\u0080");
|
two.add("\u0080");
|
||||||
two.add("\uD800\uDC00");
|
two.add("\uD800\uDC00");
|
||||||
m.put("Two", two);
|
m.put("Two", two);
|
||||||
d.put("test", m);
|
d.put("test", m);
|
||||||
|
|
||||||
Map<String, Boolean> m2 = new HashMap<>();
|
Map<String, Boolean> m2 = new HashMap<String, Boolean>();
|
||||||
m2.put("should be true", true);
|
m2.put("should be true", true);
|
||||||
d.put("another test", m2);
|
d.put("another test", m2);
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.db;
|
package org.briarproject.bramble.db;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class BasicH2Test extends BriarTestCase {
|
public class BasicH2Test extends BrambleTestCase {
|
||||||
|
|
||||||
private static final String CREATE_TABLE =
|
private static final String CREATE_TABLE =
|
||||||
"CREATE TABLE foo (uniqueId BINARY(32), name VARCHAR NOT NULL)";
|
"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 {
|
private List<String> getNames() throws SQLException {
|
||||||
String sql = "SELECT name FROM foo ORDER BY uniqueId";
|
String sql = "SELECT name FROM foo ORDER BY uniqueId";
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = connection.prepareStatement(sql);
|
PreparedStatement ps = connection.prepareStatement(sql);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.db;
|
package org.briarproject.bramble.db;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.contact.Contact;
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.contact.event.ContactAddedEvent;
|
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.assertNotNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class DatabaseComponentImplTest extends BriarTestCase {
|
public class DatabaseComponentImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final Object txn = new Object();
|
private final Object txn = new Object();
|
||||||
private final ClientId clientId;
|
private final ClientId clientId;
|
||||||
@@ -118,8 +118,8 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
private DatabaseComponent createDatabaseComponent(Database<Object> database,
|
private DatabaseComponent createDatabaseComponent(Database<Object> database,
|
||||||
EventBus eventBus, ShutdownManager shutdown) {
|
EventBus eventBus, ShutdownManager shutdown) {
|
||||||
return new DatabaseComponentImpl<>(database, Object.class, eventBus,
|
return new DatabaseComponentImpl<Object>(database, Object.class,
|
||||||
shutdown);
|
eventBus, shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1701,7 +1701,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
Transaction transaction = db.startTransaction(false);
|
Transaction transaction = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.addLocalMessage(transaction, message, metadata, true);
|
db.addLocalMessage(transaction, message, metadata, true);
|
||||||
Collection<MessageId> dependencies = new ArrayList<>(2);
|
Collection<MessageId> dependencies = new ArrayList<MessageId>(2);
|
||||||
dependencies.add(messageId1);
|
dependencies.add(messageId1);
|
||||||
dependencies.add(messageId2);
|
dependencies.add(messageId2);
|
||||||
db.addMessageDependencies(transaction, message, dependencies);
|
db.addMessageDependencies(transaction, message, dependencies);
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package org.briarproject.bramble.db;
|
package org.briarproject.bramble.db;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
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;
|
private static final int ONE_HOUR = 60 * 60 * 1000;
|
||||||
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package org.briarproject.bramble.db;
|
package org.briarproject.bramble.db;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestDatabaseConfig;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.TestUtils;
|
|
||||||
import org.briarproject.bramble.api.contact.Contact;
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
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.OutgoingKeys;
|
||||||
import org.briarproject.bramble.api.transport.TransportKeys;
|
import org.briarproject.bramble.api.transport.TransportKeys;
|
||||||
import org.briarproject.bramble.system.SystemClock;
|
import org.briarproject.bramble.system.SystemClock;
|
||||||
|
import org.briarproject.bramble.TestDatabaseConfig;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
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 ONE_MEGABYTE = 1024 * 1024;
|
||||||
private static final int MAX_SIZE = 5 * ONE_MEGABYTE;
|
private static final int MAX_SIZE = 5 * ONE_MEGABYTE;
|
||||||
@@ -868,7 +868,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
assertEquals(0, db.countOfferedMessages(txn, contactId));
|
assertEquals(0, db.countOfferedMessages(txn, contactId));
|
||||||
|
|
||||||
// Add some offered messages and count them
|
// 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++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
MessageId m = new MessageId(TestUtils.getRandomId());
|
MessageId m = new MessageId(TestUtils.getRandomId());
|
||||||
db.addOfferedMessage(txn, contactId, m);
|
db.addOfferedMessage(txn, contactId, m);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.db;
|
package org.briarproject.bramble.db;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
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.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class LockFairnessTest extends BriarTestCase {
|
public class LockFairnessTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadersCanShareTheLock() throws Exception {
|
public void testReadersCanShareTheLock() throws Exception {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.db;
|
package org.briarproject.bramble.db;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
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 DROP_TABLE = "DROP TABLE foo IF EXISTS";
|
||||||
private static final String CREATE_TABLE = "CREATE TABLE foo"
|
private static final String CREATE_TABLE = "CREATE TABLE foo"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.identity;
|
package org.briarproject.bramble.identity;
|
||||||
|
|
||||||
import org.briarproject.BriarMockTestCase;
|
import org.briarproject.bramble.BrambleMockTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.contact.Contact;
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
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.briarproject.bramble.api.identity.Author.Status.VERIFIED;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class IdentityManagerImplTest extends BriarMockTestCase {
|
public class IdentityManagerImplTest extends BrambleMockTestCase {
|
||||||
|
|
||||||
private final IdentityManager identityManager;
|
private final IdentityManager identityManager;
|
||||||
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||||
@@ -79,7 +79,7 @@ public class IdentityManagerImplTest extends BriarMockTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetAuthorStatus() throws DbException {
|
public void testGetAuthorStatus() throws DbException {
|
||||||
final AuthorId authorId = new AuthorId(TestUtils.getRandomId());
|
final AuthorId authorId = new AuthorId(TestUtils.getRandomId());
|
||||||
final Collection<Contact> contacts = new ArrayList<>();
|
final Collection<Contact> contacts = new ArrayList<Contact>();
|
||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.keyagreement;
|
package org.briarproject.bramble.keyagreement;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
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.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class KeyAgreementProtocolTest extends BriarTestCase {
|
public class KeyAgreementProtocolTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public JUnitRuleMockery context = new JUnitRuleMockery() {{
|
public JUnitRuleMockery context = new JUnitRuleMockery() {{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.lifecycle;
|
package org.briarproject.bramble.lifecycle;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.bramble.api.lifecycle.ShutdownManager;
|
import org.briarproject.bramble.api.lifecycle.ShutdownManager;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -10,12 +10,12 @@ import java.util.Set;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ShutdownManagerImplTest extends BriarTestCase {
|
public class ShutdownManagerImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddAndRemove() {
|
public void testAddAndRemove() {
|
||||||
ShutdownManager s = createShutdownManager();
|
ShutdownManager s = createShutdownManager();
|
||||||
Set<Integer> handles = new HashSet<>();
|
Set<Integer> handles = new HashSet<Integer>();
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
int handle = s.addShutdownHook(new Runnable() {
|
int handle = s.addShutdownHook(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package org.briarproject.bramble.plugin;
|
package org.briarproject.bramble.plugin;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
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 MIN_INTERVAL = 60 * 1000;
|
||||||
private static final int MAX_INTERVAL = 60 * 60 * 1000;
|
private static final int MAX_INTERVAL = 60 * 60 * 1000;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.plugin;
|
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.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
import org.briarproject.bramble.api.plugin.ConnectionRegistry;
|
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.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class ConnectionRegistryImplTest extends BriarTestCase {
|
public class ConnectionRegistryImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final ContactId contactId, contactId1;
|
private final ContactId contactId, contactId1;
|
||||||
private final TransportId transportId, transportId1;
|
private final TransportId transportId, transportId1;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.plugin;
|
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.event.EventBus;
|
||||||
import org.briarproject.bramble.api.plugin.ConnectionManager;
|
import org.briarproject.bramble.api.plugin.ConnectionManager;
|
||||||
import org.briarproject.bramble.api.plugin.PluginConfig;
|
import org.briarproject.bramble.api.plugin.PluginConfig;
|
||||||
@@ -23,7 +23,7 @@ import java.util.Arrays;
|
|||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
public class PluginManagerImplTest extends BriarTestCase {
|
public class PluginManagerImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStartAndStop() throws Exception {
|
public void testStartAndStop() throws Exception {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.plugin;
|
package org.briarproject.bramble.plugin;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.RunAction;
|
||||||
import org.briarproject.ImmediateExecutor;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.RunAction;
|
import org.briarproject.bramble.ImmediateExecutor;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.contact.event.ContactStatusChangedEvent;
|
import org.briarproject.bramble.api.contact.event.ContactStatusChangedEvent;
|
||||||
import org.briarproject.bramble.api.plugin.ConnectionManager;
|
import org.briarproject.bramble.api.plugin.ConnectionManager;
|
||||||
@@ -32,7 +32,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
|
|
||||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
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 ContactId contactId = new ContactId(234);
|
||||||
private final int pollingInterval = 60 * 1000;
|
private final int pollingInterval = 60 * 1000;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.plugin.tcp;
|
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.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.data.BdfList;
|
import org.briarproject.bramble.api.data.BdfList;
|
||||||
import org.briarproject.bramble.api.keyagreement.KeyAgreementConnection;
|
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.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
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 ContactId contactId = new ContactId(234);
|
||||||
private final Backoff backoff = new TestBackoff();
|
private final Backoff backoff = new TestBackoff();
|
||||||
@@ -194,7 +194,8 @@ public class LanTcpPluginTest extends BriarTestCase {
|
|||||||
plugin.createKeyAgreementListener(new byte[COMMIT_LENGTH]);
|
plugin.createKeyAgreementListener(new byte[COMMIT_LENGTH]);
|
||||||
assertNotNull(kal);
|
assertNotNull(kal);
|
||||||
Callable<KeyAgreementConnection> c = kal.listen();
|
Callable<KeyAgreementConnection> c = kal.listen();
|
||||||
FutureTask<KeyAgreementConnection> f = new FutureTask<>(c);
|
FutureTask<KeyAgreementConnection> f =
|
||||||
|
new FutureTask<KeyAgreementConnection>(c);
|
||||||
new Thread(f).start();
|
new Thread(f).start();
|
||||||
// The plugin should have bound a socket and stored the port number
|
// The plugin should have bound a socket and stored the port number
|
||||||
BdfList descriptor = kal.getDescriptor();
|
BdfList descriptor = kal.getDescriptor();
|
||||||
@@ -290,7 +291,7 @@ public class LanTcpPluginTest extends BriarTestCase {
|
|||||||
private static class Callback implements DuplexPluginCallback {
|
private static class Callback implements DuplexPluginCallback {
|
||||||
|
|
||||||
private final Map<ContactId, TransportProperties> remote =
|
private final Map<ContactId, TransportProperties> remote =
|
||||||
new Hashtable<>();
|
new Hashtable<ContactId, TransportProperties>();
|
||||||
private final CountDownLatch propertiesLatch = new CountDownLatch(1);
|
private final CountDownLatch propertiesLatch = new CountDownLatch(1);
|
||||||
private final CountDownLatch connectionsLatch = new CountDownLatch(1);
|
private final CountDownLatch connectionsLatch = new CountDownLatch(1);
|
||||||
private final TransportProperties local = new TransportProperties();
|
private final TransportProperties local = new TransportProperties();
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package org.briarproject.bramble.properties;
|
package org.briarproject.bramble.properties;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class TransportPropertyManagerImplTest extends BriarTestCase {
|
public class TransportPropertyManagerImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnitTestsExist() {
|
public void testUnitTestsExist() {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.properties;
|
package org.briarproject.bramble.properties;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
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.briarproject.bramble.api.properties.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class TransportPropertyValidatorTest extends BriarTestCase {
|
public class TransportPropertyValidatorTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final TransportId transportId;
|
private final TransportId transportId;
|
||||||
private final BdfDictionary bdfDictionary;
|
private final BdfDictionary bdfDictionary;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.sync;
|
package org.briarproject.bramble.sync;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.UniqueId;
|
import org.briarproject.bramble.api.UniqueId;
|
||||||
import org.briarproject.bramble.util.ByteUtils;
|
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.briarproject.bramble.api.sync.SyncConstants.PACKET_HEADER_LENGTH;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class PacketReaderImplTest extends BriarTestCase {
|
public class PacketReaderImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test(expected = FormatException.class)
|
@Test(expected = FormatException.class)
|
||||||
public void testFormatExceptionIfAckIsTooLarge() throws Exception {
|
public void testFormatExceptionIfAckIsTooLarge() throws Exception {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.sync;
|
package org.briarproject.bramble.sync;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.ImmediateExecutor;
|
import org.briarproject.bramble.ImmediateExecutor;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||||
import org.briarproject.bramble.api.db.Transaction;
|
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;
|
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 Mockery context;
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.sync;
|
package org.briarproject.bramble.sync;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
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.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class SyncIntegrationTest extends BriarTestCase {
|
public class SyncIntegrationTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GroupFactory groupFactory;
|
GroupFactory groupFactory;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.sync;
|
package org.briarproject.bramble.sync;
|
||||||
|
|
||||||
import org.briarproject.TestSeedProviderModule;
|
import org.briarproject.bramble.TestSeedProviderModule;
|
||||||
import org.briarproject.bramble.crypto.CryptoModule;
|
import org.briarproject.bramble.crypto.CryptoModule;
|
||||||
import org.briarproject.bramble.transport.TransportModule;
|
import org.briarproject.bramble.transport.TransportModule;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.sync;
|
package org.briarproject.bramble.sync;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.ImmediateExecutor;
|
import org.briarproject.bramble.ImmediateExecutor;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.UniqueId;
|
import org.briarproject.bramble.api.UniqueId;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
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.PENDING;
|
||||||
import static org.briarproject.bramble.api.sync.ValidationManager.State.UNKNOWN;
|
import static org.briarproject.bramble.api.sync.ValidationManager.State.UNKNOWN;
|
||||||
|
|
||||||
public class ValidationManagerImplTest extends BriarTestCase {
|
public class ValidationManagerImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final ClientId clientId =
|
private final ClientId clientId =
|
||||||
new ClientId(TestUtils.getRandomString(5));
|
new ClientId(TestUtils.getRandomString(5));
|
||||||
@@ -831,7 +831,8 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
context.mock(IncomingMessageHook.class);
|
context.mock(IncomingMessageHook.class);
|
||||||
final MessageId messageId3 = new MessageId(TestUtils.getRandomId());
|
final MessageId messageId3 = new MessageId(TestUtils.getRandomId());
|
||||||
final MessageId messageId4 = 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(messageId1, PENDING);
|
||||||
twoDependents.put(messageId2, PENDING);
|
twoDependents.put(messageId2, PENDING);
|
||||||
final Transaction txn = new Transaction(null, true);
|
final Transaction txn = new Transaction(null, true);
|
||||||
@@ -952,10 +953,12 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
raw);
|
raw);
|
||||||
final Message message4 = new Message(messageId4, groupId, timestamp,
|
final Message message4 = new Message(messageId4, groupId, timestamp,
|
||||||
raw);
|
raw);
|
||||||
final Map<MessageId, State> twoDependents = new LinkedHashMap<>();
|
final Map<MessageId, State> twoDependents =
|
||||||
|
new LinkedHashMap<MessageId, State>();
|
||||||
twoDependents.put(messageId1, PENDING);
|
twoDependents.put(messageId1, PENDING);
|
||||||
twoDependents.put(messageId2, 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(messageId1, DELIVERED);
|
||||||
twoDependencies.put(messageId2, DELIVERED);
|
twoDependencies.put(messageId2, DELIVERED);
|
||||||
final Transaction txn = new Transaction(null, true);
|
final Transaction txn = new Transaction(null, true);
|
||||||
@@ -1117,7 +1120,8 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
final MessageValidator validator = context.mock(MessageValidator.class);
|
final MessageValidator validator = context.mock(MessageValidator.class);
|
||||||
final IncomingMessageHook hook =
|
final IncomingMessageHook hook =
|
||||||
context.mock(IncomingMessageHook.class);
|
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(messageId, DELIVERED);
|
||||||
twoDependencies.put(messageId2, UNKNOWN);
|
twoDependencies.put(messageId2, UNKNOWN);
|
||||||
final Transaction txn = new Transaction(null, true);
|
final Transaction txn = new Transaction(null, true);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.system;
|
package org.briarproject.bramble.system;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.Bytes;
|
import org.briarproject.bramble.api.Bytes;
|
||||||
import org.briarproject.bramble.util.OsUtils;
|
import org.briarproject.bramble.util.OsUtils;
|
||||||
import org.junit.After;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class LinuxSeedProviderTest extends BriarTestCase {
|
public class LinuxSeedProviderTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final File testDir = TestUtils.getTestDirectory();
|
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");
|
System.err.println("WARNING: Skipping test, can't run on this OS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<Bytes> seeds = new HashSet<>();
|
Set<Bytes> seeds = new HashSet<Bytes>();
|
||||||
LinuxSeedProvider p = new LinuxSeedProvider();
|
LinuxSeedProvider p = new LinuxSeedProvider();
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
byte[] seed = p.getSeed();
|
byte[] seed = p.getSeed();
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.transport;
|
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.Contact;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.contact.event.ContactRemovedEvent;
|
import org.briarproject.bramble.api.contact.event.ContactRemovedEvent;
|
||||||
@@ -24,13 +24,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.briarproject.TestUtils.getRandomBytes;
|
import static org.briarproject.bramble.TestUtils.getRandomBytes;
|
||||||
import static org.briarproject.TestUtils.getRandomId;
|
import static org.briarproject.bramble.TestUtils.getRandomId;
|
||||||
import static org.briarproject.TestUtils.getSecretKey;
|
import static org.briarproject.bramble.TestUtils.getSecretKey;
|
||||||
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class KeyManagerImplTest extends BriarTestCase {
|
public class KeyManagerImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final Mockery context = new Mockery();
|
private final Mockery context = new Mockery();
|
||||||
private final KeyManagerImpl keyManager;
|
private final KeyManagerImpl keyManager;
|
||||||
@@ -63,7 +63,7 @@ public class KeyManagerImplTest extends BriarTestCase {
|
|||||||
Author remoteAuthor = new Author(remoteAuthorId, "author",
|
Author remoteAuthor = new Author(remoteAuthorId, "author",
|
||||||
getRandomBytes(42));
|
getRandomBytes(42));
|
||||||
AuthorId localAuthorId = new AuthorId(getRandomId());
|
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,
|
contacts.add(new Contact(contactId, remoteAuthor, localAuthorId, true,
|
||||||
true));
|
true));
|
||||||
contacts.add(new Contact(inactiveContactId, remoteAuthor, localAuthorId,
|
contacts.add(new Contact(inactiveContactId, remoteAuthor, localAuthorId,
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.transport;
|
package org.briarproject.bramble.transport;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.transport.ReorderingWindow.Change;
|
import org.briarproject.bramble.transport.ReorderingWindow.Change;
|
||||||
import org.junit.Test;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
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;
|
private static final int BITMAP_BYTES = REORDERING_WINDOW_SIZE / 8;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.transport;
|
package org.briarproject.bramble.transport;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.bramble.api.crypto.StreamDecrypter;
|
import org.briarproject.bramble.api.crypto.StreamDecrypter;
|
||||||
import org.jmock.Expectations;
|
import org.jmock.Expectations;
|
||||||
import org.jmock.Mockery;
|
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.briarproject.bramble.api.transport.TransportConstants.MAX_PAYLOAD_LENGTH;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class StreamReaderImplTest extends BriarTestCase {
|
public class StreamReaderImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyFramesAreSkipped() throws Exception {
|
public void testEmptyFramesAreSkipped() throws Exception {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.transport;
|
package org.briarproject.bramble.transport;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.crypto.StreamDecrypter;
|
import org.briarproject.bramble.api.crypto.StreamDecrypter;
|
||||||
import org.briarproject.bramble.api.crypto.StreamEncrypter;
|
import org.briarproject.bramble.api.crypto.StreamEncrypter;
|
||||||
import org.junit.Test;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class StreamReaderWriterIntegrationTest extends BriarTestCase {
|
public class StreamReaderWriterIntegrationTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriteAndRead() throws Exception {
|
public void testWriteAndRead() throws Exception {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.transport;
|
package org.briarproject.bramble.transport;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.bramble.api.crypto.StreamEncrypter;
|
import org.briarproject.bramble.api.crypto.StreamEncrypter;
|
||||||
import org.jmock.Expectations;
|
import org.jmock.Expectations;
|
||||||
import org.jmock.Mockery;
|
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.briarproject.bramble.api.transport.TransportConstants.MAX_PAYLOAD_LENGTH;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class StreamWriterImplTest extends BriarTestCase {
|
public class StreamWriterImplTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloseWithoutWritingWritesFinalFrame() throws Exception {
|
public void testCloseWithoutWritingWritesFinalFrame() throws Exception {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.transport;
|
package org.briarproject.bramble.transport;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.RunAction;
|
||||||
import org.briarproject.RunAction;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
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.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
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 TransportId transportId = new TransportId("id");
|
||||||
private final long maxLatency = 30 * 1000; // 30 seconds
|
private final long maxLatency = 30 * 1000; // 30 seconds
|
||||||
@@ -62,7 +62,8 @@ public class TransportKeyManagerImplTest extends BriarTestCase {
|
|||||||
context.mock(ScheduledExecutorService.class);
|
context.mock(ScheduledExecutorService.class);
|
||||||
final Clock clock = context.mock(Clock.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 shouldRotate = createTransportKeys(900, 0);
|
||||||
final TransportKeys shouldNotRotate = createTransportKeys(1000, 0);
|
final TransportKeys shouldNotRotate = createTransportKeys(1000, 0);
|
||||||
loaded.put(contactId, shouldRotate);
|
loaded.put(contactId, shouldRotate);
|
||||||
@@ -341,7 +342,7 @@ public class TransportKeyManagerImplTest extends BriarTestCase {
|
|||||||
final boolean alice = true;
|
final boolean alice = true;
|
||||||
final TransportKeys transportKeys = createTransportKeys(1000, 0);
|
final TransportKeys transportKeys = createTransportKeys(1000, 0);
|
||||||
// Keep a copy of the tags
|
// 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);
|
final Transaction txn = new Transaction(null, false);
|
||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.util;
|
package org.briarproject.bramble.util;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.briarproject.bramble.util.ByteUtils.MAX_16_BIT_UNSIGNED;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class ByteUtilsTest extends BriarTestCase {
|
public class ByteUtilsTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadUint16() {
|
public void testReadUint16() {
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.briarproject.bramble.util;
|
package org.briarproject.bramble.util;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
|
||||||
public class StringUtilsTest extends BriarTestCase {
|
public class StringUtilsTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToHexString() {
|
public void testToHexString() {
|
||||||
@@ -7,4 +7,10 @@ apply plugin: 'witness'
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile project(':bramble-core')
|
compile project(':bramble-core')
|
||||||
compile fileTree(dir: 'libs', include: '*.jar')
|
compile fileTree(dir: 'libs', include: '*.jar')
|
||||||
|
|
||||||
|
testCompile project(path: ':bramble-core', configuration: 'testOutput')
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(Test) {
|
||||||
|
systemProperty 'java.library.path', 'libs'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package org.briarproject.bramble.plugin.file;
|
package org.briarproject.bramble.plugin.file;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class LinuxRemovableDriveFinderTest extends BriarTestCase {
|
public class LinuxRemovableDriveFinderTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseMountPoint() {
|
public void testParseMountPoint() {
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package org.briarproject.bramble.plugin.file;
|
package org.briarproject.bramble.plugin.file;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class MacRemovableDriveFinderTest extends BriarTestCase {
|
public class MacRemovableDriveFinderTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseMountPoint() {
|
public void testParseMountPoint() {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.plugin.file;
|
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.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
|
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
|
||||||
import org.junit.Test;
|
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.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class PollingRemovableDriveMonitorTest extends BriarTestCase {
|
public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOneCallbackPerFile() throws Exception {
|
public void testOneCallbackPerFile() throws Exception {
|
||||||
@@ -41,7 +41,7 @@ public class PollingRemovableDriveMonitorTest extends BriarTestCase {
|
|||||||
};
|
};
|
||||||
// Create a callback that waits for two files
|
// Create a callback that waits for two files
|
||||||
final CountDownLatch latch = new CountDownLatch(2);
|
final CountDownLatch latch = new CountDownLatch(2);
|
||||||
final List<File> detected = new ArrayList<>();
|
final List<File> detected = new ArrayList<File>();
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
Callback callback = new Callback() {
|
Callback callback = new Callback() {
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.bramble.plugin.file;
|
package org.briarproject.bramble.plugin.file;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.ImmediateExecutor;
|
import org.briarproject.bramble.ImmediateExecutor;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
||||||
import org.briarproject.bramble.api.plugin.simplex.SimplexPluginCallback;
|
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.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class RemovableDrivePluginTest extends BriarTestCase {
|
public class RemovableDrivePluginTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final File testDir = TestUtils.getTestDirectory();
|
private final File testDir = TestUtils.getTestDirectory();
|
||||||
private final ContactId contactId = new ContactId(234);
|
private final ContactId contactId = new ContactId(234);
|
||||||
@@ -73,7 +73,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
|
|||||||
public void testWriterIsNullIfNoDriveIsChosen() throws Exception {
|
public void testWriterIsNullIfNoDriveIsChosen() throws Exception {
|
||||||
final File drive1 = new File(testDir, "1");
|
final File drive1 = new File(testDir, "1");
|
||||||
final File drive2 = new File(testDir, "2");
|
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(drive1);
|
||||||
drives.add(drive2);
|
drives.add(drive2);
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
|
|||||||
public void testWriterIsNullIfOutputDirDoesNotExist() throws Exception {
|
public void testWriterIsNullIfOutputDirDoesNotExist() throws Exception {
|
||||||
final File drive1 = new File(testDir, "1");
|
final File drive1 = new File(testDir, "1");
|
||||||
final File drive2 = new File(testDir, "2");
|
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(drive1);
|
||||||
drives.add(drive2);
|
drives.add(drive2);
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
|
|||||||
public void testWriterIsNullIfOutputDirIsAFile() throws Exception {
|
public void testWriterIsNullIfOutputDirIsAFile() throws Exception {
|
||||||
final File drive1 = new File(testDir, "1");
|
final File drive1 = new File(testDir, "1");
|
||||||
final File drive2 = new File(testDir, "2");
|
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(drive1);
|
||||||
drives.add(drive2);
|
drives.add(drive2);
|
||||||
// Create drive1 as a file rather than a directory
|
// Create drive1 as a file rather than a directory
|
||||||
@@ -192,7 +192,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
|
|||||||
public void testWriterIsNotNullIfOutputDirIsADir() throws Exception {
|
public void testWriterIsNotNullIfOutputDirIsADir() throws Exception {
|
||||||
final File drive1 = new File(testDir, "1");
|
final File drive1 = new File(testDir, "1");
|
||||||
final File drive2 = new File(testDir, "2");
|
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(drive1);
|
||||||
drives.add(drive2);
|
drives.add(drive2);
|
||||||
// Create drive1 as a directory
|
// Create drive1 as a directory
|
||||||
@@ -236,7 +236,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
|
|||||||
public void testWritingToWriter() throws Exception {
|
public void testWritingToWriter() throws Exception {
|
||||||
final File drive1 = new File(testDir, "1");
|
final File drive1 = new File(testDir, "1");
|
||||||
final File drive2 = new File(testDir, "2");
|
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(drive1);
|
||||||
drives.add(drive2);
|
drives.add(drive2);
|
||||||
// Create drive1 as a directory
|
// Create drive1 as a directory
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.bramble.plugin.file;
|
package org.briarproject.bramble.plugin.file;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
|
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
|
||||||
import org.briarproject.bramble.util.OsUtils;
|
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.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class UnixRemovableDriveMonitorTest extends BriarTestCase {
|
public class UnixRemovableDriveMonitorTest extends BrambleTestCase {
|
||||||
|
|
||||||
private final File testDir = TestUtils.getTestDirectory();
|
private final File testDir = TestUtils.getTestDirectory();
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public class UnixRemovableDriveMonitorTest extends BriarTestCase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create a callback that will wait for two files before stopping
|
// 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);
|
final CountDownLatch latch = new CountDownLatch(2);
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
final Callback callback = new Callback() {
|
final Callback callback = new Callback() {
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package org.briarproject.bramble.plugin.modem;
|
package org.briarproject.bramble.plugin.modem;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
public class CountryCodesTest extends BriarTestCase {
|
public class CountryCodesTest extends BrambleTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTranslation() {
|
public void testTranslation() {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.bramble.plugin.modem;
|
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.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
|
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
|
||||||
import org.briarproject.bramble.api.properties.TransportProperties;
|
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.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
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 ISO_1336 = "GB";
|
||||||
private static final String NUMBER = "0123456789";
|
private static final String NUMBER = "0123456789";
|
||||||
@@ -30,14 +30,13 @@ dependencies {
|
|||||||
compile 'info.guardianproject.trustedintents:trustedintents:0.2'
|
compile 'info.guardianproject.trustedintents:trustedintents:0.2'
|
||||||
compile 'de.hdodenhof:circleimageview:2.1.0'
|
compile 'de.hdodenhof:circleimageview:2.1.0'
|
||||||
compile 'com.google.zxing:core:3.2.1'
|
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'
|
provided 'javax.annotation:jsr250-api:1.0'
|
||||||
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
|
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
|
||||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||||
compile 'uk.co.samuelwall:material-tap-target-prompt:1.3.0'
|
compile 'uk.co.samuelwall:material-tap-target-prompt:1.3.0'
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile project(path: ':bramble-core', configuration: 'testOutput')
|
||||||
testCompile project(path: ':briar-tests')
|
|
||||||
testCompile 'org.robolectric:robolectric:3.0'
|
testCompile 'org.robolectric:robolectric:3.0'
|
||||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import android.content.Intent;
|
|||||||
|
|
||||||
import junit.framework.Assert;
|
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.db.DbException;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
|
|||||||
1
briar-core/.gitignore
vendored
1
briar-core/.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
bin
|
bin
|
||||||
build
|
build
|
||||||
|
test.tmp
|
||||||
.settings
|
.settings
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ dependencies {
|
|||||||
compile 'com.squareup.okhttp3:okhttp:3.3.1'
|
compile 'com.squareup.okhttp3:okhttp:3.3.1'
|
||||||
compile 'org.jsoup:jsoup:1.9.2'
|
compile 'org.jsoup:jsoup:1.9.2'
|
||||||
|
|
||||||
testCompile project(':briar-tests') // TODO remove when moving unit tests (#778)
|
testCompile project(':bramble-core') // TODO get rid of this dependency
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
|
testCompile project(path: ':bramble-api', configuration: 'testOutput')
|
||||||
testCompile 'net.jodah:concurrentunit:0.4.2'
|
testCompile 'net.jodah:concurrentunit:0.4.2'
|
||||||
testCompile 'com.google.dagger:dagger-compiler:2.8'
|
|
||||||
testApt 'com.google.dagger:dagger-compiler:2.8'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyVerification {
|
dependencyVerification {
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package org.briarproject.briar;
|
|||||||
|
|
||||||
import net.jodah.concurrentunit.Waiter;
|
import net.jodah.concurrentunit.Waiter;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.TestUtils;
|
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.client.ContactGroupFactory;
|
import org.briarproject.bramble.api.client.ContactGroupFactory;
|
||||||
import org.briarproject.bramble.api.contact.Contact;
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
@@ -60,11 +59,11 @@ import javax.annotation.Nullable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
import static org.briarproject.TestPluginConfigModule.MAX_LATENCY;
|
import static org.briarproject.bramble.TestUtils.getSecretKey;
|
||||||
import static org.briarproject.TestUtils.getSecretKey;
|
|
||||||
import static org.briarproject.bramble.api.sync.ValidationManager.State.DELIVERED;
|
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.INVALID;
|
||||||
import static org.briarproject.bramble.api.sync.ValidationManager.State.PENDING;
|
import static org.briarproject.bramble.api.sync.ValidationManager.State.PENDING;
|
||||||
|
import static org.briarproject.briar.TestPluginConfigModule.MAX_LATENCY;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package org.briarproject.briar;
|
package org.briarproject.briar;
|
||||||
|
|
||||||
import org.briarproject.TestDatabaseModule;
|
import org.briarproject.bramble.TestDatabaseModule;
|
||||||
import org.briarproject.TestPluginConfigModule;
|
import org.briarproject.bramble.TestSeedProviderModule;
|
||||||
import org.briarproject.TestSeedProviderModule;
|
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.contact.ContactManager;
|
import org.briarproject.bramble.api.contact.ContactManager;
|
||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.briarproject.briar;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.BrambleTestCase;
|
||||||
|
|
||||||
|
public abstract class BriarTestCase extends BrambleTestCase {
|
||||||
|
|
||||||
|
public BriarTestCase() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.briar;
|
||||||
|
|
||||||
import org.hamcrest.Description;
|
import org.hamcrest.Description;
|
||||||
import org.jmock.api.Action;
|
import org.jmock.api.Action;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.briar;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject;
|
package org.briarproject.briar;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.plugin.PluginConfig;
|
import org.briarproject.bramble.api.plugin.PluginConfig;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.briar.blog;
|
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.FormatException;
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.contact.Contact;
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
@@ -34,8 +34,8 @@ import org.junit.Test;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.briarproject.TestUtils.getRandomBytes;
|
import static org.briarproject.bramble.TestUtils.getRandomBytes;
|
||||||
import static org.briarproject.TestUtils.getRandomId;
|
import static org.briarproject.bramble.TestUtils.getRandomId;
|
||||||
import static org.briarproject.bramble.api.identity.Author.Status.VERIFIED;
|
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.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.briar.blog;
|
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.db.DbException;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.BriarIntegrationTest;
|
import org.briarproject.briar.BriarIntegrationTest;
|
||||||
@@ -21,7 +21,7 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
import static junit.framework.Assert.assertFalse;
|
import static junit.framework.Assert.assertFalse;
|
||||||
import static junit.framework.Assert.assertNotNull;
|
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.COMMENT;
|
||||||
import static org.briarproject.briar.api.blog.MessageType.POST;
|
import static org.briarproject.briar.api.blog.MessageType.POST;
|
||||||
import static org.briarproject.briar.api.blog.MessageType.WRAPPED_COMMENT;
|
import static org.briarproject.briar.api.blog.MessageType.WRAPPED_COMMENT;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.briar.blog;
|
package org.briarproject.briar.blog;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.briar.BriarTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.briarproject.briar.client;
|
package org.briarproject.briar.client;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.briar.BriarTestCase;
|
||||||
import org.briarproject.CaptureArgumentAction;
|
import org.briarproject.briar.CaptureArgumentAction;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||||
import org.briarproject.bramble.api.data.BdfList;
|
import org.briarproject.bramble.api.data.BdfList;
|
||||||
@@ -130,7 +130,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.mock(ValidationManager.class);
|
context.mock(ValidationManager.class);
|
||||||
|
|
||||||
final AtomicReference<MessageValidator> captured =
|
final AtomicReference<MessageValidator> captured =
|
||||||
new AtomicReference<>();
|
new AtomicReference<MessageValidator>();
|
||||||
final QueueMessageValidator queueMessageValidator =
|
final QueueMessageValidator queueMessageValidator =
|
||||||
context.mock(QueueMessageValidator.class);
|
context.mock(QueueMessageValidator.class);
|
||||||
// The message is too short to be a valid queue message
|
// The message is too short to be a valid queue message
|
||||||
@@ -141,7 +141,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(validationManager).registerMessageValidator(with(clientId),
|
oneOf(validationManager).registerMessageValidator(with(clientId),
|
||||||
with(any(MessageValidator.class)));
|
with(any(MessageValidator.class)));
|
||||||
will(new CaptureArgumentAction<>(captured,
|
will(new CaptureArgumentAction<MessageValidator>(captured,
|
||||||
MessageValidator.class, 1));
|
MessageValidator.class, 1));
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.mock(ValidationManager.class);
|
context.mock(ValidationManager.class);
|
||||||
|
|
||||||
final AtomicReference<MessageValidator> captured =
|
final AtomicReference<MessageValidator> captured =
|
||||||
new AtomicReference<>();
|
new AtomicReference<MessageValidator>();
|
||||||
final QueueMessageValidator queueMessageValidator =
|
final QueueMessageValidator queueMessageValidator =
|
||||||
context.mock(QueueMessageValidator.class);
|
context.mock(QueueMessageValidator.class);
|
||||||
// The message has a negative queue position
|
// The message has a negative queue position
|
||||||
@@ -187,7 +187,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(validationManager).registerMessageValidator(with(clientId),
|
oneOf(validationManager).registerMessageValidator(with(clientId),
|
||||||
with(any(MessageValidator.class)));
|
with(any(MessageValidator.class)));
|
||||||
will(new CaptureArgumentAction<>(captured,
|
will(new CaptureArgumentAction<MessageValidator>(captured,
|
||||||
MessageValidator.class, 1));
|
MessageValidator.class, 1));
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.mock(ValidationManager.class);
|
context.mock(ValidationManager.class);
|
||||||
|
|
||||||
final AtomicReference<MessageValidator> captured =
|
final AtomicReference<MessageValidator> captured =
|
||||||
new AtomicReference<>();
|
new AtomicReference<MessageValidator>();
|
||||||
final QueueMessageValidator queueMessageValidator =
|
final QueueMessageValidator queueMessageValidator =
|
||||||
context.mock(QueueMessageValidator.class);
|
context.mock(QueueMessageValidator.class);
|
||||||
final Metadata metadata = new Metadata();
|
final Metadata metadata = new Metadata();
|
||||||
@@ -234,7 +234,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(validationManager).registerMessageValidator(with(clientId),
|
oneOf(validationManager).registerMessageValidator(with(clientId),
|
||||||
with(any(MessageValidator.class)));
|
with(any(MessageValidator.class)));
|
||||||
will(new CaptureArgumentAction<>(captured,
|
will(new CaptureArgumentAction<MessageValidator>(captured,
|
||||||
MessageValidator.class, 1));
|
MessageValidator.class, 1));
|
||||||
// The message should be delegated
|
// The message should be delegated
|
||||||
oneOf(queueMessageValidator).validateMessage(
|
oneOf(queueMessageValidator).validateMessage(
|
||||||
@@ -267,7 +267,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
final ValidationManager validationManager =
|
final ValidationManager validationManager =
|
||||||
context.mock(ValidationManager.class);
|
context.mock(ValidationManager.class);
|
||||||
final AtomicReference<IncomingMessageHook> captured =
|
final AtomicReference<IncomingMessageHook> captured =
|
||||||
new AtomicReference<>();
|
new AtomicReference<IncomingMessageHook>();
|
||||||
final IncomingQueueMessageHook incomingQueueMessageHook =
|
final IncomingQueueMessageHook incomingQueueMessageHook =
|
||||||
context.mock(IncomingQueueMessageHook.class);
|
context.mock(IncomingQueueMessageHook.class);
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
||||||
with(any(IncomingMessageHook.class)));
|
with(any(IncomingMessageHook.class)));
|
||||||
will(new CaptureArgumentAction<>(captured,
|
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
|
||||||
IncomingMessageHook.class, 1));
|
IncomingMessageHook.class, 1));
|
||||||
oneOf(db).getGroupMetadata(txn, groupId);
|
oneOf(db).getGroupMetadata(txn, groupId);
|
||||||
will(returnValue(groupMetadata));
|
will(returnValue(groupMetadata));
|
||||||
@@ -319,7 +319,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
final ValidationManager validationManager =
|
final ValidationManager validationManager =
|
||||||
context.mock(ValidationManager.class);
|
context.mock(ValidationManager.class);
|
||||||
final AtomicReference<IncomingMessageHook> captured =
|
final AtomicReference<IncomingMessageHook> captured =
|
||||||
new AtomicReference<>();
|
new AtomicReference<IncomingMessageHook>();
|
||||||
final IncomingQueueMessageHook incomingQueueMessageHook =
|
final IncomingQueueMessageHook incomingQueueMessageHook =
|
||||||
context.mock(IncomingQueueMessageHook.class);
|
context.mock(IncomingQueueMessageHook.class);
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
||||||
with(any(IncomingMessageHook.class)));
|
with(any(IncomingMessageHook.class)));
|
||||||
will(new CaptureArgumentAction<>(captured,
|
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
|
||||||
IncomingMessageHook.class, 1));
|
IncomingMessageHook.class, 1));
|
||||||
oneOf(db).getGroupMetadata(txn, groupId);
|
oneOf(db).getGroupMetadata(txn, groupId);
|
||||||
will(returnValue(groupMetadata));
|
will(returnValue(groupMetadata));
|
||||||
@@ -375,7 +375,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
final ValidationManager validationManager =
|
final ValidationManager validationManager =
|
||||||
context.mock(ValidationManager.class);
|
context.mock(ValidationManager.class);
|
||||||
final AtomicReference<IncomingMessageHook> captured =
|
final AtomicReference<IncomingMessageHook> captured =
|
||||||
new AtomicReference<>();
|
new AtomicReference<IncomingMessageHook>();
|
||||||
final IncomingQueueMessageHook incomingQueueMessageHook =
|
final IncomingQueueMessageHook incomingQueueMessageHook =
|
||||||
context.mock(IncomingQueueMessageHook.class);
|
context.mock(IncomingQueueMessageHook.class);
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
||||||
with(any(IncomingMessageHook.class)));
|
with(any(IncomingMessageHook.class)));
|
||||||
will(new CaptureArgumentAction<>(captured,
|
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
|
||||||
IncomingMessageHook.class, 1));
|
IncomingMessageHook.class, 1));
|
||||||
oneOf(db).getGroupMetadata(txn, groupId);
|
oneOf(db).getGroupMetadata(txn, groupId);
|
||||||
will(returnValue(groupMetadata));
|
will(returnValue(groupMetadata));
|
||||||
@@ -433,7 +433,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
final ValidationManager validationManager =
|
final ValidationManager validationManager =
|
||||||
context.mock(ValidationManager.class);
|
context.mock(ValidationManager.class);
|
||||||
final AtomicReference<IncomingMessageHook> captured =
|
final AtomicReference<IncomingMessageHook> captured =
|
||||||
new AtomicReference<>();
|
new AtomicReference<IncomingMessageHook>();
|
||||||
final IncomingQueueMessageHook incomingQueueMessageHook =
|
final IncomingQueueMessageHook incomingQueueMessageHook =
|
||||||
context.mock(IncomingQueueMessageHook.class);
|
context.mock(IncomingQueueMessageHook.class);
|
||||||
|
|
||||||
@@ -457,7 +457,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
|
||||||
with(any(IncomingMessageHook.class)));
|
with(any(IncomingMessageHook.class)));
|
||||||
will(new CaptureArgumentAction<>(captured,
|
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
|
||||||
IncomingMessageHook.class, 1));
|
IncomingMessageHook.class, 1));
|
||||||
oneOf(db).getGroupMetadata(txn, groupId);
|
oneOf(db).getGroupMetadata(txn, groupId);
|
||||||
will(returnValue(groupMetadata));
|
will(returnValue(groupMetadata));
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.briar.client;
|
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.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.client.MessageTree;
|
import org.briarproject.briar.api.client.MessageTree;
|
||||||
@@ -19,7 +19,7 @@ public class MessageTreeImplTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMessageTree() {
|
public void testMessageTree() {
|
||||||
tree = new MessageTreeImpl<>();
|
tree = new MessageTreeImpl<TestNode>();
|
||||||
testSimpleTree();
|
testSimpleTree();
|
||||||
tree.clear();
|
tree.clear();
|
||||||
testSimpleTree();
|
testSimpleTree();
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.briar.forum;
|
package org.briarproject.briar.forum;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.briar.BriarTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.briarproject.briar.forum;
|
package org.briarproject.briar.forum;
|
||||||
|
|
||||||
import org.briarproject.TestDatabaseModule;
|
import org.briarproject.bramble.TestDatabaseModule;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.briar.BriarIntegrationTest;
|
import org.briarproject.briar.BriarIntegrationTest;
|
||||||
import org.briarproject.briar.BriarIntegrationTestComponent;
|
import org.briarproject.briar.BriarIntegrationTestComponent;
|
||||||
@@ -17,7 +17,7 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.briar.forum;
|
package org.briarproject.briar.forum;
|
||||||
|
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.ValidatorTestCase;
|
import org.briarproject.bramble.ValidatorTestCase;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.UniqueId;
|
import org.briarproject.bramble.api.UniqueId;
|
||||||
import org.briarproject.bramble.api.client.BdfMessageContext;
|
import org.briarproject.bramble.api.client.BdfMessageContext;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.briarproject.briar.introduction;
|
package org.briarproject.briar.introduction;
|
||||||
|
|
||||||
import org.briarproject.BriarTestCase;
|
import org.briarproject.briar.BriarTestCase;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.bramble.TestUtils;
|
||||||
import org.briarproject.bramble.api.Bytes;
|
import org.briarproject.bramble.api.Bytes;
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.client.ClientHelper;
|
import org.briarproject.bramble.api.client.ClientHelper;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user