mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Keep members in subclasses and use getters
This commit is contained in:
committed by
Torsten Grote
parent
ec3360400c
commit
7006f765a6
@@ -19,19 +19,18 @@ import static org.junit.Assert.assertTrue;
|
||||
public abstract class AbstractAutoDeleteIntegrationTest
|
||||
extends AbstractAutoDeleteTest {
|
||||
|
||||
protected SharingManager<? extends Shareable> sharingManager0;
|
||||
protected Shareable shareable;
|
||||
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>>
|
||||
responseReceivedEventClass;
|
||||
protected abstract SharingManager<? extends Shareable> getSharingManager0();
|
||||
|
||||
protected void testAutoDeclinedSharing(
|
||||
SharingManager<? extends Shareable> sharingManager0,
|
||||
Shareable shareable) throws Exception {
|
||||
protected abstract Shareable getShareable();
|
||||
|
||||
protected abstract Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> 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<? extends InvitationResponse> 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);
|
||||
}
|
||||
|
||||
@@ -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<? extends Shareable> sharingManager0;
|
||||
private Shareable shareable;
|
||||
private Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>>
|
||||
responseReceivedEventClass;
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
@@ -26,8 +35,23 @@ public class AutoDeleteBlogIntegrationTest
|
||||
return component.getBlogSharingManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SharingManager<? extends Shareable> getSharingManager0() {
|
||||
return sharingManager0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shareable getShareable() {
|
||||
return shareable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass() {
|
||||
return responseReceivedEventClass;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoDeclinedBlogSharing() throws Exception {
|
||||
testAutoDeclinedSharing(sharingManager0, shareable);
|
||||
testAutoDeclinedSharing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<? extends Shareable> sharingManager0;
|
||||
protected Shareable shareable;
|
||||
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>>
|
||||
responseReceivedEventClass;
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
@@ -25,8 +34,23 @@ public class AutoDeleteForumIntegrationTest
|
||||
return component.getForumSharingManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SharingManager<? extends Shareable> getSharingManager0() {
|
||||
return sharingManager0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shareable getShareable() {
|
||||
return shareable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass() {
|
||||
return responseReceivedEventClass;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoDeclinedForumSharing() throws Exception {
|
||||
testAutoDeclinedSharing(sharingManager0, shareable);
|
||||
testAutoDeclinedSharing();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user