diff --git a/briar-core/src/test/java/org/briarproject/briar/sharing/AbstractAutoDeleteIntegrationTest.java b/briar-core/src/test/java/org/briarproject/briar/sharing/AbstractAutoDeleteIntegrationTest.java index ec5d60da6..a60c85764 100644 --- a/briar-core/src/test/java/org/briarproject/briar/sharing/AbstractAutoDeleteIntegrationTest.java +++ b/briar-core/src/test/java/org/briarproject/briar/sharing/AbstractAutoDeleteIntegrationTest.java @@ -19,19 +19,18 @@ import static org.junit.Assert.assertTrue; public abstract class AbstractAutoDeleteIntegrationTest extends AbstractAutoDeleteTest { - protected SharingManager sharingManager0; - protected Shareable shareable; - protected Class> - responseReceivedEventClass; + protected abstract SharingManager getSharingManager0(); - protected void testAutoDeclinedSharing( - SharingManager sharingManager0, - Shareable shareable) throws Exception { + protected abstract Shareable getShareable(); + + protected abstract Class> getResponseReceivedEventClass(); + + protected void testAutoDeclinedSharing() throws Exception { setAutoDeleteTimer(c0, contactId1From0, MIN_AUTO_DELETE_TIMER_MS); // Send invitation - sharingManager0.sendInvitation( - shareable.getId(), contactId1From0, "This shareable!"); + getSharingManager0().sendInvitation( + getShareable().getId(), contactId1From0, "This shareable!"); // The message should have been added to 0's view of the conversation assertGroupCount(c0, contactId1From0, 1, 0); @@ -100,7 +99,7 @@ public abstract class AbstractAutoDeleteIntegrationTest // view of the conversation and the invitation auto-declined c0.getTimeTravel().addCurrentTimeMillis(1); ConversationMessageReceivedEvent e = - assertEvent(c1, responseReceivedEventClass, + assertEvent(c1, getResponseReceivedEventClass(), () -> c1.getTimeTravel().addCurrentTimeMillis(1) ); // assert that the proper event got broadcast @@ -128,8 +127,8 @@ public abstract class AbstractAutoDeleteIntegrationTest waitForEvents(c1); // 0 can invite 1 again - assertTrue(sharingManager0 - .canBeShared(shareable.getId(), contact1From0)); + assertTrue(getSharingManager0() + .canBeShared(getShareable().getId(), contact1From0)); // Before 1's timer elapses, 1 should still see the auto-decline message c0.getTimeTravel().addCurrentTimeMillis(timerLatency - 1); @@ -165,11 +164,12 @@ public abstract class AbstractAutoDeleteIntegrationTest assertEquals(0, getMessageHeaders(c0, contactId1From0).size()); // 0 can invite 1 again and really does invite - assertTrue(sharingManager0 - .canBeShared(shareable.getId(), contact1From0)); + assertTrue(getSharingManager0() + .canBeShared(getShareable().getId(), contact1From0)); // Send invitation - sharingManager0.sendInvitation(shareable.getId(), contactId1From0, - "This shareable, please be quick!"); + getSharingManager0() + .sendInvitation(getShareable().getId(), contactId1From0, + "This shareable, please be quick!"); sync0To1(1, true); assertGroupCount(c1, contactId0From1, 1, 1); } diff --git a/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteBlogIntegrationTest.java b/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteBlogIntegrationTest.java index 0e3b1f402..0f393328d 100644 --- a/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteBlogIntegrationTest.java +++ b/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteBlogIntegrationTest.java @@ -2,6 +2,10 @@ package org.briarproject.briar.sharing; import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent; import org.briarproject.briar.api.conversation.ConversationManager; +import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent; +import org.briarproject.briar.api.sharing.InvitationResponse; +import org.briarproject.briar.api.sharing.Shareable; +import org.briarproject.briar.api.sharing.SharingManager; import org.briarproject.briar.test.BriarIntegrationTestComponent; import org.junit.Before; import org.junit.Test; @@ -9,6 +13,11 @@ import org.junit.Test; public class AutoDeleteBlogIntegrationTest extends AbstractAutoDeleteIntegrationTest { + private SharingManager sharingManager0; + private Shareable shareable; + private Class> + responseReceivedEventClass; + @Before @Override public void setUp() throws Exception { @@ -26,8 +35,23 @@ public class AutoDeleteBlogIntegrationTest return component.getBlogSharingManager(); } + @Override + protected SharingManager getSharingManager0() { + return sharingManager0; + } + + @Override + protected Shareable getShareable() { + return shareable; + } + + @Override + protected Class> getResponseReceivedEventClass() { + return responseReceivedEventClass; + } + @Test public void testAutoDeclinedBlogSharing() throws Exception { - testAutoDeclinedSharing(sharingManager0, shareable); + testAutoDeclinedSharing(); } } diff --git a/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteForumIntegrationTest.java b/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteForumIntegrationTest.java index 07815e34d..eb2d14fa0 100644 --- a/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteForumIntegrationTest.java +++ b/briar-core/src/test/java/org/briarproject/briar/sharing/AutoDeleteForumIntegrationTest.java @@ -1,7 +1,11 @@ package org.briarproject.briar.sharing; import org.briarproject.briar.api.conversation.ConversationManager; +import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent; import org.briarproject.briar.api.forum.event.ForumInvitationResponseReceivedEvent; +import org.briarproject.briar.api.sharing.InvitationResponse; +import org.briarproject.briar.api.sharing.Shareable; +import org.briarproject.briar.api.sharing.SharingManager; import org.briarproject.briar.test.BriarIntegrationTestComponent; import org.junit.Before; import org.junit.Test; @@ -9,6 +13,11 @@ import org.junit.Test; public class AutoDeleteForumIntegrationTest extends AbstractAutoDeleteIntegrationTest { + private SharingManager sharingManager0; + protected Shareable shareable; + protected Class> + responseReceivedEventClass; + @Before @Override public void setUp() throws Exception { @@ -25,8 +34,23 @@ public class AutoDeleteForumIntegrationTest return component.getForumSharingManager(); } + @Override + protected SharingManager getSharingManager0() { + return sharingManager0; + } + + @Override + protected Shareable getShareable() { + return shareable; + } + + @Override + protected Class> getResponseReceivedEventClass() { + return responseReceivedEventClass; + } + @Test public void testAutoDeclinedForumSharing() throws Exception { - testAutoDeclinedSharing(sharingManager0, shareable); + testAutoDeclinedSharing(); } }