mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Refactor integration tests to allow clock to be replaced.
This commit is contained in:
@@ -21,7 +21,6 @@ import org.briarproject.bramble.rendezvous.RendezvousModule;
|
|||||||
import org.briarproject.bramble.settings.SettingsModule;
|
import org.briarproject.bramble.settings.SettingsModule;
|
||||||
import org.briarproject.bramble.sync.SyncModule;
|
import org.briarproject.bramble.sync.SyncModule;
|
||||||
import org.briarproject.bramble.sync.validation.ValidationModule;
|
import org.briarproject.bramble.sync.validation.ValidationModule;
|
||||||
import org.briarproject.bramble.system.ClockModule;
|
|
||||||
import org.briarproject.bramble.transport.TransportModule;
|
import org.briarproject.bramble.transport.TransportModule;
|
||||||
import org.briarproject.bramble.versioning.VersioningModule;
|
import org.briarproject.bramble.versioning.VersioningModule;
|
||||||
|
|
||||||
@@ -29,7 +28,6 @@ import dagger.Module;
|
|||||||
|
|
||||||
@Module(includes = {
|
@Module(includes = {
|
||||||
ClientModule.class,
|
ClientModule.class,
|
||||||
ClockModule.class,
|
|
||||||
ConnectionModule.class,
|
ConnectionModule.class,
|
||||||
ContactModule.class,
|
ContactModule.class,
|
||||||
CryptoModule.class,
|
CryptoModule.class,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import dagger.Provides;
|
|||||||
DefaultEventExecutorModule.class,
|
DefaultEventExecutorModule.class,
|
||||||
DefaultTaskSchedulerModule.class,
|
DefaultTaskSchedulerModule.class,
|
||||||
DefaultWakefulIoExecutorModule.class,
|
DefaultWakefulIoExecutorModule.class,
|
||||||
|
TestClockModule.class,
|
||||||
TestDatabaseConfigModule.class,
|
TestDatabaseConfigModule.class,
|
||||||
TestPluginConfigModule.class,
|
TestPluginConfigModule.class,
|
||||||
TestSecureRandomModule.class
|
TestSecureRandomModule.class
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.briarproject.bramble.test;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
|
import org.briarproject.bramble.system.SystemClock;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
|
@Module
|
||||||
|
public class TestClockModule {
|
||||||
|
|
||||||
|
private final Clock clock;
|
||||||
|
|
||||||
|
public TestClockModule() {
|
||||||
|
clock = new SystemClock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestClockModule(AtomicLong time) {
|
||||||
|
clock = new SettableClock(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
Clock provideClock() {
|
||||||
|
return clock;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,9 @@ import org.briarproject.bramble.system.JavaSystemModule;
|
|||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
|
|
||||||
@Module(includes = {
|
@Module(includes = {
|
||||||
|
CircumventionModule.class,
|
||||||
JavaNetworkModule.class,
|
JavaNetworkModule.class,
|
||||||
JavaSystemModule.class,
|
JavaSystemModule.class,
|
||||||
CircumventionModule.class,
|
|
||||||
SocksModule.class
|
SocksModule.class
|
||||||
})
|
})
|
||||||
public class BrambleJavaModule {
|
public class BrambleJavaModule {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.briarproject.bramble.api.system.AndroidWakeLockManager;
|
|||||||
import org.briarproject.bramble.api.system.Clock;
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.system.LocationUtils;
|
import org.briarproject.bramble.api.system.LocationUtils;
|
||||||
import org.briarproject.bramble.plugin.tor.CircumventionProvider;
|
import org.briarproject.bramble.plugin.tor.CircumventionProvider;
|
||||||
|
import org.briarproject.bramble.system.ClockModule;
|
||||||
import org.briarproject.briar.BriarCoreEagerSingletons;
|
import org.briarproject.briar.BriarCoreEagerSingletons;
|
||||||
import org.briarproject.briar.BriarCoreModule;
|
import org.briarproject.briar.BriarCoreModule;
|
||||||
import org.briarproject.briar.android.attachment.AttachmentModule;
|
import org.briarproject.briar.android.attachment.AttachmentModule;
|
||||||
@@ -81,6 +82,7 @@ import dagger.Component;
|
|||||||
BriarAccountModule.class,
|
BriarAccountModule.class,
|
||||||
AppModule.class,
|
AppModule.class,
|
||||||
AttachmentModule.class,
|
AttachmentModule.class,
|
||||||
|
ClockModule.class,
|
||||||
MediaModule.class
|
MediaModule.class
|
||||||
})
|
})
|
||||||
public interface AndroidComponent
|
public interface AndroidComponent
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.briar.android.logging;
|
package org.briarproject.briar.android.logging;
|
||||||
|
|
||||||
import org.briarproject.bramble.BrambleCoreModule;
|
import org.briarproject.bramble.BrambleCoreModule;
|
||||||
|
import org.briarproject.bramble.system.ClockModule;
|
||||||
import org.briarproject.bramble.test.TestSecureRandomModule;
|
import org.briarproject.bramble.test.TestSecureRandomModule;
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
@@ -11,6 +12,7 @@ import dagger.Component;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Component(modules = {
|
@Component(modules = {
|
||||||
|
ClockModule.class,
|
||||||
BrambleCoreModule.class,
|
BrambleCoreModule.class,
|
||||||
TestSecureRandomModule.class,
|
TestSecureRandomModule.class,
|
||||||
LoggingModule.class,
|
LoggingModule.class,
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class BlogManagerIntegrationTest
|
|||||||
|
|
||||||
// add a post to blog0
|
// add a post to blog0
|
||||||
BlogPost p = blogPostFactory.createBlogPost(blog0.getId(),
|
BlogPost p = blogPostFactory.createBlogPost(blog0.getId(),
|
||||||
clock.currentTimeMillis(), null, author0, text);
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// check that post is now in blog0
|
// check that post is now in blog0
|
||||||
@@ -158,9 +158,8 @@ public class BlogManagerIntegrationTest
|
|||||||
public void testBlogPostInWrongBlog() throws Exception {
|
public void testBlogPostInWrongBlog() throws Exception {
|
||||||
// add a post to blog1
|
// add a post to blog1
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
BlogPost p = blogPostFactory
|
BlogPost p = blogPostFactory.createBlogPost(blog1.getId(),
|
||||||
.createBlogPost(blog1.getId(), clock.currentTimeMillis(), null,
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
author0, text);
|
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// check that post is now in blog1
|
// check that post is now in blog1
|
||||||
@@ -197,9 +196,8 @@ public class BlogManagerIntegrationTest
|
|||||||
public void testBlogComment() throws Exception {
|
public void testBlogComment() throws Exception {
|
||||||
// add a post to blog0
|
// add a post to blog0
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
BlogPost p = blogPostFactory
|
BlogPost p = blogPostFactory.createBlogPost(blog0.getId(),
|
||||||
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
author0, text);
|
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// sync the post over
|
// sync the post over
|
||||||
@@ -242,9 +240,8 @@ public class BlogManagerIntegrationTest
|
|||||||
public void testBlogCommentOnOwnPost() throws Exception {
|
public void testBlogCommentOnOwnPost() throws Exception {
|
||||||
// add a post to blog0
|
// add a post to blog0
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
BlogPost p = blogPostFactory
|
BlogPost p = blogPostFactory.createBlogPost(blog0.getId(),
|
||||||
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
author0, text);
|
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// get header of own post
|
// get header of own post
|
||||||
@@ -278,9 +275,8 @@ public class BlogManagerIntegrationTest
|
|||||||
public void testCommentOnComment() throws Exception {
|
public void testCommentOnComment() throws Exception {
|
||||||
// add a post to blog0
|
// add a post to blog0
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
BlogPost p = blogPostFactory
|
BlogPost p = blogPostFactory.createBlogPost(blog0.getId(),
|
||||||
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
author0, text);
|
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// sync the post over
|
// sync the post over
|
||||||
@@ -366,9 +362,8 @@ public class BlogManagerIntegrationTest
|
|||||||
public void testCommentOnOwnComment() throws Exception {
|
public void testCommentOnOwnComment() throws Exception {
|
||||||
// add a post to blog0
|
// add a post to blog0
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
BlogPost p = blogPostFactory
|
BlogPost p = blogPostFactory.createBlogPost(blog0.getId(),
|
||||||
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
author0, text);
|
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// sync the post over
|
// sync the post over
|
||||||
@@ -411,9 +406,8 @@ public class BlogManagerIntegrationTest
|
|||||||
|
|
||||||
// add a feed post to rssBlog
|
// add a feed post to rssBlog
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
BlogPost p = blogPostFactory
|
BlogPost p = blogPostFactory.createBlogPost(rssBlog.getId(),
|
||||||
.createBlogPost(rssBlog.getId(), clock.currentTimeMillis(),
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
null, author0, text);
|
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// make sure it got saved as an RSS feed post
|
// make sure it got saved as an RSS feed post
|
||||||
@@ -430,9 +424,8 @@ public class BlogManagerIntegrationTest
|
|||||||
public void testFeedReblog() throws Exception {
|
public void testFeedReblog() throws Exception {
|
||||||
// add a feed post to rssBlog
|
// add a feed post to rssBlog
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
BlogPost p = blogPostFactory
|
BlogPost p = blogPostFactory.createBlogPost(rssBlog.getId(),
|
||||||
.createBlogPost(rssBlog.getId(), clock.currentTimeMillis(),
|
c0.getClock().currentTimeMillis(), null, author0, text);
|
||||||
null, author0, text);
|
|
||||||
blogManager0.addLocalPost(p);
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
// reblog feed post to own blog
|
// reblog feed post to own blog
|
||||||
|
|||||||
@@ -84,9 +84,9 @@ public class ForumManagerTest
|
|||||||
@Test
|
@Test
|
||||||
public void testForumPost() throws Exception {
|
public void testForumPost() throws Exception {
|
||||||
assertEquals(1, forumManager0.getForums().size());
|
assertEquals(1, forumManager0.getForums().size());
|
||||||
long ms1 = clock.currentTimeMillis() - 1000L;
|
long ms1 = c0.getClock().currentTimeMillis() - 1000L;
|
||||||
String text1 = "some forum text";
|
String text1 = "some forum text";
|
||||||
long ms2 = clock.currentTimeMillis();
|
long ms2 = c0.getClock().currentTimeMillis();
|
||||||
String text2 = "some other forum text";
|
String text2 = "some other forum text";
|
||||||
ForumPost post1 =
|
ForumPost post1 =
|
||||||
createForumPost(forum0.getGroup().getId(), null, text1, ms1);
|
createForumPost(forum0.getGroup().getId(), null, text1, ms1);
|
||||||
@@ -136,7 +136,7 @@ public class ForumManagerTest
|
|||||||
@Test
|
@Test
|
||||||
public void testForumPostDelivery() throws Exception {
|
public void testForumPostDelivery() throws Exception {
|
||||||
// add one forum post
|
// add one forum post
|
||||||
long time = clock.currentTimeMillis();
|
long time = c0.getClock().currentTimeMillis();
|
||||||
ForumPost post1 = createForumPost(groupId0, null, "a", time);
|
ForumPost post1 = createForumPost(groupId0, null, "a", time);
|
||||||
forumManager0.addLocalPost(post1);
|
forumManager0.addLocalPost(post1);
|
||||||
assertEquals(1, forumManager0.getPostHeaders(groupId0).size());
|
assertEquals(1, forumManager0.getPostHeaders(groupId0).size());
|
||||||
@@ -150,7 +150,7 @@ public class ForumManagerTest
|
|||||||
assertGroupCount(messageTracker1, groupId0, 1, 1, time);
|
assertGroupCount(messageTracker1, groupId0, 1, 1, time);
|
||||||
|
|
||||||
// add another forum post
|
// add another forum post
|
||||||
long time2 = clock.currentTimeMillis();
|
long time2 = c0.getClock().currentTimeMillis();
|
||||||
ForumPost post2 = createForumPost(groupId0, null, "b", time2);
|
ForumPost post2 = createForumPost(groupId0, null, "b", time2);
|
||||||
forumManager1.addLocalPost(post2);
|
forumManager1.addLocalPost(post2);
|
||||||
assertEquals(1, forumManager0.getPostHeaders(groupId0).size());
|
assertEquals(1, forumManager0.getPostHeaders(groupId0).size());
|
||||||
@@ -167,7 +167,7 @@ public class ForumManagerTest
|
|||||||
@Test
|
@Test
|
||||||
public void testForumPostDeliveredAfterParent() throws Exception {
|
public void testForumPostDeliveredAfterParent() throws Exception {
|
||||||
// add one forum post without the parent
|
// add one forum post without the parent
|
||||||
long time = clock.currentTimeMillis();
|
long time = c0.getClock().currentTimeMillis();
|
||||||
ForumPost post1 = createForumPost(groupId0, null, "a", time);
|
ForumPost post1 = createForumPost(groupId0, null, "a", time);
|
||||||
ForumPost post2 = createForumPost(groupId0, post1, "a", time);
|
ForumPost post2 = createForumPost(groupId0, post1, "a", time);
|
||||||
forumManager0.addLocalPost(post2);
|
forumManager0.addLocalPost(post2);
|
||||||
@@ -199,7 +199,7 @@ public class ForumManagerTest
|
|||||||
sync1To0(1, true);
|
sync1To0(1, true);
|
||||||
|
|
||||||
// add one forum post with a parent in another forum
|
// add one forum post with a parent in another forum
|
||||||
long time = clock.currentTimeMillis();
|
long time = c0.getClock().currentTimeMillis();
|
||||||
ForumPost post1 = createForumPost(g1, null, "a", time);
|
ForumPost post1 = createForumPost(g1, null, "a", time);
|
||||||
ForumPost post = createForumPost(groupId0, post1, "b", time);
|
ForumPost post = createForumPost(groupId0, post1, "b", time);
|
||||||
forumManager0.addLocalPost(post);
|
forumManager0.addLocalPost(post);
|
||||||
|
|||||||
@@ -1042,10 +1042,12 @@ public class IntroductionIntegrationTest
|
|||||||
contactManager1.removeContact(contactId0From1);
|
contactManager1.removeContact(contactId0From1);
|
||||||
SecretKey rootKey0_1 = getSecretKey();
|
SecretKey rootKey0_1 = getSecretKey();
|
||||||
contactId1From0 = contactManager0.addContact(author1, author0.getId(),
|
contactId1From0 = contactManager0.addContact(author1, author0.getId(),
|
||||||
rootKey0_1, clock.currentTimeMillis(), true, true, true);
|
rootKey0_1, c0.getClock().currentTimeMillis(), true, true,
|
||||||
|
true);
|
||||||
contact1From0 = contactManager0.getContact(contactId1From0);
|
contact1From0 = contactManager0.getContact(contactId1From0);
|
||||||
contactId0From1 = contactManager1.addContact(author0, author1.getId(),
|
contactId0From1 = contactManager1.addContact(author0, author1.getId(),
|
||||||
rootKey0_1, clock.currentTimeMillis(), false, true, true);
|
rootKey0_1, c1.getClock().currentTimeMillis(), false, true,
|
||||||
|
true);
|
||||||
contact0From1 = contactManager1.getContact(contactId0From1);
|
contact0From1 = contactManager1.getContact(contactId0From1);
|
||||||
|
|
||||||
// Sync initial client versioning updates and transport properties
|
// Sync initial client versioning updates and transport properties
|
||||||
@@ -1169,7 +1171,7 @@ public class IntroductionIntegrationTest
|
|||||||
m -> new AcceptMessage(m.getMessageId(), m.getGroupId(),
|
m -> new AcceptMessage(m.getMessageId(), m.getGroupId(),
|
||||||
m.getTimestamp(), m.getPreviousMessageId(),
|
m.getTimestamp(), m.getPreviousMessageId(),
|
||||||
m.getSessionId(), m.getEphemeralPublicKey(),
|
m.getSessionId(), m.getEphemeralPublicKey(),
|
||||||
clock.currentTimeMillis(),
|
c0.getClock().currentTimeMillis(),
|
||||||
m.getTransportProperties(), NO_AUTO_DELETE_TIMER)
|
m.getTransportProperties(), NO_AUTO_DELETE_TIMER)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ public class MessagingManagerIntegrationTest
|
|||||||
// send legacy message
|
// send legacy message
|
||||||
GroupId g = c0.getMessagingManager().getConversationId(contactId);
|
GroupId g = c0.getMessagingManager().getConversationId(contactId);
|
||||||
PrivateMessage m0 = messageFactory.createLegacyPrivateMessage(g,
|
PrivateMessage m0 = messageFactory.createLegacyPrivateMessage(g,
|
||||||
clock.currentTimeMillis(), getRandomString(42));
|
c0.getClock().currentTimeMillis(), getRandomString(42));
|
||||||
c0.getMessagingManager().addLocalMessage(m0);
|
c0.getMessagingManager().addLocalMessage(m0);
|
||||||
syncMessage(c0, c1, contactId, 1, true);
|
syncMessage(c0, c1, contactId, 1, true);
|
||||||
|
|
||||||
@@ -384,7 +384,8 @@ public class MessagingManagerIntegrationTest
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
GroupId g = from.getMessagingManager().getConversationId(contactId);
|
GroupId g = from.getMessagingManager().getConversationId(contactId);
|
||||||
PrivateMessage m = messageFactory.createPrivateMessage(g,
|
PrivateMessage m = messageFactory.createPrivateMessage(g,
|
||||||
clock.currentTimeMillis(), text, attachments, autoDeleteTimer);
|
from.getClock().currentTimeMillis(), text, attachments,
|
||||||
|
autoDeleteTimer);
|
||||||
from.getMessagingManager().addLocalMessage(m);
|
from.getMessagingManager().addLocalMessage(m);
|
||||||
syncMessage(from, to, contactId, 1 + attachments.size(), true);
|
syncMessage(from, to, contactId, 1 + attachments.size(), true);
|
||||||
return m;
|
return m;
|
||||||
@@ -395,7 +396,7 @@ public class MessagingManagerIntegrationTest
|
|||||||
GroupId g = c.getMessagingManager().getConversationId(contactId);
|
GroupId g = c.getMessagingManager().getConversationId(contactId);
|
||||||
InputStream stream = new ByteArrayInputStream(getRandomBytes(42));
|
InputStream stream = new ByteArrayInputStream(getRandomBytes(42));
|
||||||
return c.getMessagingManager().addLocalAttachment(g,
|
return c.getMessagingManager().addLocalAttachment(g,
|
||||||
clock.currentTimeMillis(), "image/jpeg", stream);
|
c.getClock().currentTimeMillis(), "image/jpeg", stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<ConversationMessageHeader> getMessages(
|
private Collection<ConversationMessageHeader> getMessages(
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class PrivateGroupIntegrationTest
|
|||||||
privateGroup0 =
|
privateGroup0 =
|
||||||
privateGroupFactory.createPrivateGroup("Test Group", author0);
|
privateGroupFactory.createPrivateGroup("Test Group", author0);
|
||||||
groupId0 = privateGroup0.getId();
|
groupId0 = privateGroup0.getId();
|
||||||
long joinTime = clock.currentTimeMillis();
|
long joinTime = c0.getClock().currentTimeMillis();
|
||||||
GroupMessage joinMsg0 = groupMessageFactory
|
GroupMessage joinMsg0 = groupMessageFactory
|
||||||
.createJoinMessage(groupId0, joinTime, author0);
|
.createJoinMessage(groupId0, joinTime, author0);
|
||||||
groupManager0.addPrivateGroup(privateGroup0, joinMsg0, true);
|
groupManager0.addPrivateGroup(privateGroup0, joinMsg0, true);
|
||||||
@@ -92,7 +92,8 @@ public class PrivateGroupIntegrationTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMembership() throws Exception {
|
public void testMembership() throws Exception {
|
||||||
sendInvitation(contactId1From0, clock.currentTimeMillis(), "Hi!");
|
sendInvitation(contactId1From0, c0.getClock().currentTimeMillis(),
|
||||||
|
"Hi!");
|
||||||
|
|
||||||
// our group has only one member (ourselves)
|
// our group has only one member (ourselves)
|
||||||
Collection<GroupMember> members = groupManager0.getMembers(groupId0);
|
Collection<GroupMember> members = groupManager0.getMembers(groupId0);
|
||||||
@@ -135,8 +136,10 @@ public class PrivateGroupIntegrationTest
|
|||||||
@Test
|
@Test
|
||||||
public void testRevealContacts() throws Exception {
|
public void testRevealContacts() throws Exception {
|
||||||
// invite two contacts
|
// invite two contacts
|
||||||
sendInvitation(contactId1From0, clock.currentTimeMillis(), "Hi 1!");
|
sendInvitation(contactId1From0, c0.getClock().currentTimeMillis(),
|
||||||
sendInvitation(contactId2From0, clock.currentTimeMillis(), "Hi 2!");
|
"Hi 1!");
|
||||||
|
sendInvitation(contactId2From0, c0.getClock().currentTimeMillis(),
|
||||||
|
"Hi 2!");
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
sync0To2(1, true);
|
sync0To2(1, true);
|
||||||
|
|
||||||
@@ -182,7 +185,7 @@ public class PrivateGroupIntegrationTest
|
|||||||
getGroupMember(groupManager2, author1.getId()).getVisibility());
|
getGroupMember(groupManager2, author1.getId()).getVisibility());
|
||||||
|
|
||||||
// 2 sends a message to the group
|
// 2 sends a message to the group
|
||||||
long time = clock.currentTimeMillis();
|
long time = c2.getClock().currentTimeMillis();
|
||||||
String text = "This is a test message!";
|
String text = "This is a test message!";
|
||||||
MessageId previousMsgId = groupManager2.getPreviousMsgId(groupId0);
|
MessageId previousMsgId = groupManager2.getPreviousMsgId(groupId0);
|
||||||
GroupMessage msg = groupMessageFactory
|
GroupMessage msg = groupMessageFactory
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
addGroup();
|
addGroup();
|
||||||
|
|
||||||
// create and add test message
|
// create and add test message
|
||||||
long time = clock.currentTimeMillis();
|
long time = c0.getClock().currentTimeMillis();
|
||||||
String text = "This is a test message!";
|
String text = "This is a test message!";
|
||||||
MessageId previousMsgId =
|
MessageId previousMsgId =
|
||||||
groupManager0.getPreviousMsgId(groupId0);
|
groupManager0.getPreviousMsgId(groupId0);
|
||||||
@@ -125,7 +125,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
|
|
||||||
// create and add test message with no previousMsgId
|
// create and add test message with no previousMsgId
|
||||||
GroupMessage msg = groupMessageFactory.createGroupMessage(groupId0,
|
GroupMessage msg = groupMessageFactory.createGroupMessage(groupId0,
|
||||||
clock.currentTimeMillis(), null, author0, "test", null);
|
c0.getClock().currentTimeMillis(), null, author0, "test", null);
|
||||||
groupManager0.addLocalMessage(msg);
|
groupManager0.addLocalMessage(msg);
|
||||||
|
|
||||||
// sync test message
|
// sync test message
|
||||||
@@ -136,9 +136,9 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
|
|
||||||
// create and add test message with random previousMsgId
|
// create and add test message with random previousMsgId
|
||||||
MessageId previousMsgId = new MessageId(getRandomId());
|
MessageId previousMsgId = new MessageId(getRandomId());
|
||||||
msg = groupMessageFactory
|
msg = groupMessageFactory.createGroupMessage(groupId0,
|
||||||
.createGroupMessage(groupId0, clock.currentTimeMillis(), null,
|
c0.getClock().currentTimeMillis(), null, author0, "test",
|
||||||
author0, "test", previousMsgId);
|
previousMsgId);
|
||||||
groupManager0.addLocalMessage(msg);
|
groupManager0.addLocalMessage(msg);
|
||||||
|
|
||||||
// sync test message
|
// sync test message
|
||||||
@@ -149,9 +149,9 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
|
|
||||||
// create and add test message with wrong previousMsgId
|
// create and add test message with wrong previousMsgId
|
||||||
previousMsgId = groupManager1.getPreviousMsgId(groupId0);
|
previousMsgId = groupManager1.getPreviousMsgId(groupId0);
|
||||||
msg = groupMessageFactory
|
msg = groupMessageFactory.createGroupMessage(groupId0,
|
||||||
.createGroupMessage(groupId0, clock.currentTimeMillis(), null,
|
c0.getClock().currentTimeMillis(), null, author0, "test",
|
||||||
author0, "test", previousMsgId);
|
previousMsgId);
|
||||||
groupManager0.addLocalMessage(msg);
|
groupManager0.addLocalMessage(msg);
|
||||||
|
|
||||||
// sync test message
|
// sync test message
|
||||||
@@ -168,9 +168,9 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
// create and add test message with random parentMsgId
|
// create and add test message with random parentMsgId
|
||||||
MessageId parentMsgId = new MessageId(getRandomId());
|
MessageId parentMsgId = new MessageId(getRandomId());
|
||||||
MessageId previousMsgId = groupManager0.getPreviousMsgId(groupId0);
|
MessageId previousMsgId = groupManager0.getPreviousMsgId(groupId0);
|
||||||
GroupMessage msg = groupMessageFactory
|
GroupMessage msg = groupMessageFactory.createGroupMessage(groupId0,
|
||||||
.createGroupMessage(groupId0, clock.currentTimeMillis(),
|
c0.getClock().currentTimeMillis(), parentMsgId, author0, "test",
|
||||||
parentMsgId, author0, "test", previousMsgId);
|
previousMsgId);
|
||||||
groupManager0.addLocalMessage(msg);
|
groupManager0.addLocalMessage(msg);
|
||||||
|
|
||||||
// sync test message
|
// sync test message
|
||||||
@@ -181,9 +181,9 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
|
|
||||||
// create and add test message with wrong parentMsgId
|
// create and add test message with wrong parentMsgId
|
||||||
parentMsgId = previousMsgId;
|
parentMsgId = previousMsgId;
|
||||||
msg = groupMessageFactory
|
msg = groupMessageFactory.createGroupMessage(groupId0,
|
||||||
.createGroupMessage(groupId0, clock.currentTimeMillis(),
|
c0.getClock().currentTimeMillis(), parentMsgId, author0, "test",
|
||||||
parentMsgId, author0, "test", previousMsgId);
|
previousMsgId);
|
||||||
groupManager0.addLocalMessage(msg);
|
groupManager0.addLocalMessage(msg);
|
||||||
|
|
||||||
// sync test message
|
// sync test message
|
||||||
@@ -211,7 +211,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
assertEquals(2, groupManager1.getHeaders(groupId0).size());
|
assertEquals(2, groupManager1.getHeaders(groupId0).size());
|
||||||
|
|
||||||
// create and add test message with good timestamp
|
// create and add test message with good timestamp
|
||||||
long time = clock.currentTimeMillis();
|
long time = c0.getClock().currentTimeMillis();
|
||||||
msg = groupMessageFactory
|
msg = groupMessageFactory
|
||||||
.createGroupMessage(groupId0, time, null, author0, "test",
|
.createGroupMessage(groupId0, time, null, author0, "test",
|
||||||
previousMsgId);
|
previousMsgId);
|
||||||
@@ -238,7 +238,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
@Test
|
@Test
|
||||||
public void testWrongJoinMessages1() throws Exception {
|
public void testWrongJoinMessages1() throws Exception {
|
||||||
// author0 joins privateGroup0 with wrong join message
|
// author0 joins privateGroup0 with wrong join message
|
||||||
long joinTime = clock.currentTimeMillis();
|
long joinTime = c0.getClock().currentTimeMillis();
|
||||||
GroupMessage joinMsg0 = groupMessageFactory
|
GroupMessage joinMsg0 = groupMessageFactory
|
||||||
.createJoinMessage(privateGroup0.getId(), joinTime, author0,
|
.createJoinMessage(privateGroup0.getId(), joinTime, author0,
|
||||||
joinTime, getRandomBytes(12));
|
joinTime, getRandomBytes(12));
|
||||||
@@ -251,7 +251,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
contactId1From0, privateGroup0.getId(), SHARED));
|
contactId1From0, privateGroup0.getId(), SHARED));
|
||||||
|
|
||||||
// author1 joins privateGroup0 with wrong timestamp
|
// author1 joins privateGroup0 with wrong timestamp
|
||||||
joinTime = clock.currentTimeMillis();
|
joinTime = c1.getClock().currentTimeMillis();
|
||||||
long inviteTime = joinTime;
|
long inviteTime = joinTime;
|
||||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||||
byte[] creatorSignature = groupInvitationFactory
|
byte[] creatorSignature = groupInvitationFactory
|
||||||
@@ -283,7 +283,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
@Test
|
@Test
|
||||||
public void testWrongJoinMessages2() throws Exception {
|
public void testWrongJoinMessages2() throws Exception {
|
||||||
// author0 joins privateGroup0 with wrong member's join message
|
// author0 joins privateGroup0 with wrong member's join message
|
||||||
long joinTime = clock.currentTimeMillis();
|
long joinTime = c0.getClock().currentTimeMillis();
|
||||||
long inviteTime = joinTime - 1;
|
long inviteTime = joinTime - 1;
|
||||||
BdfList toSign = groupInvitationFactory
|
BdfList toSign = groupInvitationFactory
|
||||||
.createInviteToken(author0.getId(), author0.getId(),
|
.createInviteToken(author0.getId(), author0.getId(),
|
||||||
@@ -303,7 +303,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
contactId1From0, privateGroup0.getId(), SHARED));
|
contactId1From0, privateGroup0.getId(), SHARED));
|
||||||
|
|
||||||
// author1 joins privateGroup0 with wrong signature in join message
|
// author1 joins privateGroup0 with wrong signature in join message
|
||||||
joinTime = clock.currentTimeMillis();
|
joinTime = c1.getClock().currentTimeMillis();
|
||||||
inviteTime = joinTime - 1;
|
inviteTime = joinTime - 1;
|
||||||
// signature uses joiner's key, not creator's key
|
// signature uses joiner's key, not creator's key
|
||||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||||
@@ -365,7 +365,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
contactId2From0, privateGroup0.getId(), SHARED));
|
contactId2From0, privateGroup0.getId(), SHARED));
|
||||||
|
|
||||||
// author2 joins privateGroup0
|
// author2 joins privateGroup0
|
||||||
long joinTime = clock.currentTimeMillis();
|
long joinTime = c2.getClock().currentTimeMillis();
|
||||||
long inviteTime = joinTime - 1;
|
long inviteTime = joinTime - 1;
|
||||||
Contact c2 = contactManager0.getContact(contactId2From0);
|
Contact c2 = contactManager0.getContact(contactId2From0);
|
||||||
byte[] creatorSignature = groupInvitationFactory
|
byte[] creatorSignature = groupInvitationFactory
|
||||||
@@ -447,7 +447,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
|
|
||||||
private void addGroup() throws Exception {
|
private void addGroup() throws Exception {
|
||||||
// author0 joins privateGroup0
|
// author0 joins privateGroup0
|
||||||
long joinTime = clock.currentTimeMillis();
|
long joinTime = c0.getClock().currentTimeMillis();
|
||||||
GroupMessage joinMsg0 = groupMessageFactory
|
GroupMessage joinMsg0 = groupMessageFactory
|
||||||
.createJoinMessage(privateGroup0.getId(), joinTime, author0);
|
.createJoinMessage(privateGroup0.getId(), joinTime, author0);
|
||||||
groupManager0.addPrivateGroup(privateGroup0, joinMsg0, true);
|
groupManager0.addPrivateGroup(privateGroup0, joinMsg0, true);
|
||||||
@@ -459,7 +459,7 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
contactId1From0, privateGroup0.getId(), SHARED));
|
contactId1From0, privateGroup0.getId(), SHARED));
|
||||||
|
|
||||||
// author1 joins privateGroup0
|
// author1 joins privateGroup0
|
||||||
joinTime = clock.currentTimeMillis();
|
joinTime = c1.getClock().currentTimeMillis();
|
||||||
long inviteTime = joinTime - 1;
|
long inviteTime = joinTime - 1;
|
||||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||||
byte[] creatorSignature = groupInvitationFactory
|
byte[] creatorSignature = groupInvitationFactory
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
privateGroup =
|
privateGroup =
|
||||||
privateGroupFactory.createPrivateGroup("Testgroup", author0);
|
privateGroupFactory.createPrivateGroup("Testgroup", author0);
|
||||||
long joinTime = clock.currentTimeMillis();
|
long joinTime = c0.getClock().currentTimeMillis();
|
||||||
GroupMessage joinMsg0 = groupMessageFactory
|
GroupMessage joinMsg0 = groupMessageFactory
|
||||||
.createJoinMessage(privateGroup.getId(), joinTime, author0);
|
.createJoinMessage(privateGroup.getId(), joinTime, author0);
|
||||||
groupManager0.addPrivateGroup(privateGroup, joinMsg0, true);
|
groupManager0.addPrivateGroup(privateGroup, joinMsg0, true);
|
||||||
@@ -88,7 +88,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendInvitation() throws Exception {
|
public void testSendInvitation() throws Exception {
|
||||||
long timestamp = clock.currentTimeMillis();
|
long timestamp = c0.getClock().currentTimeMillis();
|
||||||
String text = "Hi!";
|
String text = "Hi!";
|
||||||
sendInvitation(timestamp, text);
|
sendInvitation(timestamp, text);
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvitationDecline() throws Exception {
|
public void testInvitationDecline() throws Exception {
|
||||||
long timestamp = clock.currentTimeMillis();
|
long timestamp = c0.getClock().currentTimeMillis();
|
||||||
sendInvitation(timestamp, null);
|
sendInvitation(timestamp, null);
|
||||||
|
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
@@ -172,7 +172,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
setAutoDeleteTimer(c1, contactId0From1, MIN_AUTO_DELETE_TIMER_MS);
|
setAutoDeleteTimer(c1, contactId0From1, MIN_AUTO_DELETE_TIMER_MS);
|
||||||
|
|
||||||
// Send invitation
|
// Send invitation
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
// Decline invitation
|
// Decline invitation
|
||||||
@@ -194,7 +194,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvitationAccept() throws Exception {
|
public void testInvitationAccept() throws Exception {
|
||||||
long timestamp = clock.currentTimeMillis();
|
long timestamp = c0.getClock().currentTimeMillis();
|
||||||
sendInvitation(timestamp, null);
|
sendInvitation(timestamp, null);
|
||||||
|
|
||||||
// check that invitation message state is correct
|
// check that invitation message state is correct
|
||||||
@@ -257,7 +257,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
setAutoDeleteTimer(c1, contactId0From1, MIN_AUTO_DELETE_TIMER_MS);
|
setAutoDeleteTimer(c1, contactId0From1, MIN_AUTO_DELETE_TIMER_MS);
|
||||||
|
|
||||||
// Send invitation
|
// Send invitation
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
// Accept invitation
|
// Accept invitation
|
||||||
@@ -281,7 +281,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGroupCount() throws Exception {
|
public void testGroupCount() throws Exception {
|
||||||
long timestamp = clock.currentTimeMillis();
|
long timestamp = c0.getClock().currentTimeMillis();
|
||||||
sendInvitation(timestamp, null);
|
sendInvitation(timestamp, null);
|
||||||
|
|
||||||
// 0 has one read outgoing message
|
// 0 has one read outgoing message
|
||||||
@@ -313,7 +313,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleInvitations() throws Exception {
|
public void testMultipleInvitations() throws Exception {
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
|
|
||||||
// invitation is not allowed before the first hasn't been answered
|
// invitation is not allowed before the first hasn't been answered
|
||||||
assertFalse(groupInvitationManager0
|
assertFalse(groupInvitationManager0
|
||||||
@@ -330,7 +330,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
.isInvitationAllowed(contact1From0, privateGroup.getId()));
|
||||||
|
|
||||||
// send and accept the second invitation
|
// send and accept the second invitation
|
||||||
sendInvitation(clock.currentTimeMillis(), "Second Invitation");
|
sendInvitation(c0.getClock().currentTimeMillis(), "Second Invitation");
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
groupInvitationManager1
|
groupInvitationManager1
|
||||||
.respondToInvitation(contactId0From1, privateGroup, true);
|
.respondToInvitation(contactId0From1, privateGroup, true);
|
||||||
@@ -342,7 +342,8 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
// don't allow another invitation request
|
// don't allow another invitation request
|
||||||
try {
|
try {
|
||||||
sendInvitation(clock.currentTimeMillis(), "Third Invitation");
|
sendInvitation(c0.getClock().currentTimeMillis(),
|
||||||
|
"Third Invitation");
|
||||||
fail();
|
fail();
|
||||||
} catch (ProtocolStateException e) {
|
} catch (ProtocolStateException e) {
|
||||||
// expected
|
// expected
|
||||||
@@ -351,7 +352,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
@Test(expected = ProtocolStateException.class)
|
@Test(expected = ProtocolStateException.class)
|
||||||
public void testInvitationsWithSameTimestamp() throws Exception {
|
public void testInvitationsWithSameTimestamp() throws Exception {
|
||||||
long timestamp = clock.currentTimeMillis();
|
long timestamp = c0.getClock().currentTimeMillis();
|
||||||
sendInvitation(timestamp, null);
|
sendInvitation(timestamp, null);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
@@ -369,7 +370,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
@Test(expected = ProtocolStateException.class)
|
@Test(expected = ProtocolStateException.class)
|
||||||
public void testCreatorLeavesBeforeInvitationAccepted() throws Exception {
|
public void testCreatorLeavesBeforeInvitationAccepted() throws Exception {
|
||||||
// Creator invites invitee to join group
|
// Creator invites invitee to join group
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
|
|
||||||
// Creator's invite message is delivered to invitee
|
// Creator's invite message is delivered to invitee
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
@@ -392,7 +393,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
@Test
|
@Test
|
||||||
public void testCreatorLeavesBeforeInvitationDeclined() throws Exception {
|
public void testCreatorLeavesBeforeInvitationDeclined() throws Exception {
|
||||||
// Creator invites invitee to join group
|
// Creator invites invitee to join group
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
|
|
||||||
// Creator's invite message is delivered to invitee
|
// Creator's invite message is delivered to invitee
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
@@ -419,7 +420,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
public void testCreatorLeavesConcurrentlyWithInvitationAccepted()
|
public void testCreatorLeavesConcurrentlyWithInvitationAccepted()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// Creator invites invitee to join group
|
// Creator invites invitee to join group
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
|
|
||||||
// Creator's invite message is delivered to invitee
|
// Creator's invite message is delivered to invitee
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
@@ -450,7 +451,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
public void testCreatorLeavesConcurrentlyWithInvitationDeclined()
|
public void testCreatorLeavesConcurrentlyWithInvitationDeclined()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// Creator invites invitee to join group
|
// Creator invites invitee to join group
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
|
|
||||||
// Creator's invite message is delivered to invitee
|
// Creator's invite message is delivered to invitee
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
@@ -477,7 +478,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
public void testCreatorLeavesConcurrentlyWithMemberLeaving()
|
public void testCreatorLeavesConcurrentlyWithMemberLeaving()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// Creator invites invitee to join group
|
// Creator invites invitee to join group
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
|
|
||||||
// Creator's invite message is delivered to invitee
|
// Creator's invite message is delivered to invitee
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
@@ -517,7 +518,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
public void testDeletingAllMessagesWhenCompletingSession()
|
public void testDeletingAllMessagesWhenCompletingSession()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// send invitation
|
// send invitation
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
// messages can not be deleted
|
// messages can not be deleted
|
||||||
@@ -572,7 +573,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
@Test
|
@Test
|
||||||
public void testDeletingAllMessagesWhenDeclining() throws Exception {
|
public void testDeletingAllMessagesWhenDeclining() throws Exception {
|
||||||
// send invitation
|
// send invitation
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
// respond
|
// respond
|
||||||
@@ -608,7 +609,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
assertGroupCount(messageTracker1, g0From1.getId(), 0, 0);
|
assertGroupCount(messageTracker1, g0From1.getId(), 0, 0);
|
||||||
|
|
||||||
// creator can re-invite
|
// creator can re-invite
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
// now new messages can not be deleted anymore
|
// now new messages can not be deleted anymore
|
||||||
@@ -639,7 +640,7 @@ public class GroupInvitationIntegrationTest
|
|||||||
@Test
|
@Test
|
||||||
public void testDeletingSomeMessages() throws Exception {
|
public void testDeletingSomeMessages() throws Exception {
|
||||||
// send invitation
|
// send invitation
|
||||||
sendInvitation(clock.currentTimeMillis(), null);
|
sendInvitation(c0.getClock().currentTimeMillis(), null);
|
||||||
sync0To1(1, true);
|
sync0To1(1, true);
|
||||||
|
|
||||||
// deleting the invitation will fail for both
|
// deleting the invitation will fail for both
|
||||||
|
|||||||
@@ -725,7 +725,7 @@ public class ForumSharingIntegrationTest
|
|||||||
assertResponseReceived(listener0, contactId1From0, true);
|
assertResponseReceived(listener0, contactId1From0, true);
|
||||||
|
|
||||||
// sharer posts into the forum
|
// sharer posts into the forum
|
||||||
long time = clock.currentTimeMillis();
|
long time = c0.getClock().currentTimeMillis();
|
||||||
String text = getRandomString(42);
|
String text = getRandomString(42);
|
||||||
ForumPost p = forumPostFactory
|
ForumPost p = forumPostFactory
|
||||||
.createPost(forum.getId(), time, null, author0, text);
|
.createPost(forum.getId(), time, null, author0, text);
|
||||||
@@ -743,7 +743,7 @@ public class ForumSharingIntegrationTest
|
|||||||
assertEquals(author0, header.getAuthor());
|
assertEquals(author0, header.getAuthor());
|
||||||
|
|
||||||
// now invitee creates a post
|
// now invitee creates a post
|
||||||
time = clock.currentTimeMillis();
|
time = c1.getClock().currentTimeMillis();
|
||||||
text = getRandomString(42);
|
text = getRandomString(42);
|
||||||
p = forumPostFactory
|
p = forumPostFactory
|
||||||
.createPost(forum.getId(), time, null, author1, text);
|
.createPost(forum.getId(), time, null, author1, text);
|
||||||
@@ -789,7 +789,7 @@ public class ForumSharingIntegrationTest
|
|||||||
assertResponseReceived(listener0, contactId1From0, true);
|
assertResponseReceived(listener0, contactId1From0, true);
|
||||||
|
|
||||||
// now invitee creates a post
|
// now invitee creates a post
|
||||||
time = clock.currentTimeMillis();
|
time = c1.getClock().currentTimeMillis();
|
||||||
text = getRandomString(42);
|
text = getRandomString(42);
|
||||||
p = forumPostFactory
|
p = forumPostFactory
|
||||||
.createPost(forum.getId(), time, null, author1, text);
|
.createPost(forum.getId(), time, null, author1, text);
|
||||||
@@ -848,7 +848,7 @@ public class ForumSharingIntegrationTest
|
|||||||
// send an accept message for the same forum
|
// send an accept message for the same forum
|
||||||
Message m = messageEncoder.encodeAcceptMessage(
|
Message m = messageEncoder.encodeAcceptMessage(
|
||||||
forumSharingManager0.getContactGroup(contact1From0).getId(),
|
forumSharingManager0.getContactGroup(contact1From0).getId(),
|
||||||
forum.getId(), clock.currentTimeMillis(), invitationId);
|
forum.getId(), c0.getClock().currentTimeMillis(), invitationId);
|
||||||
c0.getClientHelper().addLocalMessage(m, new BdfDictionary(), true);
|
c0.getClientHelper().addLocalMessage(m, new BdfDictionary(), true);
|
||||||
|
|
||||||
// sync unexpected message and the expected abort message back
|
// sync unexpected message and the expected abort message back
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import org.briarproject.bramble.api.sync.MessageFactory;
|
|||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.bramble.api.sync.event.MessageStateChangedEvent;
|
import org.briarproject.bramble.api.sync.event.MessageStateChangedEvent;
|
||||||
import org.briarproject.bramble.api.sync.event.MessagesAckedEvent;
|
import org.briarproject.bramble.api.sync.event.MessagesAckedEvent;
|
||||||
import org.briarproject.bramble.api.system.Clock;
|
|
||||||
import org.briarproject.bramble.test.TestTransportConnectionReader;
|
import org.briarproject.bramble.test.TestTransportConnectionReader;
|
||||||
import org.briarproject.bramble.test.TestTransportConnectionWriter;
|
import org.briarproject.bramble.test.TestTransportConnectionWriter;
|
||||||
import org.briarproject.bramble.test.TestUtils;
|
import org.briarproject.bramble.test.TestUtils;
|
||||||
@@ -96,8 +95,6 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
|||||||
private LifecycleManager lifecycleManager0, lifecycleManager1,
|
private LifecycleManager lifecycleManager0, lifecycleManager1,
|
||||||
lifecycleManager2;
|
lifecycleManager2;
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected Clock clock;
|
|
||||||
@Inject
|
@Inject
|
||||||
protected CryptoComponent crypto;
|
protected CryptoComponent crypto;
|
||||||
@Inject
|
@Inject
|
||||||
@@ -139,9 +136,9 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
|||||||
private final SecretKey rootKey0_2 = getSecretKey();
|
private final SecretKey rootKey0_2 = getSecretKey();
|
||||||
private final SecretKey rootKey1_2 = getSecretKey();
|
private final SecretKey rootKey1_2 = getSecretKey();
|
||||||
|
|
||||||
protected File t0Dir = new File(testDir, AUTHOR0);
|
protected final File t0Dir = new File(testDir, AUTHOR0);
|
||||||
protected File t1Dir = new File(testDir, AUTHOR1);
|
protected final File t1Dir = new File(testDir, AUTHOR1);
|
||||||
protected File t2Dir = new File(testDir, AUTHOR2);
|
protected final File t2Dir = new File(testDir, AUTHOR2);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -269,16 +266,20 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
|||||||
|
|
||||||
protected void addDefaultContacts() throws Exception {
|
protected void addDefaultContacts() throws Exception {
|
||||||
contactId1From0 = contactManager0.addContact(author1, author0.getId(),
|
contactId1From0 = contactManager0.addContact(author1, author0.getId(),
|
||||||
rootKey0_1, clock.currentTimeMillis(), true, true, true);
|
rootKey0_1, c0.getClock().currentTimeMillis(), true, true,
|
||||||
|
true);
|
||||||
contact1From0 = contactManager0.getContact(contactId1From0);
|
contact1From0 = contactManager0.getContact(contactId1From0);
|
||||||
contactId0From1 = contactManager1.addContact(author0, author1.getId(),
|
contactId0From1 = contactManager1.addContact(author0, author1.getId(),
|
||||||
rootKey0_1, clock.currentTimeMillis(), false, true, true);
|
rootKey0_1, c1.getClock().currentTimeMillis(), false, true,
|
||||||
|
true);
|
||||||
contact0From1 = contactManager1.getContact(contactId0From1);
|
contact0From1 = contactManager1.getContact(contactId0From1);
|
||||||
contactId2From0 = contactManager0.addContact(author2, author0.getId(),
|
contactId2From0 = contactManager0.addContact(author2, author0.getId(),
|
||||||
rootKey0_2, clock.currentTimeMillis(), true, true, true);
|
rootKey0_2, c0.getClock().currentTimeMillis(), true, true,
|
||||||
|
true);
|
||||||
contact2From0 = contactManager0.getContact(contactId2From0);
|
contact2From0 = contactManager0.getContact(contactId2From0);
|
||||||
contactId0From2 = contactManager2.addContact(author0, author2.getId(),
|
contactId0From2 = contactManager2.addContact(author0, author2.getId(),
|
||||||
rootKey0_2, clock.currentTimeMillis(), false, true, true);
|
rootKey0_2, c2.getClock().currentTimeMillis(), false, true,
|
||||||
|
true);
|
||||||
contact0From2 = contactManager2.getContact(contactId0From2);
|
contact0From2 = contactManager2.getContact(contactId0From2);
|
||||||
|
|
||||||
// Sync initial client versioning updates
|
// Sync initial client versioning updates
|
||||||
@@ -297,9 +298,11 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
|||||||
protected void addContacts1And2(boolean haveTransportProperties)
|
protected void addContacts1And2(boolean haveTransportProperties)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
contactId2From1 = contactManager1.addContact(author2, author1.getId(),
|
contactId2From1 = contactManager1.addContact(author2, author1.getId(),
|
||||||
rootKey1_2, clock.currentTimeMillis(), true, true, true);
|
rootKey1_2, c1.getClock().currentTimeMillis(), true, true,
|
||||||
|
true);
|
||||||
contactId1From2 = contactManager2.addContact(author1, author2.getId(),
|
contactId1From2 = contactManager2.addContact(author1, author2.getId(),
|
||||||
rootKey1_2, clock.currentTimeMillis(), false, true, true);
|
rootKey1_2, c2.getClock().currentTimeMillis(), false, true,
|
||||||
|
true);
|
||||||
|
|
||||||
// Sync initial client versioning updates
|
// Sync initial client versioning updates
|
||||||
sync1To2(1, true);
|
sync1To2(1, true);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.briarproject.bramble.api.identity.AuthorFactory;
|
|||||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||||
import org.briarproject.bramble.api.properties.TransportPropertyManager;
|
import org.briarproject.bramble.api.properties.TransportPropertyManager;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.test.BrambleCoreIntegrationTestModule;
|
import org.briarproject.bramble.test.BrambleCoreIntegrationTestModule;
|
||||||
import org.briarproject.briar.api.attachment.AttachmentReader;
|
import org.briarproject.briar.api.attachment.AttachmentReader;
|
||||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||||
@@ -134,6 +135,8 @@ public interface BriarIntegrationTestComponent
|
|||||||
|
|
||||||
AutoDeleteManager getAutoDeleteManager();
|
AutoDeleteManager getAutoDeleteManager();
|
||||||
|
|
||||||
|
Clock getClock();
|
||||||
|
|
||||||
class Helper {
|
class Helper {
|
||||||
|
|
||||||
public static void injectEagerSingletons(
|
public static void injectEagerSingletons(
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.briarproject.bramble.network.JavaNetworkModule
|
|||||||
import org.briarproject.bramble.plugin.tor.CircumventionModule
|
import org.briarproject.bramble.plugin.tor.CircumventionModule
|
||||||
import org.briarproject.bramble.plugin.tor.UnixTorPluginFactory
|
import org.briarproject.bramble.plugin.tor.UnixTorPluginFactory
|
||||||
import org.briarproject.bramble.socks.SocksModule
|
import org.briarproject.bramble.socks.SocksModule
|
||||||
|
import org.briarproject.bramble.system.ClockModule
|
||||||
import org.briarproject.bramble.system.DefaultTaskSchedulerModule
|
import org.briarproject.bramble.system.DefaultTaskSchedulerModule
|
||||||
import org.briarproject.bramble.system.DefaultWakefulIoExecutorModule
|
import org.briarproject.bramble.system.DefaultWakefulIoExecutorModule
|
||||||
import org.briarproject.bramble.system.DesktopSecureRandomModule
|
import org.briarproject.bramble.system.DesktopSecureRandomModule
|
||||||
@@ -36,6 +37,7 @@ import javax.inject.Singleton
|
|||||||
includes = [
|
includes = [
|
||||||
AccountModule::class,
|
AccountModule::class,
|
||||||
CircumventionModule::class,
|
CircumventionModule::class,
|
||||||
|
ClockModule::class,
|
||||||
DefaultBatteryManagerModule::class,
|
DefaultBatteryManagerModule::class,
|
||||||
DefaultEventExecutorModule::class,
|
DefaultEventExecutorModule::class,
|
||||||
DefaultTaskSchedulerModule::class,
|
DefaultTaskSchedulerModule::class,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.briarproject.bramble.event.DefaultEventExecutorModule
|
|||||||
import org.briarproject.bramble.network.JavaNetworkModule
|
import org.briarproject.bramble.network.JavaNetworkModule
|
||||||
import org.briarproject.bramble.plugin.tor.CircumventionModule
|
import org.briarproject.bramble.plugin.tor.CircumventionModule
|
||||||
import org.briarproject.bramble.socks.SocksModule
|
import org.briarproject.bramble.socks.SocksModule
|
||||||
|
import org.briarproject.bramble.system.ClockModule
|
||||||
import org.briarproject.bramble.system.DefaultTaskSchedulerModule
|
import org.briarproject.bramble.system.DefaultTaskSchedulerModule
|
||||||
import org.briarproject.bramble.system.DefaultWakefulIoExecutorModule
|
import org.briarproject.bramble.system.DefaultWakefulIoExecutorModule
|
||||||
import org.briarproject.bramble.system.JavaSystemModule
|
import org.briarproject.bramble.system.JavaSystemModule
|
||||||
@@ -34,6 +35,7 @@ import javax.inject.Singleton
|
|||||||
JavaSystemModule::class,
|
JavaSystemModule::class,
|
||||||
AccountModule::class,
|
AccountModule::class,
|
||||||
CircumventionModule::class,
|
CircumventionModule::class,
|
||||||
|
ClockModule::class,
|
||||||
DefaultEventExecutorModule::class,
|
DefaultEventExecutorModule::class,
|
||||||
DefaultTaskSchedulerModule::class,
|
DefaultTaskSchedulerModule::class,
|
||||||
DefaultWakefulIoExecutorModule::class,
|
DefaultWakefulIoExecutorModule::class,
|
||||||
|
|||||||
Reference in New Issue
Block a user