mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Use status endpoint for contact connectivity check.
This commit is contained in:
@@ -9,8 +9,6 @@ import java.io.IOException;
|
||||
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||
|
||||
@ThreadSafe
|
||||
@NotNullByDefault
|
||||
class ContactMailboxConnectivityChecker extends ConnectivityCheckerImpl {
|
||||
@@ -29,8 +27,9 @@ class ContactMailboxConnectivityChecker extends ConnectivityCheckerImpl {
|
||||
return new SimpleApiCall() {
|
||||
@Override
|
||||
void tryToCallApi() throws IOException, ApiException {
|
||||
mailboxApi.getFiles(properties,
|
||||
requireNonNull(properties.getInboxId()));
|
||||
if (!mailboxApi.checkStatus(properties)) {
|
||||
throw new ApiException();
|
||||
}
|
||||
// Call the observers and cache the result
|
||||
onConnectivityCheckSucceeded(clock.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||
import static org.briarproject.bramble.mailbox.MailboxApi.CLIENT_SUPPORTS;
|
||||
import static org.briarproject.bramble.test.TestUtils.getMailboxProperties;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -54,9 +52,8 @@ public class ContactMailboxConnectivityCheckerTest extends BrambleMockTestCase {
|
||||
|
||||
// When the check succeeds the observer should be called
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(mailboxApi).getFiles(properties,
|
||||
requireNonNull(properties.getInboxId()));
|
||||
will(returnValue(emptyList()));
|
||||
oneOf(mailboxApi).checkStatus(properties);
|
||||
will(returnValue(true));
|
||||
oneOf(clock).currentTimeMillis();
|
||||
will(returnValue(now));
|
||||
oneOf(observer).onConnectivityCheckSucceeded();
|
||||
@@ -86,8 +83,7 @@ public class ContactMailboxConnectivityCheckerTest extends BrambleMockTestCase {
|
||||
|
||||
// When the check fails, the observer should not be called
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(mailboxApi).getFiles(properties,
|
||||
requireNonNull(properties.getInboxId()));
|
||||
oneOf(mailboxApi).checkStatus(properties);
|
||||
will(throwException(new IOException()));
|
||||
}});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user