mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Destroy connectivity checker when client is destroyed.
This commit is contained in:
@@ -55,6 +55,10 @@ class ContactMailboxClient implements MailboxClient {
|
||||
}
|
||||
if (uploadWorker != null) uploadWorker.destroy();
|
||||
if (downloadWorker != null) downloadWorker.destroy();
|
||||
// The connectivity checker belongs to the client, so it should be
|
||||
// destroyed. The Tor reachability monitor is shared between clients,
|
||||
// so it should not be destroyed
|
||||
connectivityChecker.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -86,6 +86,10 @@ class OwnMailboxClient implements MailboxClient {
|
||||
for (MailboxWorker worker : uploadWorkers) worker.destroy();
|
||||
if (downloadWorker != null) downloadWorker.destroy();
|
||||
contactListWorker.destroy();
|
||||
// The connectivity checker belongs to the client, so it should be
|
||||
// destroyed. The Tor reachability monitor is shared between clients,
|
||||
// so it should not be destroyed
|
||||
connectivityChecker.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,6 +40,8 @@ public class ContactMailboxClientTest extends BrambleMockTestCase {
|
||||
@Test
|
||||
public void testStartAndDestroyWithNoContactsAssigned() {
|
||||
client.start();
|
||||
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -54,6 +56,7 @@ public class ContactMailboxClientTest extends BrambleMockTestCase {
|
||||
|
||||
// When the client is destroyed, the worker should be destroyed
|
||||
expectDestroyWorker(uploadWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -71,6 +74,7 @@ public class ContactMailboxClientTest extends BrambleMockTestCase {
|
||||
client.deassignContactForUpload(contactId);
|
||||
context.assertIsSatisfied();
|
||||
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -85,6 +89,7 @@ public class ContactMailboxClientTest extends BrambleMockTestCase {
|
||||
|
||||
// When the client is destroyed, the worker should be destroyed
|
||||
expectDestroyWorker(downloadWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -102,6 +107,7 @@ public class ContactMailboxClientTest extends BrambleMockTestCase {
|
||||
client.deassignContactForDownload(contactId);
|
||||
context.assertIsSatisfied();
|
||||
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -128,4 +134,10 @@ public class ContactMailboxClientTest extends BrambleMockTestCase {
|
||||
oneOf(worker).destroy();
|
||||
}});
|
||||
}
|
||||
|
||||
private void expectDestroyConnectivityChecker() {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(connectivityChecker).destroy();
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class OwnMailboxClientTest extends BrambleMockTestCase {
|
||||
client.start();
|
||||
|
||||
expectDestroyWorker(contactListWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -67,6 +68,7 @@ public class OwnMailboxClientTest extends BrambleMockTestCase {
|
||||
// When the client is destroyed, the worker should be destroyed
|
||||
expectDestroyWorker(uploadWorker1);
|
||||
expectDestroyWorker(contactListWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -87,6 +89,7 @@ public class OwnMailboxClientTest extends BrambleMockTestCase {
|
||||
context.assertIsSatisfied();
|
||||
|
||||
expectDestroyWorker(contactListWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -120,6 +123,7 @@ public class OwnMailboxClientTest extends BrambleMockTestCase {
|
||||
context.assertIsSatisfied();
|
||||
|
||||
expectDestroyWorker(contactListWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -137,6 +141,7 @@ public class OwnMailboxClientTest extends BrambleMockTestCase {
|
||||
// When the client is destroyed, the worker should be destroyed
|
||||
expectDestroyWorker(downloadWorker);
|
||||
expectDestroyWorker(contactListWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -166,6 +171,7 @@ public class OwnMailboxClientTest extends BrambleMockTestCase {
|
||||
context.assertIsSatisfied();
|
||||
|
||||
expectDestroyWorker(contactListWorker);
|
||||
expectDestroyConnectivityChecker();
|
||||
client.destroy();
|
||||
}
|
||||
|
||||
@@ -205,4 +211,10 @@ public class OwnMailboxClientTest extends BrambleMockTestCase {
|
||||
oneOf(worker).destroy();
|
||||
}});
|
||||
}
|
||||
|
||||
private void expectDestroyConnectivityChecker() {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(connectivityChecker).destroy();
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user