mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Fix integration tests
First problem was a race condition with message delivery and the second one due to the fact that we no longer plan to allow adding of additional blogs, so the test for that has simply been removed.
This commit is contained in:
@@ -241,32 +241,6 @@ public class BlogManagerTest {
|
|||||||
stopLifecycles();
|
stopLifecycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddAndRemoveBlog() throws Exception {
|
|
||||||
startLifecycles();
|
|
||||||
defaultInit();
|
|
||||||
|
|
||||||
String name = "Test Blog";
|
|
||||||
String desc = "Description";
|
|
||||||
|
|
||||||
// add blog
|
|
||||||
Blog blog = blogManager0.addBlog(author0, name, desc);
|
|
||||||
Collection<Blog> blogs0 = blogManager0.getBlogs();
|
|
||||||
assertEquals(3, blogs0.size());
|
|
||||||
assertTrue(blogs0.contains(blog));
|
|
||||||
assertEquals(2, blogManager0.getBlogs(author0).size());
|
|
||||||
assertTrue(blogManager0.canBeRemoved(blog.getId()));
|
|
||||||
|
|
||||||
// remove blog
|
|
||||||
blogManager0.removeBlog(blog);
|
|
||||||
blogs0 = blogManager0.getBlogs();
|
|
||||||
assertEquals(2, blogs0.size());
|
|
||||||
assertFalse(blogs0.contains(blog));
|
|
||||||
assertEquals(1, blogManager0.getBlogs(author0).size());
|
|
||||||
|
|
||||||
stopLifecycles();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanNotRemoveContactsPersonalBlog() throws Exception {
|
public void testCanNotRemoveContactsPersonalBlog() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
|
|||||||
@@ -423,13 +423,11 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
respond = false;
|
respond = false;
|
||||||
|
|
||||||
// sync first request message and leave message
|
// sync first request message and leave message
|
||||||
syncToInvitee();
|
deliverMessage(sync0, contactId0, sync1, contactId1, 2,
|
||||||
|
"Sharer to Invitee");
|
||||||
eventWaiter.await(TIMEOUT, 1);
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
assertTrue(listener1.requestReceived);
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
// wait also for second message to arrive
|
|
||||||
msgWaiter.await(TIMEOUT, 1);
|
|
||||||
|
|
||||||
// ensure that invitee has no forum invitations available
|
// ensure that invitee has no forum invitations available
|
||||||
assertEquals(0, forumSharingManager1.getInvitations().size());
|
assertEquals(0, forumSharingManager1.getInvitations().size());
|
||||||
assertEquals(0, forumManager1.getForums().size());
|
assertEquals(0, forumManager1.getForums().size());
|
||||||
@@ -446,13 +444,11 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
forumManager0.removeForum(forum0);
|
forumManager0.removeForum(forum0);
|
||||||
|
|
||||||
// sync first request message and leave message
|
// sync first request message and leave message
|
||||||
syncToInvitee();
|
deliverMessage(sync0, contactId0, sync1, contactId1, 2,
|
||||||
|
"Sharer to Invitee");
|
||||||
eventWaiter.await(TIMEOUT, 1);
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
assertTrue(listener1.requestReceived);
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
// wait also for second message to arrive
|
|
||||||
msgWaiter.await(TIMEOUT, 1);
|
|
||||||
|
|
||||||
// ensure that invitee has no forum invitations available
|
// ensure that invitee has no forum invitations available
|
||||||
assertEquals(0, forumSharingManager1.getInvitations().size());
|
assertEquals(0, forumSharingManager1.getInvitations().size());
|
||||||
assertEquals(1, forumManager1.getForums().size());
|
assertEquals(1, forumManager1.getForums().size());
|
||||||
@@ -764,7 +760,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
forumSharingManager2
|
forumSharingManager2
|
||||||
.sendInvitation(forum0.getId(), contactId1, null);
|
.sendInvitation(forum0.getId(), contactId1, null);
|
||||||
// sync second request message
|
// sync second request message
|
||||||
deliverMessage(sync2, contactId2, sync1, contactId1,
|
deliverMessage(sync2, contactId2, sync1, contactId1, 1,
|
||||||
"Sharer2 to Invitee");
|
"Sharer2 to Invitee");
|
||||||
|
|
||||||
// make sure we now have two invitations to the same forum available
|
// make sure we now have two invitations to the same forum available
|
||||||
@@ -785,7 +781,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
Contact c2 = contactManager1.getContact(contactId2);
|
Contact c2 = contactManager1.getContact(contactId2);
|
||||||
forumSharingManager1.respondToInvitation(forum0, c2, true);
|
forumSharingManager1.respondToInvitation(forum0, c2, true);
|
||||||
// sync response
|
// sync response
|
||||||
deliverMessage(sync1, contactId21, sync2, contactId2,
|
deliverMessage(sync1, contactId21, sync2, contactId2, 1,
|
||||||
"Invitee to Sharer2");
|
"Invitee to Sharer2");
|
||||||
eventWaiter.await(TIMEOUT, 1);
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
assertTrue(listener2.responseReceived);
|
assertTrue(listener2.responseReceived);
|
||||||
@@ -924,8 +920,8 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
|
|
||||||
private class SharerListener implements EventListener {
|
private class SharerListener implements EventListener {
|
||||||
|
|
||||||
volatile boolean requestReceived = false;
|
private volatile boolean requestReceived = false;
|
||||||
volatile boolean responseReceived = false;
|
private volatile boolean responseReceived = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void eventOccurred(Event e) {
|
public void eventOccurred(Event e) {
|
||||||
@@ -964,17 +960,17 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
|
|
||||||
private class InviteeListener implements EventListener {
|
private class InviteeListener implements EventListener {
|
||||||
|
|
||||||
volatile boolean requestReceived = false;
|
private volatile boolean requestReceived = false;
|
||||||
volatile boolean responseReceived = false;
|
private volatile boolean responseReceived = false;
|
||||||
|
|
||||||
private final boolean accept, answer;
|
private final boolean accept, answer;
|
||||||
|
|
||||||
InviteeListener(boolean accept, boolean answer) {
|
private InviteeListener(boolean accept, boolean answer) {
|
||||||
this.accept = accept;
|
this.accept = accept;
|
||||||
this.answer = answer;
|
this.answer = answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
InviteeListener(boolean accept) {
|
private InviteeListener(boolean accept) {
|
||||||
this(accept, true);
|
this(accept, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1109,17 +1105,17 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void syncToInvitee() throws IOException, TimeoutException {
|
private void syncToInvitee() throws IOException, TimeoutException {
|
||||||
deliverMessage(sync0, contactId0, sync1, contactId1,
|
deliverMessage(sync0, contactId0, sync1, contactId1, 1,
|
||||||
"Sharer to Invitee");
|
"Sharer to Invitee");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncToSharer() throws IOException, TimeoutException {
|
private void syncToSharer() throws IOException, TimeoutException {
|
||||||
deliverMessage(sync1, contactId1, sync0, contactId0,
|
deliverMessage(sync1, contactId1, sync0, contactId0, 1,
|
||||||
"Invitee to Sharer");
|
"Invitee to Sharer");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
||||||
SyncSessionFactory toSync, ContactId toId, String debug)
|
SyncSessionFactory toSync, ContactId toId, int num, String debug)
|
||||||
throws IOException, TimeoutException {
|
throws IOException, TimeoutException {
|
||||||
|
|
||||||
if (debug != null) LOG.info("TEST: Sending message from " + debug);
|
if (debug != null) LOG.info("TEST: Sending message from " + debug);
|
||||||
@@ -1140,7 +1136,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
// wait for message to actually arrive
|
// wait for message to actually arrive
|
||||||
msgWaiter.await(TIMEOUT, 1);
|
msgWaiter.await(TIMEOUT, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectEagerSingletons(
|
private void injectEagerSingletons(
|
||||||
|
|||||||
Reference in New Issue
Block a user