mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +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 javax.annotation.concurrent.ThreadSafe;
|
||||||
|
|
||||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
|
||||||
|
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
class ContactMailboxConnectivityChecker extends ConnectivityCheckerImpl {
|
class ContactMailboxConnectivityChecker extends ConnectivityCheckerImpl {
|
||||||
@@ -29,8 +27,9 @@ class ContactMailboxConnectivityChecker extends ConnectivityCheckerImpl {
|
|||||||
return new SimpleApiCall() {
|
return new SimpleApiCall() {
|
||||||
@Override
|
@Override
|
||||||
void tryToCallApi() throws IOException, ApiException {
|
void tryToCallApi() throws IOException, ApiException {
|
||||||
mailboxApi.getFiles(properties,
|
if (!mailboxApi.checkStatus(properties)) {
|
||||||
requireNonNull(properties.getInboxId()));
|
throw new ApiException();
|
||||||
|
}
|
||||||
// Call the observers and cache the result
|
// Call the observers and cache the result
|
||||||
onConnectivityCheckSucceeded(clock.currentTimeMillis());
|
onConnectivityCheckSucceeded(clock.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,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.api.nullsafety.NullSafety.requireNonNull;
|
|
||||||
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;
|
||||||
@@ -54,9 +52,8 @@ public class ContactMailboxConnectivityCheckerTest extends BrambleMockTestCase {
|
|||||||
|
|
||||||
// When the check succeeds the observer should be called
|
// When the check succeeds the observer should be called
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(mailboxApi).getFiles(properties,
|
oneOf(mailboxApi).checkStatus(properties);
|
||||||
requireNonNull(properties.getInboxId()));
|
will(returnValue(true));
|
||||||
will(returnValue(emptyList()));
|
|
||||||
oneOf(clock).currentTimeMillis();
|
oneOf(clock).currentTimeMillis();
|
||||||
will(returnValue(now));
|
will(returnValue(now));
|
||||||
oneOf(observer).onConnectivityCheckSucceeded();
|
oneOf(observer).onConnectivityCheckSucceeded();
|
||||||
@@ -86,8 +83,7 @@ public class ContactMailboxConnectivityCheckerTest extends BrambleMockTestCase {
|
|||||||
|
|
||||||
// When the check fails, the observer should not be called
|
// When the check fails, the observer should not be called
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(mailboxApi).getFiles(properties,
|
oneOf(mailboxApi).checkStatus(properties);
|
||||||
requireNonNull(properties.getInboxId()));
|
|
||||||
will(throwException(new IOException()));
|
will(throwException(new IOException()));
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user