mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 23:29:52 +01:00
Compare commits
51 Commits
752-780-ac
...
851-recycl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb6037d42d | ||
|
|
3ce0131b8c | ||
|
|
008e4f760a | ||
|
|
fc44268b22 | ||
|
|
de0a7c75ed | ||
|
|
1c6be2fb78 | ||
|
|
09b0a8b161 | ||
|
|
a6d053a0ea | ||
|
|
e7a26c42a4 | ||
|
|
bb5fc35e17 | ||
|
|
ea4e2f09c8 | ||
|
|
ffc9fdbb92 | ||
|
|
074f5c2faf | ||
|
|
ab3fcb6219 | ||
|
|
b7e35ff780 | ||
|
|
3c2428449d | ||
|
|
25a4caec2a | ||
|
|
1081a08ea9 | ||
|
|
32be148c7a | ||
|
|
78000375df | ||
|
|
66f8978bb6 | ||
|
|
45b5040254 | ||
|
|
378a8f0a10 | ||
|
|
562866494b | ||
|
|
c9cb085a0a | ||
|
|
97d4c68f43 | ||
|
|
4226ba40c2 | ||
|
|
3df3d19a07 | ||
|
|
e3dcc62509 | ||
|
|
db3c3eee44 | ||
|
|
5a522d64df | ||
|
|
68b216d580 | ||
|
|
d5c6fcc85b | ||
|
|
a099104d08 | ||
|
|
787b3399f7 | ||
|
|
4e159bbb1f | ||
|
|
7c6232db9d | ||
|
|
6cf1480d2d | ||
|
|
2679e6932f | ||
|
|
17e149e517 | ||
|
|
d04dda1566 | ||
|
|
5588855667 | ||
|
|
7df6abbcbe | ||
|
|
001f5faeaa | ||
|
|
ba1a19d236 | ||
|
|
b7ce7de42a | ||
|
|
3f6a8f9341 | ||
|
|
9495163016 | ||
|
|
7f5a5d40dc | ||
|
|
98dd8ec7f7 | ||
|
|
81337fe7ad |
@@ -18,6 +18,7 @@ import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.Backoff;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
|
||||
@@ -128,7 +129,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() throws IOException {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
// BluetoothAdapter.getDefaultAdapter() must be called on a thread
|
||||
// with a message queue, so submit it to the AndroidExecutor
|
||||
@@ -142,13 +143,14 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
}).get();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IOException("Interrupted while getting BluetoothAdapter");
|
||||
LOG.warning("Interrupted while getting BluetoothAdapter");
|
||||
throw new PluginException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new IOException(e);
|
||||
throw new PluginException(e);
|
||||
}
|
||||
if (adapter == null) {
|
||||
LOG.info("Bluetooth is not supported");
|
||||
return false;
|
||||
throw new PluginException();
|
||||
}
|
||||
running = true;
|
||||
// Listen for changes to the Bluetooth state
|
||||
@@ -170,7 +172,6 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
LOG.info("Not enabling Bluetooth");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void bind() {
|
||||
|
||||
@@ -39,14 +39,13 @@ class AndroidLanTcpPlugin extends LanTcpPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
public void start() {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
running = true;
|
||||
// Register to receive network status events
|
||||
networkStateReceiver = new NetworkStateReceiver();
|
||||
IntentFilter filter = new IntentFilter(CONNECTIVITY_ACTION);
|
||||
appContext.registerReceiver(networkStateReceiver, filter);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.Backoff;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TorConstants;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||
@@ -162,14 +163,18 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() throws IOException {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
// Install or update the assets if necessary
|
||||
if (!assetsAreUpToDate()) installAssets();
|
||||
LOG.info("Starting Tor");
|
||||
// Watch for the auth cookie file being updated
|
||||
cookieFile.getParentFile().mkdirs();
|
||||
cookieFile.createNewFile();
|
||||
try {
|
||||
cookieFile.getParentFile().mkdirs();
|
||||
cookieFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
FileObserver obs = new WriteObserver(cookieFile, latch);
|
||||
obs.startWatching();
|
||||
@@ -182,8 +187,8 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
Process torProcess;
|
||||
try {
|
||||
torProcess = Runtime.getRuntime().exec(cmd, env, torDirectory);
|
||||
} catch (SecurityException e) {
|
||||
throw new IOException(e);
|
||||
} catch (SecurityException | IOException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
// Log the process's standard output until it detaches
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
@@ -197,35 +202,39 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
if (exit != 0) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.warning("Tor exited with value " + exit);
|
||||
return false;
|
||||
throw new PluginException();
|
||||
}
|
||||
// Wait for the auth cookie file to be created/updated
|
||||
if (!latch.await(COOKIE_TIMEOUT, MILLISECONDS)) {
|
||||
LOG.warning("Auth cookie not created");
|
||||
if (LOG.isLoggable(INFO)) listFiles(torDirectory);
|
||||
return false;
|
||||
throw new PluginException();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
LOG.warning("Interrupted while starting Tor");
|
||||
Thread.currentThread().interrupt();
|
||||
return false;
|
||||
throw new PluginException();
|
||||
}
|
||||
// Open a control connection and authenticate using the cookie file
|
||||
controlSocket = new Socket("127.0.0.1", CONTROL_PORT);
|
||||
controlConnection = new TorControlConnection(controlSocket);
|
||||
controlConnection.authenticate(read(cookieFile));
|
||||
// Tell Tor to exit when the control connection is closed
|
||||
controlConnection.takeOwnership();
|
||||
controlConnection.resetConf(Collections.singletonList(OWNER));
|
||||
running = true;
|
||||
// Register to receive events from the Tor process
|
||||
controlConnection.setEventHandler(this);
|
||||
controlConnection.setEvents(Arrays.asList(EVENTS));
|
||||
// Check whether Tor has already bootstrapped
|
||||
String phase = controlConnection.getInfo("status/bootstrap-phase");
|
||||
if (phase != null && phase.contains("PROGRESS=100")) {
|
||||
LOG.info("Tor has already bootstrapped");
|
||||
connectionStatus.setBootstrapped();
|
||||
try {
|
||||
// Open a control connection and authenticate using the cookie file
|
||||
controlSocket = new Socket("127.0.0.1", CONTROL_PORT);
|
||||
controlConnection = new TorControlConnection(controlSocket);
|
||||
controlConnection.authenticate(read(cookieFile));
|
||||
// Tell Tor to exit when the control connection is closed
|
||||
controlConnection.takeOwnership();
|
||||
controlConnection.resetConf(Collections.singletonList(OWNER));
|
||||
running = true;
|
||||
// Register to receive events from the Tor process
|
||||
controlConnection.setEventHandler(this);
|
||||
controlConnection.setEvents(Arrays.asList(EVENTS));
|
||||
// Check whether Tor has already bootstrapped
|
||||
String phase = controlConnection.getInfo("status/bootstrap-phase");
|
||||
if (phase != null && phase.contains("PROGRESS=100")) {
|
||||
LOG.info("Tor has already bootstrapped");
|
||||
connectionStatus.setBootstrapped();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
// Register to receive network status events
|
||||
networkStateReceiver = new NetworkStateReceiver();
|
||||
@@ -233,7 +242,6 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
appContext.registerReceiver(networkStateReceiver, filter);
|
||||
// Bind a server socket to receive incoming hidden service connections
|
||||
bind();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean assetsAreUpToDate() {
|
||||
@@ -246,7 +254,7 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void installAssets() throws IOException {
|
||||
private void installAssets() throws PluginException {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
@@ -269,7 +277,7 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
} catch (IOException e) {
|
||||
tryToClose(in);
|
||||
tryToClose(out);
|
||||
throw e;
|
||||
throw new PluginException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,7 +484,7 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws IOException {
|
||||
public void stop() throws PluginException {
|
||||
running = false;
|
||||
tryToClose(socket);
|
||||
if (networkStateReceiver != null)
|
||||
|
||||
@@ -8,15 +8,34 @@ dependencies {
|
||||
compile "com.google.dagger:dagger:2.0.2"
|
||||
compile 'com.google.dagger:dagger-compiler:2.0.2'
|
||||
compile 'com.google.code.findbugs:jsr305:3.0.1'
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile "org.jmock:jmock:2.8.1"
|
||||
testCompile "org.jmock:jmock-junit4:2.8.1"
|
||||
testCompile "org.jmock:jmock-legacy:2.8.1"
|
||||
testCompile "org.hamcrest:hamcrest-library:1.3"
|
||||
testCompile "org.hamcrest:hamcrest-core:1.3"
|
||||
}
|
||||
|
||||
dependencyVerification {
|
||||
verify = [
|
||||
'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9',
|
||||
'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3',
|
||||
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd',
|
||||
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
||||
'com.google.dagger:dagger-producers:99ec15e8a0507ba569e7655bc1165ee5e5ca5aa914b3c8f7e2c2458f724edd6b',
|
||||
'com.google.guava:guava:d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99',
|
||||
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd'
|
||||
]
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -43,6 +43,24 @@ public interface ContactManager {
|
||||
*/
|
||||
Contact getContact(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the contact with the given remoteAuthorId
|
||||
* that was added by the LocalAuthor with the given localAuthorId
|
||||
*
|
||||
* @throws org.briarproject.bramble.api.db.NoSuchContactException
|
||||
*/
|
||||
Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the contact with the given remoteAuthorId
|
||||
* that was added by the LocalAuthor with the given localAuthorId
|
||||
*
|
||||
* @throws org.briarproject.bramble.api.db.NoSuchContactException
|
||||
*/
|
||||
Contact getContact(Transaction txn, AuthorId remoteAuthorId,
|
||||
AuthorId localAuthorId) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all active contacts.
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.briarproject.bramble.api.plugin;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
@NotNullByDefault
|
||||
@@ -25,14 +24,14 @@ public interface Plugin {
|
||||
int getMaxIdleTime();
|
||||
|
||||
/**
|
||||
* Starts the plugin and returns true if it started successfully.
|
||||
* Starts the plugin.
|
||||
*/
|
||||
boolean start() throws IOException;
|
||||
void start() throws PluginException;
|
||||
|
||||
/**
|
||||
* Stops the plugin.
|
||||
*/
|
||||
void stop() throws IOException;
|
||||
void stop() throws PluginException;
|
||||
|
||||
/**
|
||||
* Returns true if the plugin is running.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.briarproject.bramble.api.plugin;
|
||||
|
||||
/**
|
||||
* An exception that indicates an error starting or stopping a {@link Plugin}.
|
||||
*/
|
||||
public class PluginException extends Exception {
|
||||
|
||||
public PluginException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PluginException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.briarproject.bramble.data;
|
||||
package org.briarproject.bramble.api.data;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.Bytes;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.BdfEntry;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -15,7 +13,7 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BdfDictionaryTest extends BriarTestCase {
|
||||
public class BdfDictionaryTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testConstructors() {
|
||||
@@ -1,11 +1,8 @@
|
||||
package org.briarproject.bramble.data;
|
||||
package org.briarproject.bramble.api.data;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.Bytes;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.BdfEntry;
|
||||
import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -15,7 +12,7 @@ import static org.briarproject.bramble.api.data.BdfDictionary.NULL_VALUE;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class BdfListTest extends BriarTestCase {
|
||||
public class BdfListTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testConstructors() {
|
||||
@@ -1,9 +1,10 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.After;
|
||||
|
||||
public abstract class BriarMockTestCase extends BriarTestCase {
|
||||
public abstract class BrambleMockTestCase extends
|
||||
BrambleTestCase {
|
||||
|
||||
protected final Mockery context = new Mockery();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public abstract class BriarTestCase {
|
||||
public abstract class BrambleTestCase {
|
||||
|
||||
public BriarTestCase() {
|
||||
public BrambleTestCase() {
|
||||
// Ensure exceptions thrown on worker threads cause tests to fail
|
||||
UncaughtExceptionHandler fail = new UncaughtExceptionHandler() {
|
||||
@Override
|
||||
@@ -1,19 +1,13 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.UniqueId;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.util.IoUtils;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestUtils {
|
||||
|
||||
private static final AtomicInteger nextTestDir =
|
||||
@@ -51,19 +45,4 @@ public class TestUtils {
|
||||
return new SecretKey(getRandomBytes(SecretKey.LENGTH));
|
||||
}
|
||||
|
||||
public static void assertGroupCount(MessageTracker tracker, GroupId g,
|
||||
long msgCount, long unreadCount, long latestMsgTime)
|
||||
throws DbException {
|
||||
GroupCount groupCount = tracker.getGroupCount(g);
|
||||
assertEquals(msgCount, groupCount.getMsgCount());
|
||||
assertEquals(unreadCount, groupCount.getUnreadCount());
|
||||
assertEquals(latestMsgTime, groupCount.getLatestMsgTime());
|
||||
}
|
||||
|
||||
public static void assertGroupCount(MessageTracker tracker, GroupId g,
|
||||
long msgCount, long unreadCount) throws DbException {
|
||||
GroupCount c1 = tracker.getGroupCount(g);
|
||||
assertEquals(msgCount, c1.getMsgCount());
|
||||
assertEquals(unreadCount, c1.getUnreadCount());
|
||||
}
|
||||
}
|
||||
1
bramble-core/.gitignore
vendored
1
bramble-core/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
bin
|
||||
build
|
||||
test.tmp
|
||||
.settings
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
apply plugin: 'java'
|
||||
plugins {
|
||||
id "java"
|
||||
id "net.ltgt.apt" version "0.9"
|
||||
id "idea"
|
||||
}
|
||||
sourceCompatibility = 1.6
|
||||
targetCompatibility = 1.6
|
||||
|
||||
@@ -9,6 +13,8 @@ dependencies {
|
||||
compile fileTree(dir: 'libs', include: '*.jar')
|
||||
compile 'com.madgag.spongycastle:core:1.54.0.0'
|
||||
compile 'com.h2database:h2:1.4.190'
|
||||
|
||||
testCompile project(path: ':bramble-api', configuration: 'testOutput')
|
||||
}
|
||||
|
||||
dependencyVerification {
|
||||
@@ -17,3 +23,15 @@ dependencyVerification {
|
||||
'com.h2database:h2:23ba495a07bbbb3bd6c3084d10a96dad7a23741b8b6d64b213459a784195a98c'
|
||||
]
|
||||
}
|
||||
|
||||
// needed to make test output available to bramble-j2se
|
||||
configurations {
|
||||
testOutput.extendsFrom(testCompile)
|
||||
}
|
||||
task jarTest(type: Jar, dependsOn: testClasses) {
|
||||
from sourceSets.test.output
|
||||
classifier = 'test'
|
||||
}
|
||||
artifacts {
|
||||
testOutput jarTest
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.contact.ContactManager;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.NoSuchContactException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
@@ -88,6 +89,32 @@ class ContactManagerImpl implements ContactManager {
|
||||
return contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
||||
throws DbException {
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
Contact c = getContact(txn, remoteAuthorId, localAuthorId);
|
||||
db.commitTransaction(txn);
|
||||
return c;
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contact getContact(Transaction txn, AuthorId remoteAuthorId,
|
||||
AuthorId localAuthorId) throws DbException {
|
||||
Collection<Contact> contacts =
|
||||
db.getContactsByAuthorId(txn, remoteAuthorId);
|
||||
for (Contact c : contacts) {
|
||||
if (c.getLocalAuthorId().equals(localAuthorId)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
throw new NoSuchContactException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Contact> getActiveContacts() throws DbException {
|
||||
Collection<Contact> contacts;
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.briarproject.bramble.api.plugin.ConnectionManager;
|
||||
import org.briarproject.bramble.api.plugin.Plugin;
|
||||
import org.briarproject.bramble.api.plugin.PluginCallback;
|
||||
import org.briarproject.bramble.api.plugin.PluginConfig;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.PluginManager;
|
||||
import org.briarproject.bramble.api.plugin.TransportConnectionReader;
|
||||
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
||||
@@ -30,7 +31,6 @@ import org.briarproject.bramble.api.settings.Settings;
|
||||
import org.briarproject.bramble.api.settings.SettingsManager;
|
||||
import org.briarproject.bramble.api.ui.UiCallback;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -193,24 +193,17 @@ class PluginManagerImpl implements PluginManager, Service {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
boolean started = plugin.start();
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
if (started) {
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
LOG.info("Starting plugin " + plugin.getId()
|
||||
+ " took " + duration + " ms");
|
||||
}
|
||||
} else {
|
||||
if (LOG.isLoggable(WARNING)) {
|
||||
LOG.warning("Plugin" + plugin.getId()
|
||||
+ " did not start");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
long start = System.currentTimeMillis();
|
||||
plugin.start();
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
LOG.info("Starting plugin " + plugin.getId() + " took " +
|
||||
duration + " ms");
|
||||
}
|
||||
} catch (PluginException e) {
|
||||
if (LOG.isLoggable(WARNING)) {
|
||||
LOG.warning("Plugin " + plugin.getId() + " did not start");
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
} finally {
|
||||
startLatch.countDown();
|
||||
@@ -246,10 +239,13 @@ class PluginManagerImpl implements PluginManager, Service {
|
||||
+ " took " + duration + " ms");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
LOG.warning("Interrupted while waiting for plugin to start");
|
||||
LOG.warning("Interrupted while waiting for plugin to stop");
|
||||
// This task runs on an executor, so don't reset the interrupt
|
||||
} catch (IOException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
} catch (PluginException e) {
|
||||
if (LOG.isLoggable(WARNING)) {
|
||||
LOG.warning("Plugin " + plugin.getId() + " did not stop");
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
} finally {
|
||||
stopLatch.countDown();
|
||||
}
|
||||
|
||||
@@ -101,11 +101,10 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
public void start() {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
running = true;
|
||||
bind();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void bind() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.client;
|
||||
|
||||
import org.briarproject.ValidatorTestCase;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.client.BdfMessageContext;
|
||||
import org.briarproject.bramble.api.client.BdfMessageValidator;
|
||||
@@ -12,6 +11,7 @@ import org.briarproject.bramble.api.sync.Group;
|
||||
import org.briarproject.bramble.api.sync.InvalidMessageException;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageContext;
|
||||
import org.briarproject.bramble.test.ValidatorTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.lib.legacy.ClassImposteriser;
|
||||
import org.junit.Test;
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.bramble.client;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
@@ -21,6 +19,8 @@ import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageFactory;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -32,13 +32,13 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.briarproject.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.TestUtils.getRandomId;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ClientHelperImplTest extends BriarTestCase {
|
||||
public class ClientHelperImplTest extends BrambleTestCase {
|
||||
|
||||
private final Mockery context = new Mockery();
|
||||
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
@@ -165,7 +165,8 @@ public class ClientHelperImplTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetMessageMetadataAsDictionaryMap() throws Exception {
|
||||
final Map<MessageId, BdfDictionary> map = new HashMap<>();
|
||||
final Map<MessageId, BdfDictionary> map =
|
||||
new HashMap<MessageId, BdfDictionary>();
|
||||
map.put(messageId, dictionary);
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
|
||||
@@ -187,7 +188,8 @@ public class ClientHelperImplTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetMessageMetadataAsDictionaryQuery() throws Exception {
|
||||
final Map<MessageId, BdfDictionary> map = new HashMap<>();
|
||||
final Map<MessageId, BdfDictionary> map =
|
||||
new HashMap<MessageId, BdfDictionary>();
|
||||
map.put(messageId, dictionary);
|
||||
final BdfDictionary query =
|
||||
BdfDictionary.of(new BdfEntry("query", "me"));
|
||||
@@ -1,15 +1,16 @@
|
||||
package org.briarproject.bramble.contact;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.contact.ContactManager;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.NoSuchContactException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
import org.briarproject.bramble.api.transport.KeyManager;
|
||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -18,13 +19,13 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.briarproject.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.TestUtils.getRandomId;
|
||||
import static org.briarproject.TestUtils.getSecretKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ContactManagerImplTest extends BriarTestCase {
|
||||
public class ContactManagerImplTest extends BrambleMockTestCase {
|
||||
|
||||
private final Mockery context = new Mockery();
|
||||
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
@@ -66,7 +67,6 @@ public class ContactManagerImplTest extends BriarTestCase {
|
||||
assertEquals(contactId, contactManager
|
||||
.addContact(remote, local, master, timestamp, alice, verified,
|
||||
active));
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,13 +82,58 @@ public class ContactManagerImplTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertEquals(contact, contactManager.getContact(contactId));
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetContactByAuthor() throws Exception {
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
final Collection<Contact> contacts = Collections.singleton(contact);
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(db).startTransaction(true);
|
||||
will(returnValue(txn));
|
||||
oneOf(db).getContactsByAuthorId(txn, remote.getId());
|
||||
will(returnValue(contacts));
|
||||
oneOf(db).commitTransaction(txn);
|
||||
oneOf(db).endTransaction(txn);
|
||||
}});
|
||||
|
||||
assertEquals(contact, contactManager.getContact(remote.getId(), local));
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchContactException.class)
|
||||
public void testGetContactByUnknownAuthor() throws Exception {
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(db).startTransaction(true);
|
||||
will(returnValue(txn));
|
||||
oneOf(db).getContactsByAuthorId(txn, remote.getId());
|
||||
will(returnValue(Collections.emptyList()));
|
||||
oneOf(db).endTransaction(txn);
|
||||
}});
|
||||
|
||||
contactManager.getContact(remote.getId(), local);
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchContactException.class)
|
||||
public void testGetContactByUnknownLocalAuthor() throws Exception {
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
final Collection<Contact> contacts = Collections.singleton(contact);
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(db).startTransaction(true);
|
||||
will(returnValue(txn));
|
||||
oneOf(db).getContactsByAuthorId(txn, remote.getId());
|
||||
will(returnValue(contacts));
|
||||
oneOf(db).endTransaction(txn);
|
||||
}});
|
||||
|
||||
contactManager.getContact(remote.getId(), new AuthorId(getRandomId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActiveContacts() throws Exception {
|
||||
Collection<Contact> activeContacts = Collections.singletonList(contact);
|
||||
final Collection<Contact> contacts = new ArrayList<>(activeContacts);
|
||||
final Collection<Contact> contacts =
|
||||
new ArrayList<Contact>(activeContacts);
|
||||
contacts.add(new Contact(new ContactId(3), remote, local, true, false));
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
context.checking(new Expectations() {{
|
||||
@@ -101,7 +146,6 @@ public class ContactManagerImplTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertEquals(activeContacts, contactManager.getActiveContacts());
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,7 +162,6 @@ public class ContactManagerImplTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
contactManager.removeContact(contactId);
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,7 +172,6 @@ public class ContactManagerImplTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
contactManager.setContactActive(txn, contactId, active);
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,7 +187,6 @@ public class ContactManagerImplTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertTrue(contactManager.contactExists(remote.getId(), local));
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class AsciiArmourTest extends BriarTestCase {
|
||||
public class AsciiArmourTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testWrapOnSingleLine() {
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.util.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Random;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class Blake2sDigestTest extends BriarTestCase {
|
||||
public class Blake2sDigestTest extends BrambleTestCase {
|
||||
|
||||
// Vectors from BLAKE2 web site: https://blake2.net/blake2s-test.txt
|
||||
private static final String[][] keyedTestVectors = {
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
import org.spongycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
||||
import org.spongycastle.asn1.x9.X9ECParameters;
|
||||
@@ -20,7 +20,7 @@ import java.security.SecureRandom;
|
||||
import static org.briarproject.bramble.crypto.EllipticCurveConstants.PARAMETERS;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class EllipticCurveMultiplicationTest extends BriarTestCase {
|
||||
public class EllipticCurveMultiplicationTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testMultiplierProducesSameResultsAsDefault() throws Exception {
|
||||
@@ -69,7 +69,7 @@ public class EllipticCurvePerformanceTest {
|
||||
ECPublicKeyParameters public2 =
|
||||
(ECPublicKeyParameters) keyPair2.getPublic();
|
||||
// Time some ECDH key agreements
|
||||
List<Long> samples = new ArrayList<>();
|
||||
List<Long> samples = new ArrayList<Long>();
|
||||
for (int i = 0; i < SAMPLES; i++) {
|
||||
ECDHCBasicAgreement agreement = new ECDHCBasicAgreement();
|
||||
long start = System.nanoTime();
|
||||
@@ -79,7 +79,7 @@ public class EllipticCurvePerformanceTest {
|
||||
}
|
||||
long agreementMedian = median(samples);
|
||||
// Time some signatures
|
||||
List<byte[]> signatures = new ArrayList<>();
|
||||
List<byte[]> signatures = new ArrayList<byte[]>();
|
||||
samples.clear();
|
||||
for (int i = 0; i < SAMPLES; i++) {
|
||||
Digest digest = new Blake2sDigest();
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
import org.spongycastle.crypto.BlockCipher;
|
||||
import org.spongycastle.crypto.engines.AESLightEngine;
|
||||
@@ -9,7 +9,7 @@ import org.spongycastle.crypto.params.KeyParameter;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class FortunaGeneratorTest extends BriarTestCase {
|
||||
public class FortunaGeneratorTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testCounterInitialisedToOne() {
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
import org.spongycastle.crypto.BlockCipher;
|
||||
import org.spongycastle.crypto.digests.SHA256Digest;
|
||||
@@ -13,7 +13,7 @@ import static org.briarproject.bramble.crypto.FortunaSecureRandom.SELF_TEST_VECT
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class FortunaSecureRandomTest extends BriarTestCase {
|
||||
public class FortunaSecureRandomTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testClassPassesSelfTest() {
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestSeedProvider;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class HashTest extends BrambleTestCase {
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
|
||||
private final String label = TestUtils.getRandomString(42);
|
||||
private final byte[] inputBytes = TestUtils.getRandomBytes(123);
|
||||
private final byte[] inputBytes1 = TestUtils.getRandomBytes(234);
|
||||
private final byte[] inputBytes2 = new byte[0];
|
||||
|
||||
public HashTest() {
|
||||
crypto = new CryptoComponentImpl(new TestSeedProvider());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdenticalInputsProduceIdenticalHashes() {
|
||||
byte[] hash1 = crypto.hash(label, inputBytes, inputBytes1, inputBytes2);
|
||||
byte[] hash2 = crypto.hash(label, inputBytes, inputBytes1, inputBytes2);
|
||||
assertArrayEquals(hash1, hash2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDifferentInputsProduceDifferentHashes() {
|
||||
byte[] hash1 = crypto.hash(label, inputBytes, inputBytes1, inputBytes2);
|
||||
byte[] hash2 = crypto.hash(label, inputBytes2, inputBytes1, inputBytes);
|
||||
assertFalse(Arrays.equals(hash1, hash2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDifferentLabelsProduceDifferentHashes() {
|
||||
String label2 = TestUtils.getRandomString(42);
|
||||
byte[] hash1 = crypto.hash(label, inputBytes, inputBytes1, inputBytes2);
|
||||
byte[] hash2 =
|
||||
crypto.hash(label2, inputBytes, inputBytes1, inputBytes2);
|
||||
assertFalse(Arrays.equals(hash1, hash2));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestSeedProvider;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.system.SeedProvider;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestSeedProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class KeyAgreementTest extends BriarTestCase {
|
||||
public class KeyAgreementTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testDeriveMasterSecret() throws Exception {
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestSeedProvider;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.transport.TransportKeys;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestSeedProvider;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class KeyDerivationTest extends BriarTestCase {
|
||||
public class KeyDerivationTest extends BrambleTestCase {
|
||||
|
||||
private final TransportId transportId = new TransportId("id");
|
||||
private final CryptoComponent crypto;
|
||||
@@ -141,7 +141,7 @@ public class KeyDerivationTest extends BriarTestCase {
|
||||
}
|
||||
|
||||
private void assertAllDifferent(TransportKeys... transportKeys) {
|
||||
List<SecretKey> secretKeys = new ArrayList<>();
|
||||
List<SecretKey> secretKeys = new ArrayList<SecretKey>();
|
||||
for (TransportKeys k : transportKeys) {
|
||||
secretKeys.add(k.getPreviousIncomingKeys().getTagKey());
|
||||
secretKeys.add(k.getPreviousIncomingKeys().getHeaderKey());
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestSeedProvider;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||
import org.briarproject.bramble.api.crypto.KeyParser;
|
||||
import org.briarproject.bramble.api.crypto.PrivateKey;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestSeedProvider;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
@@ -16,7 +16,7 @@ import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_SIGNATUR
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class KeyEncodingAndParsingTest extends BriarTestCase {
|
||||
public class KeyEncodingAndParsingTest extends BrambleTestCase {
|
||||
|
||||
private final CryptoComponentImpl crypto =
|
||||
new CryptoComponentImpl(new TestSeedProvider());
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestSeedProvider;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestSeedProvider;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -12,7 +12,7 @@ import java.util.Arrays;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class MacTest extends BriarTestCase {
|
||||
public class MacTest extends BrambleTestCase {
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||
import org.briarproject.bramble.api.crypto.PrivateKey;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
import org.spongycastle.crypto.CryptoException;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.security.SecureRandom;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class MessageEncrypterTest extends BriarTestCase {
|
||||
public class MessageEncrypterTest extends BrambleTestCase {
|
||||
|
||||
private final SecureRandom random = new SecureRandom();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestSeedProvider;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestSeedProvider;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PasswordBasedKdfTest extends BriarTestCase {
|
||||
public class PasswordBasedKdfTest extends BrambleTestCase {
|
||||
|
||||
private final CryptoComponentImpl crypto =
|
||||
new CryptoComponentImpl(new TestSeedProvider());
|
||||
@@ -1,13 +1,13 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PasswordStrengthEstimatorImplTest extends BriarTestCase {
|
||||
public class PasswordStrengthEstimatorImplTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testWeakPasswords() {
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestSeedProvider;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestSeedProvider;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SignatureTest extends BriarTestCase {
|
||||
public class SignatureTest extends BrambleTestCase {
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.util.ByteUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -18,7 +18,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.STREAM_H
|
||||
import static org.briarproject.bramble.util.ByteUtils.INT_16_BYTES;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class StreamDecrypterImplTest extends BriarTestCase {
|
||||
public class StreamDecrypterImplTest extends BrambleTestCase {
|
||||
|
||||
private final AuthenticatedCipher cipher;
|
||||
private final SecretKey streamHeaderKey, frameKey;
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -13,7 +13,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.STREAM_H
|
||||
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class StreamEncrypterImplTest extends BriarTestCase {
|
||||
public class StreamEncrypterImplTest extends BrambleTestCase {
|
||||
|
||||
private final AuthenticatedCipher cipher;
|
||||
private final SecretKey streamHeaderKey, frameKey;
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.crypto;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.util.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Random;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class XSalsa20Poly1305AuthenticatedCipherTest extends BriarTestCase {
|
||||
public class XSalsa20Poly1305AuthenticatedCipherTest extends BrambleTestCase {
|
||||
|
||||
// Test vectors from the NaCl paper
|
||||
// http://cr.yp.to/highspeed/naclcrypto-20090310.pdf
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.briarproject.bramble.data;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.util.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BdfReaderImplTest extends BriarTestCase {
|
||||
public class BdfReaderImplTest extends BrambleTestCase {
|
||||
|
||||
private BdfReaderImpl r = null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.data;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.util.StringUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -16,7 +16,7 @@ import java.util.Map;
|
||||
import static org.briarproject.bramble.api.data.BdfDictionary.NULL_VALUE;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class BdfWriterImplTest extends BriarTestCase {
|
||||
public class BdfWriterImplTest extends BrambleTestCase {
|
||||
|
||||
private ByteArrayOutputStream out = null;
|
||||
private BdfWriterImpl w = null;
|
||||
@@ -155,7 +155,7 @@ public class BdfWriterImplTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testWriteList() throws IOException {
|
||||
List<Object> l = new ArrayList<>();
|
||||
List<Object> l = new ArrayList<Object>();
|
||||
for (int i = 0; i < 3; i++) l.add(i);
|
||||
w.writeList(l);
|
||||
// LIST tag, elements as integers, END tag
|
||||
@@ -164,7 +164,7 @@ public class BdfWriterImplTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testListCanContainNull() throws IOException {
|
||||
List<Object> l = new ArrayList<>();
|
||||
List<Object> l = new ArrayList<Object>();
|
||||
l.add(1);
|
||||
l.add(null);
|
||||
l.add(NULL_VALUE);
|
||||
@@ -177,7 +177,7 @@ public class BdfWriterImplTest extends BriarTestCase {
|
||||
@Test
|
||||
public void testWriteDictionary() throws IOException {
|
||||
// Use LinkedHashMap to get predictable iteration order
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
Map<String, Object> m = new LinkedHashMap<String, Object>();
|
||||
for (int i = 0; i < 4; i++) m.put(String.valueOf(i), i);
|
||||
w.writeDictionary(m);
|
||||
// DICTIONARY tag, keys as strings and values as integers, END tag
|
||||
@@ -216,12 +216,12 @@ public class BdfWriterImplTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testWriteNestedDictionariesAndLists() throws IOException {
|
||||
Map<String, Object> inner = new LinkedHashMap<>();
|
||||
Map<String, Object> inner = new LinkedHashMap<String, Object>();
|
||||
inner.put("bar", new byte[0]);
|
||||
List<Object> list = new ArrayList<>();
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
list.add(1);
|
||||
list.add(inner);
|
||||
Map<String, Object> outer = new LinkedHashMap<>();
|
||||
Map<String, Object> outer = new LinkedHashMap<String, Object>();
|
||||
outer.put("foo", list);
|
||||
w.writeDictionary(outer);
|
||||
// DICTIONARY tag, "foo" as string, LIST tag, 1 as integer,
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.bramble.data;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.db.Metadata;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Map;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
||||
public class MetadataEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
|
||||
private MetadataEncoderImpl e;
|
||||
private MetadataParserImpl p;
|
||||
@@ -99,7 +99,7 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testList() throws FormatException {
|
||||
List<Long> l = new ArrayList<>(4);
|
||||
List<Long> l = new ArrayList<Long>(4);
|
||||
l.add(42L);
|
||||
l.add(1337L);
|
||||
l.add(Long.MIN_VALUE);
|
||||
@@ -114,7 +114,7 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testDictionary() throws FormatException {
|
||||
Map<String, Boolean> m = new HashMap<>();
|
||||
Map<String, Boolean> m = new HashMap<String, Boolean>();
|
||||
m.put("1", true);
|
||||
m.put("2", false);
|
||||
|
||||
@@ -130,19 +130,19 @@ public class MetadataEncoderParserIntegrationTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testComplexDictionary() throws FormatException {
|
||||
Map<String, List> m = new HashMap<>();
|
||||
List<String> one = new ArrayList<>(3);
|
||||
Map<String, List> m = new HashMap<String, List>();
|
||||
List<String> one = new ArrayList<String>(3);
|
||||
one.add("\uFDD0");
|
||||
one.add("\uFDD1");
|
||||
one.add("\uFDD2");
|
||||
m.put("One", one);
|
||||
List<String> two = new ArrayList<>(2);
|
||||
List<String> two = new ArrayList<String>(2);
|
||||
two.add("\u0080");
|
||||
two.add("\uD800\uDC00");
|
||||
m.put("Two", two);
|
||||
d.put("test", m);
|
||||
|
||||
Map<String, Boolean> m2 = new HashMap<>();
|
||||
Map<String, Boolean> m2 = new HashMap<String, Boolean>();
|
||||
m2.put("should be true", true);
|
||||
d.put("another test", m2);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.db;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BasicH2Test extends BriarTestCase {
|
||||
public class BasicH2Test extends BrambleTestCase {
|
||||
|
||||
private static final String CREATE_TABLE =
|
||||
"CREATE TABLE foo (uniqueId BINARY(32), name VARCHAR NOT NULL)";
|
||||
@@ -322,7 +322,7 @@ public class BasicH2Test extends BriarTestCase {
|
||||
|
||||
private List<String> getNames() throws SQLException {
|
||||
String sql = "SELECT name FROM foo ORDER BY uniqueId";
|
||||
List<String> names = new ArrayList<>();
|
||||
List<String> names = new ArrayList<String>();
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.bramble.db;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.contact.event.ContactAddedEvent;
|
||||
@@ -49,6 +47,8 @@ import org.briarproject.bramble.api.sync.event.MessagesSentEvent;
|
||||
import org.briarproject.bramble.api.transport.IncomingKeys;
|
||||
import org.briarproject.bramble.api.transport.OutgoingKeys;
|
||||
import org.briarproject.bramble.api.transport.TransportKeys;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -72,7 +72,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class DatabaseComponentImplTest extends BriarTestCase {
|
||||
public class DatabaseComponentImplTest extends BrambleTestCase {
|
||||
|
||||
private final Object txn = new Object();
|
||||
private final ClientId clientId;
|
||||
@@ -118,8 +118,8 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
||||
|
||||
private DatabaseComponent createDatabaseComponent(Database<Object> database,
|
||||
EventBus eventBus, ShutdownManager shutdown) {
|
||||
return new DatabaseComponentImpl<>(database, Object.class, eventBus,
|
||||
shutdown);
|
||||
return new DatabaseComponentImpl<Object>(database, Object.class,
|
||||
eventBus, shutdown);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1701,7 +1701,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
||||
Transaction transaction = db.startTransaction(false);
|
||||
try {
|
||||
db.addLocalMessage(transaction, message, metadata, true);
|
||||
Collection<MessageId> dependencies = new ArrayList<>(2);
|
||||
Collection<MessageId> dependencies = new ArrayList<MessageId>(2);
|
||||
dependencies.add(messageId1);
|
||||
dependencies.add(messageId2);
|
||||
db.addMessageDependencies(transaction, message, dependencies);
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.briarproject.bramble.db;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExponentialBackoffTest extends BriarTestCase {
|
||||
public class ExponentialBackoffTest extends BrambleTestCase {
|
||||
|
||||
private static final int ONE_HOUR = 60 * 60 * 1000;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.bramble.db;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestDatabaseConfig;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
@@ -24,6 +21,9 @@ import org.briarproject.bramble.api.transport.IncomingKeys;
|
||||
import org.briarproject.bramble.api.transport.OutgoingKeys;
|
||||
import org.briarproject.bramble.api.transport.TransportKeys;
|
||||
import org.briarproject.bramble.system.SystemClock;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestDatabaseConfig;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -61,7 +61,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class H2DatabaseTest extends BriarTestCase {
|
||||
public class H2DatabaseTest extends BrambleTestCase {
|
||||
|
||||
private static final int ONE_MEGABYTE = 1024 * 1024;
|
||||
private static final int MAX_SIZE = 5 * ONE_MEGABYTE;
|
||||
@@ -868,7 +868,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
assertEquals(0, db.countOfferedMessages(txn, contactId));
|
||||
|
||||
// Add some offered messages and count them
|
||||
List<MessageId> ids = new ArrayList<>();
|
||||
List<MessageId> ids = new ArrayList<MessageId>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
MessageId m = new MessageId(TestUtils.getRandomId());
|
||||
db.addOfferedMessage(txn, contactId, m);
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.bramble.db;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class LockFairnessTest extends BriarTestCase {
|
||||
public class LockFairnessTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testReadersCanShareTheLock() throws Exception {
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.db;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class TransactionIsolationTest extends BriarTestCase {
|
||||
public class TransactionIsolationTest extends BrambleTestCase {
|
||||
|
||||
private static final String DROP_TABLE = "DROP TABLE foo IF EXISTS";
|
||||
private static final String CREATE_TABLE = "CREATE TABLE foo"
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.bramble.identity;
|
||||
|
||||
import org.briarproject.BriarMockTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
@@ -11,6 +9,8 @@ import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.jmock.Expectations;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -24,7 +24,7 @@ import static org.briarproject.bramble.api.identity.Author.Status.UNVERIFIED;
|
||||
import static org.briarproject.bramble.api.identity.Author.Status.VERIFIED;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class IdentityManagerImplTest extends BriarMockTestCase {
|
||||
public class IdentityManagerImplTest extends BrambleMockTestCase {
|
||||
|
||||
private final IdentityManager identityManager;
|
||||
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
@@ -79,7 +79,7 @@ public class IdentityManagerImplTest extends BriarMockTestCase {
|
||||
@Test
|
||||
public void testGetAuthorStatus() throws DbException {
|
||||
final AuthorId authorId = new AuthorId(TestUtils.getRandomId());
|
||||
final Collection<Contact> contacts = new ArrayList<>();
|
||||
final Collection<Contact> contacts = new ArrayList<Contact>();
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(db).startTransaction(true);
|
||||
@@ -1,13 +1,13 @@
|
||||
package org.briarproject.bramble.keyagreement;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.keyagreement.Payload;
|
||||
import org.briarproject.bramble.api.keyagreement.PayloadEncoder;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.auto.Mock;
|
||||
import org.jmock.integration.junit4.JUnitRuleMockery;
|
||||
@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class KeyAgreementProtocolTest extends BriarTestCase {
|
||||
public class KeyAgreementProtocolTest extends BrambleTestCase {
|
||||
|
||||
@Rule
|
||||
public JUnitRuleMockery context = new JUnitRuleMockery() {{
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.lifecycle;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.lifecycle.ShutdownManager;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -10,12 +10,12 @@ import java.util.Set;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ShutdownManagerImplTest extends BriarTestCase {
|
||||
public class ShutdownManagerImplTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testAddAndRemove() {
|
||||
ShutdownManager s = createShutdownManager();
|
||||
Set<Integer> handles = new HashSet<>();
|
||||
Set<Integer> handles = new HashSet<Integer>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
int handle = s.addShutdownHook(new Runnable() {
|
||||
@Override
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.bramble.plugin;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BackoffImplTest extends BriarTestCase {
|
||||
public class BackoffImplTest extends BrambleTestCase {
|
||||
|
||||
private static final int MIN_INTERVAL = 60 * 1000;
|
||||
private static final int MAX_INTERVAL = 60 * 60 * 1000;
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.plugin;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.EventBus;
|
||||
import org.briarproject.bramble.api.plugin.ConnectionRegistry;
|
||||
@@ -9,6 +8,7 @@ import org.briarproject.bramble.api.plugin.event.ConnectionClosedEvent;
|
||||
import org.briarproject.bramble.api.plugin.event.ConnectionOpenedEvent;
|
||||
import org.briarproject.bramble.api.plugin.event.ContactConnectedEvent;
|
||||
import org.briarproject.bramble.api.plugin.event.ContactDisconnectedEvent;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ConnectionRegistryImplTest extends BriarTestCase {
|
||||
public class ConnectionRegistryImplTest extends BrambleTestCase {
|
||||
|
||||
private final ContactId contactId, contactId1;
|
||||
private final TransportId transportId, transportId1;
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.plugin;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.event.EventBus;
|
||||
import org.briarproject.bramble.api.plugin.ConnectionManager;
|
||||
import org.briarproject.bramble.api.plugin.PluginConfig;
|
||||
@@ -14,6 +13,7 @@ import org.briarproject.bramble.api.plugin.simplex.SimplexPluginFactory;
|
||||
import org.briarproject.bramble.api.properties.TransportPropertyManager;
|
||||
import org.briarproject.bramble.api.settings.SettingsManager;
|
||||
import org.briarproject.bramble.api.ui.UiCallback;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.jmock.lib.concurrent.Synchroniser;
|
||||
@@ -23,7 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class PluginManagerImplTest extends BriarTestCase {
|
||||
public class PluginManagerImplTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testStartAndStop() throws Exception {
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.bramble.plugin;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.ImmediateExecutor;
|
||||
import org.briarproject.RunAction;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.contact.event.ContactStatusChangedEvent;
|
||||
import org.briarproject.bramble.api.plugin.ConnectionManager;
|
||||
@@ -18,6 +15,9 @@ import org.briarproject.bramble.api.plugin.event.ConnectionOpenedEvent;
|
||||
import org.briarproject.bramble.api.plugin.event.TransportEnabledEvent;
|
||||
import org.briarproject.bramble.api.plugin.simplex.SimplexPlugin;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.ImmediateExecutor;
|
||||
import org.briarproject.bramble.test.RunAction;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.jmock.lib.legacy.ClassImposteriser;
|
||||
@@ -32,7 +32,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
public class PollerTest extends BriarTestCase {
|
||||
public class PollerTest extends BrambleTestCase {
|
||||
|
||||
private final ContactId contactId = new ContactId(234);
|
||||
private final int pollingInterval = 60 * 1000;
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.plugin.tcp;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.api.keyagreement.KeyAgreementConnection;
|
||||
@@ -12,6 +11,7 @@ import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexTransportConnection;
|
||||
import org.briarproject.bramble.api.properties.TransportProperties;
|
||||
import org.briarproject.bramble.api.settings.Settings;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -39,7 +39,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class LanTcpPluginTest extends BriarTestCase {
|
||||
public class LanTcpPluginTest extends BrambleTestCase {
|
||||
|
||||
private final ContactId contactId = new ContactId(234);
|
||||
private final Backoff backoff = new TestBackoff();
|
||||
@@ -194,7 +194,8 @@ public class LanTcpPluginTest extends BriarTestCase {
|
||||
plugin.createKeyAgreementListener(new byte[COMMIT_LENGTH]);
|
||||
assertNotNull(kal);
|
||||
Callable<KeyAgreementConnection> c = kal.listen();
|
||||
FutureTask<KeyAgreementConnection> f = new FutureTask<>(c);
|
||||
FutureTask<KeyAgreementConnection> f =
|
||||
new FutureTask<KeyAgreementConnection>(c);
|
||||
new Thread(f).start();
|
||||
// The plugin should have bound a socket and stored the port number
|
||||
BdfList descriptor = kal.getDescriptor();
|
||||
@@ -290,7 +291,7 @@ public class LanTcpPluginTest extends BriarTestCase {
|
||||
private static class Callback implements DuplexPluginCallback {
|
||||
|
||||
private final Map<ContactId, TransportProperties> remote =
|
||||
new Hashtable<>();
|
||||
new Hashtable<ContactId, TransportProperties>();
|
||||
private final CountDownLatch propertiesLatch = new CountDownLatch(1);
|
||||
private final CountDownLatch connectionsLatch = new CountDownLatch(1);
|
||||
private final TransportProperties local = new TransportProperties();
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.briarproject.bramble.properties;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class TransportPropertyManagerImplTest extends BriarTestCase {
|
||||
public class TransportPropertyManagerImplTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testUnitTestsExist() {
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.bramble.properties;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
@@ -14,6 +12,8 @@ import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -23,7 +23,7 @@ import static org.briarproject.bramble.api.plugin.TransportId.MAX_TRANSPORT_ID_L
|
||||
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TransportPropertyValidatorTest extends BriarTestCase {
|
||||
public class TransportPropertyValidatorTest extends BrambleTestCase {
|
||||
|
||||
private final TransportId transportId;
|
||||
private final BdfDictionary bdfDictionary;
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.bramble.sync;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.UniqueId;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.util.ByteUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -17,7 +17,7 @@ import static org.briarproject.bramble.api.sync.SyncConstants.MAX_PACKET_PAYLOAD
|
||||
import static org.briarproject.bramble.api.sync.SyncConstants.PACKET_HEADER_LENGTH;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PacketReaderImplTest extends BriarTestCase {
|
||||
public class PacketReaderImplTest extends BrambleTestCase {
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testFormatExceptionIfAckIsTooLarge() throws Exception {
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.bramble.sync;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.ImmediateExecutor;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
@@ -10,6 +7,9 @@ import org.briarproject.bramble.api.event.EventBus;
|
||||
import org.briarproject.bramble.api.sync.Ack;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.sync.PacketWriter;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.ImmediateExecutor;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.Executor;
|
||||
|
||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_IDS;
|
||||
|
||||
public class SimplexOutgoingSessionTest extends BriarTestCase {
|
||||
public class SimplexOutgoingSessionTest extends BrambleTestCase {
|
||||
|
||||
private final Mockery context;
|
||||
private final DatabaseComponent db;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.sync;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
@@ -20,6 +20,8 @@ import org.briarproject.bramble.api.sync.Request;
|
||||
import org.briarproject.bramble.api.transport.StreamContext;
|
||||
import org.briarproject.bramble.api.transport.StreamReaderFactory;
|
||||
import org.briarproject.bramble.api.transport.StreamWriterFactory;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -37,7 +39,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SyncIntegrationTest extends BriarTestCase {
|
||||
public class SyncIntegrationTest extends BrambleTestCase {
|
||||
|
||||
@Inject
|
||||
GroupFactory groupFactory;
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.sync;
|
||||
|
||||
import org.briarproject.bramble.crypto.CryptoModule;
|
||||
import org.briarproject.bramble.sync.SyncModule;
|
||||
import org.briarproject.bramble.test.TestSeedProviderModule;
|
||||
import org.briarproject.bramble.transport.TransportModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.bramble.sync;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.ImmediateExecutor;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.UniqueId;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
@@ -22,6 +19,9 @@ import org.briarproject.bramble.api.sync.ValidationManager.IncomingMessageHook;
|
||||
import org.briarproject.bramble.api.sync.ValidationManager.MessageValidator;
|
||||
import org.briarproject.bramble.api.sync.ValidationManager.State;
|
||||
import org.briarproject.bramble.api.sync.event.MessageAddedEvent;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.ImmediateExecutor;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.util.ByteUtils;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
@@ -38,7 +38,7 @@ import static org.briarproject.bramble.api.sync.ValidationManager.State.INVALID;
|
||||
import static org.briarproject.bramble.api.sync.ValidationManager.State.PENDING;
|
||||
import static org.briarproject.bramble.api.sync.ValidationManager.State.UNKNOWN;
|
||||
|
||||
public class ValidationManagerImplTest extends BriarTestCase {
|
||||
public class ValidationManagerImplTest extends BrambleTestCase {
|
||||
|
||||
private final ClientId clientId =
|
||||
new ClientId(TestUtils.getRandomString(5));
|
||||
@@ -831,7 +831,8 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
||||
context.mock(IncomingMessageHook.class);
|
||||
final MessageId messageId3 = new MessageId(TestUtils.getRandomId());
|
||||
final MessageId messageId4 = new MessageId(TestUtils.getRandomId());
|
||||
final Map<MessageId, State> twoDependents = new LinkedHashMap<>();
|
||||
final Map<MessageId, State> twoDependents =
|
||||
new LinkedHashMap<MessageId, State>();
|
||||
twoDependents.put(messageId1, PENDING);
|
||||
twoDependents.put(messageId2, PENDING);
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
@@ -952,10 +953,12 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
||||
raw);
|
||||
final Message message4 = new Message(messageId4, groupId, timestamp,
|
||||
raw);
|
||||
final Map<MessageId, State> twoDependents = new LinkedHashMap<>();
|
||||
final Map<MessageId, State> twoDependents =
|
||||
new LinkedHashMap<MessageId, State>();
|
||||
twoDependents.put(messageId1, PENDING);
|
||||
twoDependents.put(messageId2, PENDING);
|
||||
final Map<MessageId, State> twoDependencies = new LinkedHashMap<>();
|
||||
final Map<MessageId, State> twoDependencies =
|
||||
new LinkedHashMap<MessageId, State>();
|
||||
twoDependencies.put(messageId1, DELIVERED);
|
||||
twoDependencies.put(messageId2, DELIVERED);
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
@@ -1117,7 +1120,8 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
||||
final MessageValidator validator = context.mock(MessageValidator.class);
|
||||
final IncomingMessageHook hook =
|
||||
context.mock(IncomingMessageHook.class);
|
||||
final Map<MessageId, State> twoDependencies = new LinkedHashMap<>();
|
||||
final Map<MessageId, State> twoDependencies =
|
||||
new LinkedHashMap<MessageId, State>();
|
||||
twoDependencies.put(messageId, DELIVERED);
|
||||
twoDependencies.put(messageId2, UNKNOWN);
|
||||
final Transaction txn = new Transaction(null, true);
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.bramble.system;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.Bytes;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.util.OsUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class LinuxSeedProviderTest extends BriarTestCase {
|
||||
public class LinuxSeedProviderTest extends BrambleTestCase {
|
||||
|
||||
private final File testDir = TestUtils.getTestDirectory();
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LinuxSeedProviderTest extends BriarTestCase {
|
||||
System.err.println("WARNING: Skipping test, can't run on this OS");
|
||||
return;
|
||||
}
|
||||
Set<Bytes> seeds = new HashSet<>();
|
||||
Set<Bytes> seeds = new HashSet<Bytes>();
|
||||
LinuxSeedProvider p = new LinuxSeedProvider();
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
byte[] seed = p.getSeed();
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.jmock.api.Action;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.jmock.api.Action;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
@@ -18,7 +18,7 @@ import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
class TestLifecycleModule {
|
||||
public class TestLifecycleModule {
|
||||
|
||||
@Provides
|
||||
LifecycleManager provideLifecycleManager() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginConfig;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.system.SeedProvider;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.system.SeedProvider;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject;
|
||||
package org.briarproject.bramble.test;
|
||||
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.data.MetadataEncoder;
|
||||
@@ -10,7 +10,7 @@ import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
|
||||
public abstract class ValidatorTestCase extends BriarMockTestCase {
|
||||
public abstract class ValidatorTestCase extends BrambleMockTestCase {
|
||||
|
||||
protected final ClientHelper clientHelper =
|
||||
context.mock(ClientHelper.class);
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.transport;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.contact.event.ContactRemovedEvent;
|
||||
@@ -14,6 +13,7 @@ import org.briarproject.bramble.api.plugin.PluginConfig;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.simplex.SimplexPluginFactory;
|
||||
import org.briarproject.bramble.api.transport.StreamContext;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.jmock.lib.concurrent.DeterministicExecutor;
|
||||
@@ -24,13 +24,13 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.briarproject.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.TestUtils.getRandomId;
|
||||
import static org.briarproject.TestUtils.getSecretKey;
|
||||
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class KeyManagerImplTest extends BriarTestCase {
|
||||
public class KeyManagerImplTest extends BrambleTestCase {
|
||||
|
||||
private final Mockery context = new Mockery();
|
||||
private final KeyManagerImpl keyManager;
|
||||
@@ -63,7 +63,7 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
Author remoteAuthor = new Author(remoteAuthorId, "author",
|
||||
getRandomBytes(42));
|
||||
AuthorId localAuthorId = new AuthorId(getRandomId());
|
||||
final Collection<Contact> contacts = new ArrayList<>();
|
||||
final Collection<Contact> contacts = new ArrayList<Contact>();
|
||||
contacts.add(new Contact(contactId, remoteAuthor, localAuthorId, true,
|
||||
true));
|
||||
contacts.add(new Contact(inactiveContactId, remoteAuthor, localAuthorId,
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.transport;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.transport.ReorderingWindow.Change;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -12,7 +12,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.REORDERI
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ReorderingWindowTest extends BriarTestCase {
|
||||
public class ReorderingWindowTest extends BrambleTestCase {
|
||||
|
||||
private static final int BITMAP_BYTES = REORDERING_WINDOW_SIZE / 8;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.transport;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.crypto.StreamDecrypter;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -9,7 +9,7 @@ import org.junit.Test;
|
||||
import static org.briarproject.bramble.api.transport.TransportConstants.MAX_PAYLOAD_LENGTH;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class StreamReaderImplTest extends BriarTestCase {
|
||||
public class StreamReaderImplTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testEmptyFramesAreSkipped() throws Exception {
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.bramble.transport;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.crypto.StreamDecrypter;
|
||||
import org.briarproject.bramble.api.crypto.StreamEncrypter;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -19,7 +19,7 @@ import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENG
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class StreamReaderWriterIntegrationTest extends BriarTestCase {
|
||||
public class StreamReaderWriterIntegrationTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testWriteAndRead() throws Exception {
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.bramble.transport;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.crypto.StreamEncrypter;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -9,7 +9,7 @@ import org.junit.Test;
|
||||
import static org.briarproject.bramble.api.transport.TransportConstants.MAX_PAYLOAD_LENGTH;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class StreamWriterImplTest extends BriarTestCase {
|
||||
public class StreamWriterImplTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testCloseWithoutWritingWritesFinalFrame() throws Exception {
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.bramble.transport;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.RunAction;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
@@ -14,6 +11,9 @@ import org.briarproject.bramble.api.transport.IncomingKeys;
|
||||
import org.briarproject.bramble.api.transport.OutgoingKeys;
|
||||
import org.briarproject.bramble.api.transport.StreamContext;
|
||||
import org.briarproject.bramble.api.transport.TransportKeys;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.RunAction;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.hamcrest.Description;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
@@ -40,7 +40,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TransportKeyManagerImplTest extends BriarTestCase {
|
||||
public class TransportKeyManagerImplTest extends BrambleTestCase {
|
||||
|
||||
private final TransportId transportId = new TransportId("id");
|
||||
private final long maxLatency = 30 * 1000; // 30 seconds
|
||||
@@ -62,7 +62,8 @@ public class TransportKeyManagerImplTest extends BriarTestCase {
|
||||
context.mock(ScheduledExecutorService.class);
|
||||
final Clock clock = context.mock(Clock.class);
|
||||
|
||||
final Map<ContactId, TransportKeys> loaded = new LinkedHashMap<>();
|
||||
final Map<ContactId, TransportKeys> loaded =
|
||||
new LinkedHashMap<ContactId, TransportKeys>();
|
||||
final TransportKeys shouldRotate = createTransportKeys(900, 0);
|
||||
final TransportKeys shouldNotRotate = createTransportKeys(1000, 0);
|
||||
loaded.put(contactId, shouldRotate);
|
||||
@@ -341,7 +342,7 @@ public class TransportKeyManagerImplTest extends BriarTestCase {
|
||||
final boolean alice = true;
|
||||
final TransportKeys transportKeys = createTransportKeys(1000, 0);
|
||||
// Keep a copy of the tags
|
||||
final List<byte[]> tags = new ArrayList<>();
|
||||
final List<byte[]> tags = new ArrayList<byte[]>();
|
||||
final Transaction txn = new Transaction(null, false);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.bramble.util;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.briarproject.bramble.util.ByteUtils.MAX_16_BIT_UNSIGNED;
|
||||
@@ -8,7 +8,7 @@ import static org.briarproject.bramble.util.ByteUtils.MAX_32_BIT_UNSIGNED;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ByteUtilsTest extends BriarTestCase {
|
||||
public class ByteUtilsTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testReadUint16() {
|
||||
@@ -1,13 +1,13 @@
|
||||
package org.briarproject.bramble.util;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
public class StringUtilsTest extends BriarTestCase {
|
||||
public class StringUtilsTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testToHexString() {
|
||||
@@ -7,4 +7,10 @@ apply plugin: 'witness'
|
||||
dependencies {
|
||||
compile project(':bramble-core')
|
||||
compile fileTree(dir: 'libs', include: '*.jar')
|
||||
|
||||
testCompile project(path: ':bramble-core', configuration: 'testOutput')
|
||||
}
|
||||
|
||||
tasks.withType(Test) {
|
||||
systemProperty 'java.library.path', 'libs'
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.Backoff;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
|
||||
@@ -99,7 +100,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() throws IOException {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
// Initialise the Bluetooth stack
|
||||
try {
|
||||
@@ -108,13 +109,14 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
// On Linux the user may need to install libbluetooth-dev
|
||||
if (OsUtils.isLinux())
|
||||
callback.showMessage("BLUETOOTH_INSTALL_LIBS");
|
||||
return false;
|
||||
throw new PluginException(e);
|
||||
} catch (BluetoothStateException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Local address " + localDevice.getBluetoothAddress());
|
||||
running = true;
|
||||
bind();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void bind() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.bramble.plugin.file;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.simplex.SimplexPluginCallback;
|
||||
|
||||
@@ -42,17 +43,24 @@ class RemovableDrivePlugin extends FilePlugin
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() throws IOException {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
running = true;
|
||||
monitor.start(this);
|
||||
return true;
|
||||
try {
|
||||
monitor.start(this);
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws IOException {
|
||||
public void stop() throws PluginException {
|
||||
running = false;
|
||||
monitor.stop();
|
||||
try {
|
||||
monitor.stop();
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.duplex.AbstractDuplexTransportConnection;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||
@@ -68,7 +69,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
for (String portName : serialPortList.getPortNames()) {
|
||||
if (LOG.isLoggable(INFO))
|
||||
@@ -79,12 +80,12 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Initialised modem on " + portName);
|
||||
running = true;
|
||||
return true;
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
throw new PluginException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.briarproject.bramble.plugin.file;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class LinuxRemovableDriveFinderTest extends BriarTestCase {
|
||||
public class LinuxRemovableDriveFinderTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testParseMountPoint() {
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.briarproject.bramble.plugin.file;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MacRemovableDriveFinderTest extends BriarTestCase {
|
||||
public class MacRemovableDriveFinderTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testParseMountPoint() {
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.bramble.plugin.file;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class PollingRemovableDriveMonitorTest extends BriarTestCase {
|
||||
public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testOneCallbackPerFile() throws Exception {
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.bramble.plugin.file;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.ImmediateExecutor;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
||||
import org.briarproject.bramble.api.plugin.simplex.SimplexPluginCallback;
|
||||
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.ImmediateExecutor;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.jmock.lib.concurrent.Synchroniser;
|
||||
@@ -29,7 +29,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class RemovableDrivePluginTest extends BriarTestCase {
|
||||
public class RemovableDrivePluginTest extends BrambleTestCase {
|
||||
|
||||
private final File testDir = TestUtils.getTestDirectory();
|
||||
private final ContactId contactId = new ContactId(234);
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.bramble.plugin.file;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.plugin.file.RemovableDriveMonitor.Callback;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.util.OsUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class UnixRemovableDriveMonitorTest extends BriarTestCase {
|
||||
public class UnixRemovableDriveMonitorTest extends BrambleTestCase {
|
||||
|
||||
private final File testDir = TestUtils.getTestDirectory();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.bramble.plugin.modem;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class CountryCodesTest extends BriarTestCase {
|
||||
public class CountryCodesTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testTranslation() {
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.bramble.plugin.modem;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
|
||||
import org.briarproject.bramble.api.properties.TransportProperties;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -14,9 +14,8 @@ import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ModemPluginTest extends BriarTestCase {
|
||||
public class ModemPluginTest extends BrambleTestCase {
|
||||
|
||||
private static final String ISO_1336 = "GB";
|
||||
private static final String NUMBER = "0123456789";
|
||||
@@ -49,7 +48,7 @@ public class ModemPluginTest extends BriarTestCase {
|
||||
oneOf(modem).start();
|
||||
will(returnValue(true));
|
||||
}});
|
||||
assertTrue(plugin.start());
|
||||
plugin.start();
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@@ -88,7 +87,7 @@ public class ModemPluginTest extends BriarTestCase {
|
||||
oneOf(modem).dial(NUMBER);
|
||||
will(returnValue(true));
|
||||
}});
|
||||
assertTrue(plugin.start());
|
||||
plugin.start();
|
||||
// A connection should be returned
|
||||
assertNotNull(plugin.createConnection(contactId));
|
||||
context.assertIsSatisfied();
|
||||
@@ -129,7 +128,7 @@ public class ModemPluginTest extends BriarTestCase {
|
||||
oneOf(modem).dial(NUMBER);
|
||||
will(returnValue(false));
|
||||
}});
|
||||
assertTrue(plugin.start());
|
||||
plugin.start();
|
||||
// No connection should be returned
|
||||
assertNull(plugin.createConnection(contactId));
|
||||
context.assertIsSatisfied();
|
||||
@@ -177,7 +176,7 @@ public class ModemPluginTest extends BriarTestCase {
|
||||
oneOf(modem).start();
|
||||
will(returnValue(true));
|
||||
}});
|
||||
assertTrue(plugin.start());
|
||||
plugin.start();
|
||||
// No connection should be returned
|
||||
assertNull(plugin.createConnection(contactId));
|
||||
context.assertIsSatisfied();
|
||||
5
briar-android-tests/.gitignore
vendored
5
briar-android-tests/.gitignore
vendored
@@ -1,5 +0,0 @@
|
||||
bin
|
||||
gen
|
||||
build
|
||||
local.properties
|
||||
.settings
|
||||
@@ -1,27 +0,0 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.neenbedankt.android-apt'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.3"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../briar-android/proguard-rules.txt'
|
||||
consumerProguardFiles getDefaultProguardFile('proguard-android.txt'), '../briar-android/proguard-rules.txt'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile project(':briar-tests')
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'net.jodah:concurrentunit:0.4.2'
|
||||
testCompile 'com.android.support:appcompat-v7:23.2.1'
|
||||
testApt 'com.google.dagger:dagger-compiler:2.0.2'
|
||||
provided 'javax.annotation:jsr250-api:1.0'
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<manifest package="org.briarproject"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,3 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">briar-android-tests</string>
|
||||
</resources>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user