mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 23:29:52 +01:00
Use status endpoint for connectivity check.
This commit is contained in:
@@ -55,7 +55,7 @@ class OwnMailboxConnectivityChecker extends ConnectivityCheckerImpl {
|
|||||||
private boolean checkConnectivityAndStoreResult(
|
private boolean checkConnectivityAndStoreResult(
|
||||||
MailboxProperties properties) throws DbException {
|
MailboxProperties properties) throws DbException {
|
||||||
try {
|
try {
|
||||||
mailboxApi.getFolders(properties);
|
if (!mailboxApi.checkStatus(properties)) throw new ApiException();
|
||||||
LOG.info("Own mailbox is reachable");
|
LOG.info("Own mailbox is reachable");
|
||||||
long now = clock.currentTimeMillis();
|
long now = clock.currentTimeMillis();
|
||||||
db.transaction(false, txn -> mailboxSettingsManager
|
db.transaction(false, txn -> mailboxSettingsManager
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.junit.Test;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
|
||||||
import static org.briarproject.bramble.mailbox.MailboxApi.CLIENT_SUPPORTS;
|
import static org.briarproject.bramble.mailbox.MailboxApi.CLIENT_SUPPORTS;
|
||||||
import static org.briarproject.bramble.test.TestUtils.getMailboxProperties;
|
import static org.briarproject.bramble.test.TestUtils.getMailboxProperties;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -63,8 +62,8 @@ public class OwnMailboxConnectivityCheckerTest extends BrambleMockTestCase {
|
|||||||
// When the check succeeds, the success should be recorded in the DB
|
// When the check succeeds, the success should be recorded in the DB
|
||||||
// and the observer should be called
|
// and the observer should be called
|
||||||
context.checking(new DbExpectations() {{
|
context.checking(new DbExpectations() {{
|
||||||
oneOf(mailboxApi).getFolders(properties);
|
oneOf(mailboxApi).checkStatus(properties);
|
||||||
will(returnValue(emptyList()));
|
will(returnValue(true));
|
||||||
oneOf(clock).currentTimeMillis();
|
oneOf(clock).currentTimeMillis();
|
||||||
will(returnValue(now));
|
will(returnValue(now));
|
||||||
oneOf(db).transaction(with(false), withDbRunnable(txn));
|
oneOf(db).transaction(with(false), withDbRunnable(txn));
|
||||||
@@ -98,7 +97,7 @@ public class OwnMailboxConnectivityCheckerTest extends BrambleMockTestCase {
|
|||||||
// When the check fails, the failure should be recorded in the DB and
|
// When the check fails, the failure should be recorded in the DB and
|
||||||
// the observer should not be called
|
// the observer should not be called
|
||||||
context.checking(new DbExpectations() {{
|
context.checking(new DbExpectations() {{
|
||||||
oneOf(mailboxApi).getFolders(properties);
|
oneOf(mailboxApi).checkStatus(properties);
|
||||||
will(throwException(new IOException()));
|
will(throwException(new IOException()));
|
||||||
oneOf(clock).currentTimeMillis();
|
oneOf(clock).currentTimeMillis();
|
||||||
will(returnValue(now));
|
will(returnValue(now));
|
||||||
|
|||||||
Reference in New Issue
Block a user