mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Make MailboxIntegrationTest a bit more thorough
by checking, after adding the contact to the mailbox but before creating the message, that the first file containing the mailbox update gets uploaded. Then after creating the message, the second file should be uploaded.
This commit is contained in:
@@ -7,13 +7,18 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.mailbox.MailboxIntegrationTestUtils.retryUntilSuccessOrTimeout;
|
import static org.briarproject.bramble.mailbox.MailboxIntegrationTestUtils.retryUntilSuccessOrTimeout;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
public class MailboxIntegrationTest extends AbstractMailboxIntegrationTest {
|
public class MailboxIntegrationTest extends AbstractMailboxIntegrationTest {
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
getLogger(MailboxIntegrationTest.class.getSimpleName());
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendMessageViaMailbox() throws Exception {
|
public void testSendMessageViaMailbox() throws Exception {
|
||||||
addContacts();
|
addContacts();
|
||||||
@@ -37,21 +42,30 @@ public class MailboxIntegrationTest extends AbstractMailboxIntegrationTest {
|
|||||||
getMailboxProperties(c2, contact1From2.getId());
|
getMailboxProperties(c2, contact1From2.getId());
|
||||||
assertNotNull(props2.getInboxId());
|
assertNotNull(props2.getInboxId());
|
||||||
|
|
||||||
|
// wait until file containing mailbox properties arrived on mailbox
|
||||||
|
retryUntilSuccessOrTimeout(5_000, 500, () -> {
|
||||||
|
List<MailboxFile> files = api.getFiles(props2, props2.getInboxId());
|
||||||
|
return files.size() == 1;
|
||||||
|
});
|
||||||
|
LOG.info("Mailbox properties uploaded");
|
||||||
|
|
||||||
// send message and wait for it to arrive via mailbox
|
// send message and wait for it to arrive via mailbox
|
||||||
broadcastMessage(c1);
|
broadcastMessage(c1);
|
||||||
|
|
||||||
// wait until file arrived on mailbox
|
// wait until file with broadcast message arrived on mailbox
|
||||||
retryUntilSuccessOrTimeout(5_000, 500, () -> {
|
retryUntilSuccessOrTimeout(10_000, 500, () -> {
|
||||||
List<MailboxFile> files = api.getFiles(props2, props2.getInboxId());
|
List<MailboxFile> files = api.getFiles(props2, props2.getInboxId());
|
||||||
return files.size() > 1;
|
return files.size() == 2;
|
||||||
});
|
});
|
||||||
|
LOG.info("Broadcast message uploaded");
|
||||||
|
|
||||||
// wait for message to arrive
|
// wait for message to arrive
|
||||||
// this might require 2nd download cycle after Tor reachability period
|
// this might require 2nd download cycle after Tor reachability period
|
||||||
|
LOG.info("Waiting for delivery of broadcast message");
|
||||||
awaitPendingMessageDelivery(1);
|
awaitPendingMessageDelivery(1);
|
||||||
|
|
||||||
// assert that message arrived for c2
|
// assert that message arrived for c2
|
||||||
assertNumMessages(c2, contact1From2.getId(), 1);
|
assertNumMessages(c2, contact1From2.getId(), 1);
|
||||||
|
|
||||||
// all files were deleted from mailbox
|
// all files were deleted from mailbox
|
||||||
assertEquals(0, api.getFiles(props2, props2.getInboxId()).size());
|
assertEquals(0, api.getFiles(props2, props2.getInboxId()).size());
|
||||||
|
|||||||
Reference in New Issue
Block a user