Use "text" to refer to message text.

This commit is contained in:
akwizgran
2018-10-10 10:40:23 +01:00
parent a030f92275
commit 79d5612645
145 changed files with 750 additions and 764 deletions

View File

@@ -47,7 +47,7 @@ import static org.briarproject.briar.api.blog.BlogConstants.KEY_RSS_FEED;
import static org.briarproject.briar.api.blog.BlogConstants.KEY_TIMESTAMP;
import static org.briarproject.briar.api.blog.BlogConstants.KEY_TIME_RECEIVED;
import static org.briarproject.briar.api.blog.BlogConstants.KEY_TYPE;
import static org.briarproject.briar.api.blog.BlogConstants.MAX_BLOG_COMMENT_LENGTH;
import static org.briarproject.briar.api.blog.BlogConstants.MAX_BLOG_COMMENT_TEXT_LENGTH;
import static org.briarproject.briar.api.blog.BlogManager.CLIENT_ID;
import static org.briarproject.briar.api.blog.BlogManager.MAJOR_VERSION;
import static org.briarproject.briar.api.blog.MessageType.COMMENT;
@@ -99,7 +99,7 @@ public class BlogManagerImplTest extends BriarTestCase {
rssMessageId = rssMessage.getId();
timestamp = message.getTimestamp();
timeReceived = timestamp + 1;
comment = getRandomString(MAX_BLOG_COMMENT_LENGTH);
comment = getRandomString(MAX_BLOG_COMMENT_TEXT_LENGTH);
}
@Test
@@ -694,7 +694,7 @@ public class BlogManagerImplTest extends BriarTestCase {
new BdfEntry(KEY_TIMESTAMP, timestamp),
new BdfEntry(KEY_TIME_RECEIVED, timeReceived)
);
String localComment = getRandomString(MAX_BLOG_COMMENT_LENGTH);
String localComment = getRandomString(MAX_BLOG_COMMENT_TEXT_LENGTH);
Message localCommentMsg = getMessage(blog2.getId());
MessageId localCommentId = localCommentMsg.getId();
BdfDictionary localCommentMeta = BdfDictionary.of(

View File

@@ -122,15 +122,14 @@ public class BlogManagerIntegrationTest
@Test
public void testBlogPost() throws Exception {
// check that blog0 has no posts
String body = getRandomString(42);
String text = getRandomString(42);
Collection<BlogPostHeader> headers0 =
blogManager0.getPostHeaders(blog0.getId());
assertEquals(0, headers0.size());
// add a post to blog0
BlogPost p = blogPostFactory
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
author0, body);
BlogPost p = blogPostFactory.createBlogPost(blog0.getId(),
clock.currentTimeMillis(), null, author0, text);
blogManager0.addLocalPost(p);
// check that post is now in blog0
@@ -138,7 +137,7 @@ public class BlogManagerIntegrationTest
assertEquals(1, headers0.size());
// check that body is there
assertEquals(body, blogManager0.getPostBody(p.getMessage().getId()));
assertEquals(text, blogManager0.getPostText(p.getMessage().getId()));
// make sure that blog0 at author1 doesn't have the post yet
Collection<BlogPostHeader> headers1 =
@@ -154,16 +153,16 @@ public class BlogManagerIntegrationTest
assertEquals(POST, headers1.iterator().next().getType());
// check that body is there
assertEquals(body, blogManager1.getPostBody(p.getMessage().getId()));
assertEquals(text, blogManager1.getPostText(p.getMessage().getId()));
}
@Test
public void testBlogPostInWrongBlog() throws Exception {
// add a post to blog1
String body = getRandomString(42);
String text = getRandomString(42);
BlogPost p = blogPostFactory
.createBlogPost(blog1.getId(), clock.currentTimeMillis(), null,
author0, body);
author0, text);
blogManager0.addLocalPost(p);
// check that post is now in blog1
@@ -199,10 +198,10 @@ public class BlogManagerIntegrationTest
@Test
public void testBlogComment() throws Exception {
// add a post to blog0
String body = getRandomString(42);
String text = getRandomString(42);
BlogPost p = blogPostFactory
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
author0, body);
author0, text);
blogManager0.addLocalPost(p);
// sync the post over
@@ -234,7 +233,7 @@ public class BlogManagerIntegrationTest
// ensure that body can be retrieved from wrapped post
MessageId parentId = h.getParentId();
assertNotNull(parentId);
assertEquals(body, blogManager0.getPostBody(parentId));
assertEquals(text, blogManager0.getPostText(parentId));
// 1 has only their own comment in their blog
headers1 = blogManager1.getPostHeaders(blog1.getId());
@@ -244,10 +243,10 @@ public class BlogManagerIntegrationTest
@Test
public void testBlogCommentOnOwnPost() throws Exception {
// add a post to blog0
String body = getRandomString(42);
String text = getRandomString(42);
BlogPost p = blogPostFactory
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
author0, body);
author0, text);
blogManager0.addLocalPost(p);
// get header of own post
@@ -270,7 +269,7 @@ public class BlogManagerIntegrationTest
assertEquals(2, headers1.size());
for (BlogPostHeader h : headers1) {
if (h.getType() == POST) {
assertEquals(body, blogManager1.getPostBody(h.getId()));
assertEquals(text, blogManager1.getPostText(h.getId()));
} else {
assertEquals(comment, ((BlogCommentHeader) h).getComment());
}
@@ -280,10 +279,10 @@ public class BlogManagerIntegrationTest
@Test
public void testCommentOnComment() throws Exception {
// add a post to blog0
String body = getRandomString(42);
String text = getRandomString(42);
BlogPost p = blogPostFactory
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
author0, body);
author0, text);
blogManager0.addLocalPost(p);
// sync the post over
@@ -368,10 +367,10 @@ public class BlogManagerIntegrationTest
@Test
public void testCommentOnOwnComment() throws Exception {
// add a post to blog0
String body = getRandomString(42);
String text = getRandomString(42);
BlogPost p = blogPostFactory
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
author0, body);
author0, text);
blogManager0.addLocalPost(p);
// sync the post over
@@ -413,10 +412,10 @@ public class BlogManagerIntegrationTest
assertTrue(rssBlog.isRssFeed());
// add a feed post to rssBlog
String body = getRandomString(42);
String text = getRandomString(42);
BlogPost p = blogPostFactory
.createBlogPost(rssBlog.getId(), clock.currentTimeMillis(),
null, author0, body);
null, author0, text);
blogManager0.addLocalPost(p);
// make sure it got saved as an RSS feed post
@@ -432,10 +431,10 @@ public class BlogManagerIntegrationTest
@Test
public void testFeedReblog() throws Exception {
// add a feed post to rssBlog
String body = getRandomString(42);
String text = getRandomString(42);
BlogPost p = blogPostFactory
.createBlogPost(rssBlog.getId(), clock.currentTimeMillis(),
null, author0, body);
null, author0, text);
blogManager0.addLocalPost(p);
// reblog feed post to own blog

View File

@@ -62,7 +62,7 @@ public class BlogPostValidatorTest extends BriarTestCase {
private final BlogFactory blogFactory = context.mock(BlogFactory.class);
private final ClientHelper clientHelper = context.mock(ClientHelper.class);
private final Author author;
private final String body = getRandomString(42);
private final String text = getRandomString(42);
public BlogPostValidatorTest() {
group = getGroup(CLIENT_ID, MAJOR_VERSION);
@@ -99,9 +99,9 @@ public class BlogPostValidatorTest extends BriarTestCase {
private void testValidateProperBlogPost(Blog b, boolean rssFeed)
throws IOException, GeneralSecurityException {
byte[] sigBytes = getRandomBytes(42);
BdfList m = BdfList.of(POST.getInt(), body, sigBytes);
BdfList m = BdfList.of(POST.getInt(), text, sigBytes);
BdfList signed = BdfList.of(b.getId(), message.getTimestamp(), body);
BdfList signed = BdfList.of(b.getId(), message.getTimestamp(), text);
expectCrypto(b, SIGNING_LABEL_POST, signed, sigBytes);
BdfDictionary result =
validator.validateMessage(message, group, m).getDictionary();
@@ -114,7 +114,7 @@ public class BlogPostValidatorTest extends BriarTestCase {
@Test(expected = FormatException.class)
public void testValidateBlogPostWithoutAttachments() throws IOException {
BdfList content = BdfList.of(null, null, body);
BdfList content = BdfList.of(null, null, text);
BdfList m = BdfList.of(POST.getInt(), content, null);
validator.validateMessage(message, group, m);
@@ -122,7 +122,7 @@ public class BlogPostValidatorTest extends BriarTestCase {
@Test(expected = FormatException.class)
public void testValidateBlogPostWithoutSignature() throws IOException {
BdfList content = BdfList.of(null, null, body, null);
BdfList content = BdfList.of(null, null, text, null);
BdfList m = BdfList.of(POST.getInt(), content, null);
validator.validateMessage(message, group, m);
@@ -191,12 +191,12 @@ public class BlogPostValidatorTest extends BriarTestCase {
// group descriptor, timestamp, content, signature
byte[] sigBytes = getRandomBytes(42);
BdfList m = BdfList.of(WRAPPED_POST.getInt(), descriptor,
message.getTimestamp(), body, sigBytes);
message.getTimestamp(), text, sigBytes);
BdfList signed = BdfList.of(b.getId(), message.getTimestamp(), body);
BdfList signed = BdfList.of(b.getId(), message.getTimestamp(), text);
expectCrypto(b, SIGNING_LABEL_POST, signed, sigBytes);
BdfList originalList = BdfList.of(POST.getInt(), body, sigBytes);
BdfList originalList = BdfList.of(POST.getInt(), text, sigBytes);
byte[] originalBody = getRandomBytes(42);
context.checking(new Expectations() {{

View File

@@ -106,7 +106,7 @@ public class FeedManagerImplTest extends BrambleMockTestCase {
SyndEntry entry = new SyndEntryImpl();
entry.setUpdatedDate(new Date());
entries.add(entry);
String body = "<p> (" + entry.getUpdatedDate().toString() + ")</p>";
String text = "<p> (" + entry.getUpdatedDate().toString() + ")</p>";
Message msg = getMessage(blogGroupId);
BlogPost post = new BlogPost(msg, null, localAuthor);
@@ -116,7 +116,7 @@ public class FeedManagerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(42L));
oneOf(blogPostFactory).createBlogPost(feed.getBlogId(), 42L, null,
localAuthor, body);
localAuthor, text);
will(returnValue(post));
oneOf(blogManager).addLocalPost(txn, post);
oneOf(db).commitTransaction(txn);

View File

@@ -72,24 +72,24 @@ public class ForumManagerTest
}
private ForumPost createForumPost(GroupId groupId,
@Nullable ForumPost parent, String body, long ms) throws Exception {
@Nullable ForumPost parent, String text, long ms) throws Exception {
return forumPostFactory.createPost(groupId, ms,
parent == null ? null : parent.getMessage().getId(),
author0, body);
author0, text);
}
@Test
public void testForumPost() throws Exception {
assertEquals(1, forumManager0.getForums().size());
long ms1 = clock.currentTimeMillis() - 1000L;
String body1 = "some forum text";
String text1 = "some forum text";
long ms2 = clock.currentTimeMillis();
String body2 = "some other forum text";
String text2 = "some other forum text";
ForumPost post1 =
createForumPost(forum0.getGroup().getId(), null, body1, ms1);
createForumPost(forum0.getGroup().getId(), null, text1, ms1);
assertEquals(ms1, post1.getMessage().getTimestamp());
ForumPost post2 =
createForumPost(forum0.getGroup().getId(), post1, body2, ms2);
createForumPost(forum0.getGroup().getId(), post1, text2, ms2);
assertEquals(ms2, post2.getMessage().getTimestamp());
forumManager0.addLocalPost(post1);
forumManager0.setReadFlag(forum0.getGroup().getId(),
@@ -109,19 +109,19 @@ public class ForumManagerTest
forumManager0.getPostHeaders(forum0.getGroup().getId());
assertEquals(2, headers.size());
for (ForumPostHeader h : headers) {
String hBody = forumManager0.getPostBody(h.getId());
String hText = forumManager0.getPostText(h.getId());
boolean isPost1 = h.getId().equals(post1.getMessage().getId());
boolean isPost2 = h.getId().equals(post2.getMessage().getId());
assertTrue(isPost1 || isPost2);
if (isPost1) {
assertEquals(h.getTimestamp(), ms1);
assertEquals(body1, hBody);
assertEquals(text1, hText);
assertNull(h.getParentId());
assertTrue(h.isRead());
} else {
assertEquals(h.getTimestamp(), ms2);
assertEquals(body2, hBody);
assertEquals(text2, hText);
assertEquals(h.getParentId(), post2.getParent());
assertFalse(h.isRead());
}

View File

@@ -24,7 +24,7 @@ import static org.briarproject.briar.api.blog.BlogConstants.KEY_READ;
import static org.briarproject.briar.api.forum.ForumConstants.KEY_AUTHOR;
import static org.briarproject.briar.api.forum.ForumConstants.KEY_PARENT;
import static org.briarproject.briar.api.forum.ForumConstants.KEY_TIMESTAMP;
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_POST_BODY_LENGTH;
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_POST_TEXT_LENGTH;
import static org.briarproject.briar.api.forum.ForumPostFactory.SIGNING_LABEL_POST;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertFalse;
public class ForumPostValidatorTest extends ValidatorTestCase {
private final MessageId parentId = new MessageId(getRandomId());
private final String content = getRandomString(MAX_FORUM_POST_BODY_LENGTH);
private final String text = getRandomString(MAX_FORUM_POST_TEXT_LENGTH);
private final byte[] signature = getRandomBytes(MAX_SIGNATURE_LENGTH);
private final Author author = getAuthor();
private final String authorName = author.getName();
@@ -41,9 +41,9 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
private final BdfList authorList = BdfList.of(author.getFormatVersion(),
authorName, authorPublicKey);
private final BdfList signedWithParent = BdfList.of(groupId, timestamp,
parentId.getBytes(), authorList, content);
parentId.getBytes(), authorList, text);
private final BdfList signedWithoutParent = BdfList.of(groupId, timestamp,
null, authorList, content);
null, authorList, text);
private final ForumPostValidator v = new ForumPostValidator(clientHelper,
metadataEncoder, clock);
@@ -51,13 +51,13 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsTooShortBody() throws Exception {
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content));
BdfList.of(parentId, authorList, text));
}
@Test(expected = FormatException.class)
public void testRejectsTooLongBody() throws Exception {
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content, signature, 123));
BdfList.of(parentId, authorList, text, signature, 123));
}
@Test
@@ -69,40 +69,40 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
}});
BdfMessageContext messageContext = v.validateMessage(message, group,
BdfList.of(null, authorList, content, signature));
BdfList.of(null, authorList, text, signature));
assertExpectedContext(messageContext, false);
}
@Test(expected = FormatException.class)
public void testRejectsNonRawParentId() throws Exception {
v.validateMessage(message, group,
BdfList.of(123, authorList, content, signature));
BdfList.of(123, authorList, text, signature));
}
@Test(expected = FormatException.class)
public void testRejectsTooShortParentId() throws Exception {
byte[] invalidParentId = getRandomBytes(UniqueId.LENGTH - 1);
v.validateMessage(message, group,
BdfList.of(invalidParentId, authorList, content, signature));
BdfList.of(invalidParentId, authorList, text, signature));
}
@Test(expected = FormatException.class)
public void testRejectsTooLongParentId() throws Exception {
byte[] invalidParentId = getRandomBytes(UniqueId.LENGTH + 1);
v.validateMessage(message, group,
BdfList.of(invalidParentId, authorList, content, signature));
BdfList.of(invalidParentId, authorList, text, signature));
}
@Test(expected = FormatException.class)
public void testRejectsNullAuthorList() throws Exception {
v.validateMessage(message, group,
BdfList.of(parentId, null, content, signature));
BdfList.of(parentId, null, text, signature));
}
@Test(expected = FormatException.class)
public void testRejectsNonListAuthorList() throws Exception {
v.validateMessage(message, group,
BdfList.of(parentId, 123, content, signature));
BdfList.of(parentId, 123, text, signature));
}
@Test(expected = FormatException.class)
@@ -112,11 +112,11 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
will(throwException(new FormatException()));
}});
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content, signature));
BdfList.of(parentId, authorList, text, signature));
}
@Test(expected = FormatException.class)
public void testRejectsNullContent() throws Exception {
public void testRejectsNullText() throws Exception {
expectCreateAuthor();
v.validateMessage(message, group,
@@ -124,7 +124,7 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
}
@Test(expected = FormatException.class)
public void testRejectsNonStringContent() throws Exception {
public void testRejectsNonStringText() throws Exception {
expectCreateAuthor();
v.validateMessage(message, group,
@@ -132,30 +132,30 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
}
@Test
public void testAcceptsMinLengthContent() throws Exception {
String shortContent = "";
BdfList signedWithShortContent = BdfList.of(groupId, timestamp,
parentId.getBytes(), authorList, shortContent);
public void testAcceptsMinLengthText() throws Exception {
String shortText = "";
BdfList signedWithShortText = BdfList.of(groupId, timestamp,
parentId.getBytes(), authorList, shortText);
expectCreateAuthor();
context.checking(new Expectations() {{
oneOf(clientHelper).verifySignature(signature, SIGNING_LABEL_POST,
signedWithShortContent, authorPublicKey);
signedWithShortText, authorPublicKey);
}});
BdfMessageContext messageContext = v.validateMessage(message, group,
BdfList.of(parentId, authorList, shortContent, signature));
BdfList.of(parentId, authorList, shortText, signature));
assertExpectedContext(messageContext, true);
}
@Test(expected = FormatException.class)
public void testRejectsTooLongContent() throws Exception {
String invalidContent = getRandomString(MAX_FORUM_POST_BODY_LENGTH + 1);
public void testRejectsTooLongText() throws Exception {
String invalidText = getRandomString(MAX_FORUM_POST_TEXT_LENGTH + 1);
expectCreateAuthor();
v.validateMessage(message, group,
BdfList.of(parentId, authorList, invalidContent, signature));
BdfList.of(parentId, authorList, invalidText, signature));
}
@Test(expected = FormatException.class)
@@ -163,7 +163,7 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
expectCreateAuthor();
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content, null));
BdfList.of(parentId, authorList, text, null));
}
@Test(expected = FormatException.class)
@@ -171,7 +171,7 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
expectCreateAuthor();
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content, 123));
BdfList.of(parentId, authorList, text, 123));
}
@Test(expected = FormatException.class)
@@ -181,7 +181,7 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
expectCreateAuthor();
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content, invalidSignature));
BdfList.of(parentId, authorList, text, invalidSignature));
}
@Test(expected = FormatException.class)
@@ -195,7 +195,7 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
}});
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content, signature));
BdfList.of(parentId, authorList, text, signature));
}
@Test(expected = InvalidMessageException.class)
@@ -209,7 +209,7 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
}});
v.validateMessage(message, group,
BdfList.of(parentId, authorList, content, signature));
BdfList.of(parentId, authorList, text, signature));
}
private void expectCreateAuthor() throws Exception {

View File

@@ -19,7 +19,7 @@ import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_K
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_REQUEST_MESSAGE_LENGTH;
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_INTRODUCTION_TEXT_LENGTH;
import static org.briarproject.briar.introduction.MessageType.ABORT;
import static org.briarproject.briar.introduction.MessageType.ACCEPT;
import static org.briarproject.briar.introduction.MessageType.ACTIVATE;
@@ -38,7 +38,7 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
private final SessionId sessionId = new SessionId(getRandomId());
private final MessageId previousMsgId = new MessageId(getRandomId());
private final String text = getRandomString(MAX_REQUEST_MESSAGE_LENGTH);
private final String text = getRandomString(MAX_INTRODUCTION_TEXT_LENGTH);
private final BdfDictionary meta = new BdfDictionary();
private final long acceptTimestamp = 42;
private final BdfDictionary transportProperties = BdfDictionary.of(

View File

@@ -30,7 +30,7 @@ import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.test.TestUtils.getTransportPropertiesMap;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_REQUEST_MESSAGE_LENGTH;
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_INTRODUCTION_TEXT_LENGTH;
import static org.briarproject.briar.api.introduction.IntroductionManager.CLIENT_ID;
import static org.briarproject.briar.api.introduction.IntroductionManager.MAJOR_VERSION;
import static org.briarproject.briar.introduction.MessageType.ABORT;
@@ -65,7 +65,7 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
private final SessionId sessionId = new SessionId(getRandomId());
private final MessageId previousMsgId = new MessageId(getRandomId());
private final Author author;
private final String text = getRandomString(MAX_REQUEST_MESSAGE_LENGTH);
private final String text = getRandomString(MAX_INTRODUCTION_TEXT_LENGTH);
private final byte[] ephemeralPublicKey =
getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
private final byte[] mac = getRandomBytes(MAC_BYTES);
@@ -128,7 +128,7 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
assertEquals(m.getTimestamp(), rm.getTimestamp());
assertEquals(previousMsgId, rm.getPreviousMessageId());
assertEquals(author, rm.getAuthor());
assertEquals(text, rm.getMessage());
assertEquals(text, rm.getText());
}
@Test
@@ -151,7 +151,7 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
RequestMessage rm =
messageParser.parseRequestMessage(m, clientHelper.toList(m));
assertNull(rm.getMessage());
assertNull(rm.getText());
}
@Test

View File

@@ -16,7 +16,7 @@ import static org.briarproject.bramble.test.TestUtils.getAuthor;
import static org.briarproject.bramble.test.TestUtils.getMessage;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_REQUEST_MESSAGE_LENGTH;
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_INTRODUCTION_TEXT_LENGTH;
import static org.briarproject.briar.introduction.MessageType.REQUEST;
public class MessageEncoderTest extends BrambleMockTestCase {
@@ -34,7 +34,7 @@ public class MessageEncoderTest extends BrambleMockTestCase {
private final byte[] body = message.getBody();
private final Author author = getAuthor();
private final BdfList authorList = new BdfList();
private final String text = getRandomString(MAX_REQUEST_MESSAGE_LENGTH);
private final String text = getRandomString(MAX_INTRODUCTION_TEXT_LENGTH);
@Test
public void testEncodeRequestMessage() throws FormatException {

View File

@@ -29,8 +29,8 @@ import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_K
import static org.briarproject.bramble.api.record.Record.MAX_RECORD_PAYLOAD_BYTES;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_POST_BODY_LENGTH;
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_POST_TEXT_LENGTH;
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_TEXT_LENGTH;
import static org.junit.Assert.assertTrue;
public class MessageSizeIntegrationTest extends BriarTestCase {
@@ -56,13 +56,13 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
// Create a maximum-length private message
GroupId groupId = new GroupId(getRandomId());
long timestamp = Long.MAX_VALUE;
String body = getRandomString(MAX_PRIVATE_MESSAGE_BODY_LENGTH);
String text = getRandomString(MAX_PRIVATE_MESSAGE_TEXT_LENGTH);
PrivateMessage message = privateMessageFactory.createPrivateMessage(
groupId, timestamp, body);
groupId, timestamp, text);
// Check the size of the serialised message
int length = message.getMessage().getRawLength();
assertTrue(length > UniqueId.LENGTH + 8
+ MAX_PRIVATE_MESSAGE_BODY_LENGTH);
+ MAX_PRIVATE_MESSAGE_TEXT_LENGTH);
assertTrue(length <= MAX_RECORD_PAYLOAD_BYTES);
}
@@ -79,14 +79,14 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
GroupId groupId = new GroupId(getRandomId());
long timestamp = Long.MAX_VALUE;
MessageId parent = new MessageId(getRandomId());
String body = getRandomString(MAX_FORUM_POST_BODY_LENGTH);
String text = getRandomString(MAX_FORUM_POST_TEXT_LENGTH);
ForumPost post = forumPostFactory.createPost(groupId,
timestamp, parent, author, body);
timestamp, parent, author, text);
// Check the size of the serialised message
int length = post.getMessage().getRawLength();
assertTrue(length > UniqueId.LENGTH + 8 + UniqueId.LENGTH + 4
+ MAX_AUTHOR_NAME_LENGTH + MAX_PUBLIC_KEY_LENGTH
+ MAX_FORUM_POST_BODY_LENGTH);
+ MAX_FORUM_POST_TEXT_LENGTH);
assertTrue(length <= MAX_RECORD_PAYLOAD_BYTES);
}

View File

@@ -5,10 +5,10 @@ import org.briarproject.bramble.api.client.BdfMessageContext;
import org.briarproject.bramble.api.data.BdfDictionary;
import org.briarproject.bramble.api.data.BdfList;
import org.briarproject.bramble.test.ValidatorTestCase;
import org.briarproject.bramble.util.StringUtils;
import org.junit.Test;
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_TEXT_LENGTH;
import static org.briarproject.briar.client.MessageTrackerConstants.MSG_KEY_READ;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -30,41 +30,40 @@ public class PrivateMessageValidatorTest extends ValidatorTestCase {
}
@Test(expected = FormatException.class)
public void testRejectsNullContent() throws Exception {
public void testRejectsNullText() throws Exception {
PrivateMessageValidator v = new PrivateMessageValidator(clientHelper,
metadataEncoder, clock);
v.validateMessage(message, group, BdfList.of((String) null));
}
@Test(expected = FormatException.class)
public void testRejectsNonStringContent() throws Exception {
public void testRejectsNonStringText() throws Exception {
PrivateMessageValidator v = new PrivateMessageValidator(clientHelper,
metadataEncoder, clock);
v.validateMessage(message, group, BdfList.of(123));
}
@Test(expected = FormatException.class)
public void testRejectsTooLongContent() throws Exception {
public void testRejectsTooLongText() throws Exception {
PrivateMessageValidator v = new PrivateMessageValidator(clientHelper,
metadataEncoder, clock);
String invalidContent =
StringUtils.getRandomString(MAX_PRIVATE_MESSAGE_BODY_LENGTH + 1);
v.validateMessage(message, group, BdfList.of(invalidContent));
String invalidText =
getRandomString(MAX_PRIVATE_MESSAGE_TEXT_LENGTH + 1);
v.validateMessage(message, group, BdfList.of(invalidText));
}
@Test
public void testAcceptsMaxLengthContent() throws Exception {
public void testAcceptsMaxLengthText() throws Exception {
PrivateMessageValidator v = new PrivateMessageValidator(clientHelper,
metadataEncoder, clock);
String content =
StringUtils.getRandomString(MAX_PRIVATE_MESSAGE_BODY_LENGTH);
String text = getRandomString(MAX_PRIVATE_MESSAGE_TEXT_LENGTH);
BdfMessageContext messageContext =
v.validateMessage(message, group, BdfList.of(content));
v.validateMessage(message, group, BdfList.of(text));
assertExpectedContext(messageContext);
}
@Test
public void testAcceptsMinLengthContent() throws Exception {
public void testAcceptsMinLengthText() throws Exception {
PrivateMessageValidator v = new PrivateMessageValidator(clientHelper,
metadataEncoder, clock);
BdfMessageContext messageContext =

View File

@@ -31,7 +31,7 @@ import static org.briarproject.briar.api.privategroup.MessageType.JOIN;
import static org.briarproject.briar.api.privategroup.MessageType.POST;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROUP_SALT_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_NAME_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_POST_BODY_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_POST_TEXT_LENGTH;
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationFactory.SIGNING_LABEL_INVITE;
import static org.briarproject.briar.privategroup.GroupConstants.KEY_INITIAL_JOIN_MSG;
import static org.briarproject.briar.privategroup.GroupConstants.KEY_MEMBER;
@@ -76,7 +76,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
private final BdfList token = new BdfList();
private final MessageId parentId = new MessageId(getRandomId());
private final MessageId previousMsgId = new MessageId(getRandomId());
private final String content = getRandomString(MAX_GROUP_POST_BODY_LENGTH);
private final String text = getRandomString(MAX_GROUP_POST_TEXT_LENGTH);
private final GroupMessageValidator validator =
new GroupMessageValidator(privateGroupFactory, clientHelper,
@@ -432,7 +432,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsTooShortPost() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content);
previousMsgId, text);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -440,21 +440,21 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsTooLongPost() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content, memberSignature, "");
previousMsgId, text, memberSignature, "");
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsPostWithNullAuthor() throws Exception {
BdfList body = BdfList.of(POST.getInt(), null, parentId, previousMsgId,
content, memberSignature);
text, memberSignature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsPostWithNonListAuthor() throws Exception {
BdfList body = BdfList.of(POST.getInt(), 123, parentId, previousMsgId,
content, memberSignature);
text, memberSignature);
validator.validateMessage(message, group, body);
}
@@ -462,14 +462,14 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
public void testRejectsPostWithInvalidAuthor() throws Exception {
expectRejectAuthor(memberList);
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content, memberSignature);
previousMsgId, text, memberSignature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsPostWithTooShortParentId() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList,
getRandomBytes(MessageId.LENGTH - 1), previousMsgId, content,
getRandomBytes(MessageId.LENGTH - 1), previousMsgId, text,
memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
@@ -478,7 +478,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithTooLongParentId() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList,
getRandomBytes(MessageId.LENGTH + 1), previousMsgId, content,
getRandomBytes(MessageId.LENGTH + 1), previousMsgId, text,
memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
@@ -487,7 +487,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithNonRawParentId() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, "not raw",
previousMsgId, content, memberSignature);
previousMsgId, text, memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -495,7 +495,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithTooShortPreviousMsgId() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
getRandomBytes(MessageId.LENGTH - 1), content, memberSignature);
getRandomBytes(MessageId.LENGTH - 1), text, memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -503,7 +503,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithTooLongPreviousMsgId() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
getRandomBytes(MessageId.LENGTH + 1), content, memberSignature);
getRandomBytes(MessageId.LENGTH + 1), text, memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -511,7 +511,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithNullPreviousMsgId() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId, null,
content, memberSignature);
text, memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -519,13 +519,13 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithNonRawPreviousMsgId() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
"not raw", content, memberSignature);
"not raw", text, memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsPostWithTooShortContent() throws Exception {
public void testRejectsPostWithTooShortText() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, "", memberSignature);
expectParseAuthor(memberList, member);
@@ -533,16 +533,16 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
}
@Test(expected = FormatException.class)
public void testRejectsPostWithTooLongContent() throws Exception {
public void testRejectsPostWithTooLongText() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, getRandomString(MAX_GROUP_POST_BODY_LENGTH + 1),
previousMsgId, getRandomString(MAX_GROUP_POST_TEXT_LENGTH + 1),
memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsPostWithNullContent() throws Exception {
public void testRejectsPostWithNullText() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, null, memberSignature);
expectParseAuthor(memberList, member);
@@ -550,7 +550,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
}
@Test(expected = FormatException.class)
public void testRejectsPostWithNonStringContent() throws Exception {
public void testRejectsPostWithNonStringText() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, getRandomBytes(5), memberSignature);
expectParseAuthor(memberList, member);
@@ -560,7 +560,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithTooShortSignature() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content, new byte[0]);
previousMsgId, text, new byte[0]);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -568,7 +568,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithTooLongSignature() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content,
previousMsgId, text,
getRandomBytes(MAX_SIGNATURE_LENGTH + 1));
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
@@ -577,7 +577,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithNullSignature() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content, null);
previousMsgId, text, null);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -585,7 +585,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithNonRawSignature() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content, "not raw");
previousMsgId, text, "not raw");
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}
@@ -593,7 +593,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsPostWithInvalidSignature() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content, memberSignature);
previousMsgId, text, memberSignature);
expectPostMessage(parentId, false);
validator.validateMessage(message, group, body);
}
@@ -601,7 +601,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test
public void testAcceptsPost() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, parentId,
previousMsgId, content, memberSignature);
previousMsgId, text, memberSignature);
expectPostMessage(parentId, true);
BdfMessageContext messageContext =
validator.validateMessage(message, group, body);
@@ -616,7 +616,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test
public void testAcceptsTopLevelPost() throws Exception {
BdfList body = BdfList.of(POST.getInt(), memberList, null,
previousMsgId, content, memberSignature);
previousMsgId, text, memberSignature);
expectPostMessage(null, true);
BdfMessageContext messageContext =
validator.validateMessage(message, group, body);
@@ -636,7 +636,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
memberList,
parentId == null ? null : parentId.getBytes(),
previousMsgId.getBytes(),
content
text
);
expectParseAuthor(memberList, member);
context.checking(new Expectations() {{
@@ -662,7 +662,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
@Test(expected = InvalidMessageException.class)
public void testRejectsMessageWithUnknownType() throws Exception {
BdfList body = BdfList.of(POST.getInt() + 1, memberList,
parentId, previousMsgId, content, memberSignature);
parentId, previousMsgId, text, memberSignature);
expectParseAuthor(memberList, member);
validator.validateMessage(message, group, body);
}

View File

@@ -176,10 +176,10 @@ public class PrivateGroupIntegrationTest
// 2 sends a message to the group
long time = clock.currentTimeMillis();
String body = "This is a test message!";
String text = "This is a test message!";
MessageId previousMsgId = groupManager2.getPreviousMsgId(groupId0);
GroupMessage msg = groupMessageFactory
.createGroupMessage(groupId0, time, null, author2, body,
.createGroupMessage(groupId0, time, null, author2, text,
previousMsgId);
groupManager2.addLocalMessage(msg);
@@ -209,13 +209,13 @@ public class PrivateGroupIntegrationTest
}
private void sendInvitation(ContactId c, long timestamp,
@Nullable String msg) throws DbException {
@Nullable String text) throws DbException {
Contact contact = contactManager0.getContact(c);
byte[] signature = groupInvitationFactory
.signInvitation(contact, groupId0, timestamp,
author0.getPrivateKey());
groupInvitationManager0
.sendInvitation(groupId0, c, msg, timestamp, signature);
.sendInvitation(groupId0, c, text, timestamp, signature);
}
private GroupMember getGroupMember(PrivateGroupManager groupManager,

View File

@@ -80,11 +80,11 @@ public class PrivateGroupManagerIntegrationTest
// create and add test message
long time = clock.currentTimeMillis();
String body = "This is a test message!";
String text = "This is a test message!";
MessageId previousMsgId =
groupManager0.getPreviousMsgId(groupId0);
GroupMessage msg = groupMessageFactory
.createGroupMessage(groupId0, time, null, author0, body,
.createGroupMessage(groupId0, time, null, author0, text,
previousMsgId);
groupManager0.addLocalMessage(msg);
assertEquals(msg.getMessage().getId(),
@@ -108,7 +108,7 @@ public class PrivateGroupManagerIntegrationTest
assertEquals(author0, header.getAuthor());
assertEquals(time, header.getTimestamp());
assertEquals(VERIFIED, header.getAuthorStatus());
assertEquals(body, groupManager1.getMessageBody(header.getId()));
assertEquals(text, groupManager1.getMessageText(header.getId()));
GroupCount count = groupManager1.getGroupCount(groupId0);
assertEquals(2, count.getUnreadCount());
assertEquals(time, count.getLatestMsgTime());

View File

@@ -34,7 +34,7 @@ import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROUP_SALT_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_MSG_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_TEXT_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_NAME_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.CLIENT_ID;
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.MAJOR_VERSION;
@@ -89,7 +89,7 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
new InviteMessage(new MessageId(getRandomId()), contactGroupId,
privateGroupId, 0L, privateGroup.getName(),
privateGroup.getCreator(), privateGroup.getSalt(),
getRandomString(MAX_GROUP_INVITATION_MSG_LENGTH),
getRandomString(MAX_GROUP_INVITATION_TEXT_LENGTH),
signature);
final JoinMessage joinMessage =
new JoinMessage(new MessageId(getRandomId()), contactGroupId,
@@ -121,12 +121,12 @@ abstract class AbstractProtocolEngineTest extends BrambleMockTestCase {
}});
}
void expectSendInviteMessage(String msg) throws Exception {
void expectSendInviteMessage(String text) throws Exception {
context.checking(new Expectations() {{
oneOf(messageEncoder)
.encodeInviteMessage(contactGroupId, privateGroupId,
inviteTimestamp, privateGroup.getName(), author,
privateGroup.getSalt(), msg, signature);
privateGroup.getSalt(), text, signature);
will(returnValue(message));
}});
expectSendMessage(INVITE, true);

View File

@@ -15,6 +15,7 @@ import static org.briarproject.briar.privategroup.invitation.CreatorState.JOINED
import static org.briarproject.briar.privategroup.invitation.CreatorState.LEFT;
import static org.briarproject.briar.privategroup.invitation.CreatorState.START;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
@@ -36,15 +37,15 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
public void testOnInviteActionFromStart() throws Exception {
CreatorSession session =
new CreatorSession(contactGroupId, privateGroupId);
String message = "Invitation Message";
String text = "Invitation text";
expectOnLocalInvite(message);
expectOnLocalInvite(text);
CreatorSession newSession =
engine.onInviteAction(txn, session, message, inviteTimestamp,
engine.onInviteAction(txn, session, text, inviteTimestamp,
signature);
assertEquals(INVITED, newSession.getState());
assertEquals(messageId, newSession.getLastLocalMessageId());
assertEquals(null, newSession.getLastRemoteMessageId());
assertNull(newSession.getLastRemoteMessageId());
assertEquals(messageTimestamp, newSession.getLocalTimestamp());
assertEquals(inviteTimestamp, newSession.getInviteTimestamp());
assertSessionConstantsUnchanged(session, newSession);
@@ -61,13 +62,13 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
signature);
assertEquals(INVITED, newSession.getState());
assertEquals(messageId, newSession.getLastLocalMessageId());
assertEquals(null, newSession.getLastRemoteMessageId());
assertNull(newSession.getLastRemoteMessageId());
assertEquals(messageTimestamp, newSession.getLocalTimestamp());
assertEquals(inviteTimestamp, newSession.getInviteTimestamp());
assertSessionConstantsUnchanged(session, newSession);
}
private void expectOnLocalInvite(String msg) throws Exception {
private void expectOnLocalInvite(String text) throws Exception {
context.checking(new Expectations() {{
oneOf(db).getGroup(txn, privateGroupId);
will(returnValue(privateGroupGroup));
@@ -75,7 +76,7 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
will(returnValue(privateGroup));
oneOf(messageTracker).trackOutgoingMessage(txn, message);
}});
expectSendInviteMessage(msg);
expectSendInviteMessage(text);
expectGetLocalTimestamp(messageTimestamp);
}
@@ -112,7 +113,7 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
// onJoinAction
@Test(expected = UnsupportedOperationException.class)
public void testOnJoinActionFails() throws Exception {
public void testOnJoinActionFails() {
engine.onJoinAction(txn, getDefaultSession(START));
}
@@ -186,7 +187,7 @@ public class CreatorProtocolEngineTest extends AbstractProtocolEngineTest {
// onMemberAddedAction
@Test
public void testOnMemberAddedAction() throws Exception {
public void testOnMemberAddedAction() {
CreatorSession session = getDefaultSession(START);
assertEquals(session, engine.onMemberAddedAction(txn, session));

View File

@@ -76,8 +76,8 @@ public class GroupInvitationIntegrationTest
@Test
public void testSendInvitation() throws Exception {
long timestamp = clock.currentTimeMillis();
String msg = "Hi!";
sendInvitation(timestamp, msg);
String text = "Hi!";
sendInvitation(timestamp, text);
sync0To1(1, true);
@@ -97,7 +97,7 @@ public class GroupInvitationIntegrationTest
assertEquals(1, messages.size());
GroupInvitationRequest request =
(GroupInvitationRequest) messages.iterator().next();
assertEquals(msg, request.getMessage());
assertEquals(text, request.getText());
assertEquals(author0, request.getNameable().getCreator());
assertEquals(timestamp, request.getTimestamp());
assertEquals(privateGroup0.getName(), request.getNameable().getName());
@@ -442,12 +442,12 @@ public class GroupInvitationIntegrationTest
sync1To0(1, true);
}
private void sendInvitation(long timestamp, @Nullable String msg) throws
private void sendInvitation(long timestamp, @Nullable String text) throws
DbException {
byte[] signature = groupInvitationFactory.signInvitation(contact1From0,
privateGroup0.getId(), timestamp, author0.getPrivateKey());
groupInvitationManager0
.sendInvitation(privateGroup0.getId(), contactId1From0, msg,
.sendInvitation(privateGroup0.getId(), contactId1From0, text,
timestamp, signature);
}

View File

@@ -464,7 +464,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
@Test
public void testSendFirstInvitation() throws Exception {
String msg = "Invitation text for first invitation";
String text = "Invitation text for first invitation";
long time = 42L;
byte[] signature = getRandomBytes(42);
@@ -481,7 +481,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
expectCreateStorageId();
context.checking(new Expectations() {{
oneOf(creatorEngine).onInviteAction(with(txn),
with(any(CreatorSession.class)), with(msg), with(time),
with(any(CreatorSession.class)), with(text), with(time),
with(signature));
will(returnValue(creatorSession));
}});
@@ -491,12 +491,12 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
oneOf(db).endTransaction(txn);
}});
groupInvitationManager.sendInvitation(privateGroup.getId(), contactId,
msg, time, signature);
text, time, signature);
}
@Test
public void testSendSubsequentInvitation() throws Exception {
String msg = "Invitation text for subsequent invitation";
String text = "Invitation text for subsequent invitation";
long time = 43L;
byte[] signature = getRandomBytes(43);
@@ -513,7 +513,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
.parseCreatorSession(contactGroup.getId(), bdfSession);
will(returnValue(creatorSession));
oneOf(creatorEngine).onInviteAction(with(txn),
with(any(CreatorSession.class)), with(msg), with(time),
with(any(CreatorSession.class)), with(text), with(time),
with(signature));
will(returnValue(creatorSession));
}});
@@ -523,7 +523,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
oneOf(db).endTransaction(txn);
}});
groupInvitationManager.sendInvitation(privateGroup.getId(), contactId,
msg, time, signature);
text, time, signature);
}
@Test(expected = IllegalArgumentException.class)

View File

@@ -22,7 +22,7 @@ import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.GROUP_SALT_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_MSG_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_TEXT_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_NAME_LENGTH;
import static org.briarproject.briar.api.privategroup.invitation.GroupInvitationFactory.SIGNING_LABEL_INVITE;
import static org.briarproject.briar.privategroup.invitation.MessageType.ABORT;
@@ -47,8 +47,8 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
);
private final String groupName = getRandomString(MAX_GROUP_NAME_LENGTH);
private final byte[] salt = getRandomBytes(GROUP_SALT_LENGTH);
private final String content =
getRandomString(MAX_GROUP_INVITATION_MSG_LENGTH);
private final String text =
getRandomString(MAX_GROUP_INVITATION_TEXT_LENGTH);
private final byte[] signature = getRandomBytes(MAX_SIGNATURE_LENGTH);
private final PrivateGroup privateGroup =
new PrivateGroup(group, groupName, creator, salt);
@@ -64,14 +64,14 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
@Test(expected = FormatException.class)
public void testRejectsTooShortInviteMessage() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content);
salt, text);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsTooLongInviteMessage() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, signature, "");
salt, text, signature, "");
validator.validateMessage(message, group, body);
}
@@ -79,7 +79,7 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
public void testRejectsInviteMessageWithTooShortGroupName()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, "", salt,
content, signature);
text, signature);
validator.validateMessage(message, group, body);
}
@@ -88,14 +88,14 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
throws Exception {
String tooLongName = getRandomString(MAX_GROUP_NAME_LENGTH + 1);
BdfList body = BdfList.of(INVITE.getValue(), creatorList, tooLongName,
salt, content, signature);
salt, text, signature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNullGroupName() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, null, salt,
content, signature);
text, signature);
validator.validateMessage(message, group, body);
}
@@ -103,21 +103,21 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
public void testRejectsInviteMessageWithNonStringGroupName()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList,
getRandomBytes(5), salt, content, signature);
getRandomBytes(5), salt, text, signature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNullCreator() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), null, groupName, salt,
content, signature);
text, signature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNonListCreator() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), 123, groupName, salt,
content, signature);
text, signature);
validator.validateMessage(message, group, body);
}
@@ -129,7 +129,7 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
}});
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, signature);
salt, text, signature);
validator.validateMessage(message, group, body);
}
@@ -137,7 +137,7 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
public void testRejectsInviteMessageWithTooShortGroupSalt()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
getRandomBytes(GROUP_SALT_LENGTH - 1), content, signature);
getRandomBytes(GROUP_SALT_LENGTH - 1), text, signature);
validator.validateMessage(message, group, body);
}
@@ -145,41 +145,41 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
public void testRejectsInviteMessageWithTooLongGroupSalt()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
getRandomBytes(GROUP_SALT_LENGTH + 1), content, signature);
getRandomBytes(GROUP_SALT_LENGTH + 1), text, signature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNullGroupSalt() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
null, content, signature);
null, text, signature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNonRawGroupSalt() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
"not raw", content, signature);
"not raw", text, signature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithTooShortContent() throws Exception {
public void testRejectsInviteMessageWithTooShortText() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, "", signature);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithTooLongContent() throws Exception {
public void testRejectsInviteMessageWithTooLongText() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, getRandomString(MAX_GROUP_INVITATION_MSG_LENGTH + 1),
salt, getRandomString(MAX_GROUP_INVITATION_TEXT_LENGTH + 1),
signature);
validator.validateMessage(message, group, body);
}
@Test
public void testAcceptsInviteMessageWithNullContent() throws Exception {
public void testAcceptsInviteMessageWithNullText() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, null, signature);
expectInviteMessage(false);
@@ -187,7 +187,7 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNonStringContent()
public void testRejectsInviteMessageWithNonStringText()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, getRandomBytes(5), signature);
@@ -198,7 +198,7 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
public void testRejectsInviteMessageWithTooShortSignature()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, new byte[0]);
salt, text, new byte[0]);
validator.validateMessage(message, group, body);
}
@@ -206,21 +206,21 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
public void testRejectsInviteMessageWithTooLongSignature()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, getRandomBytes(MAX_SIGNATURE_LENGTH + 1));
salt, text, getRandomBytes(MAX_SIGNATURE_LENGTH + 1));
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNullSignature() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, null);
salt, text, null);
validator.validateMessage(message, group, body);
}
@Test(expected = FormatException.class)
public void testRejectsInviteMessageWithNonRawSignature() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, "not raw");
salt, text, "not raw");
validator.validateMessage(message, group, body);
}
@@ -228,7 +228,7 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
public void testRejectsInviteMessageWithInvalidSignature()
throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, signature);
salt, text, signature);
expectInviteMessage(true);
validator.validateMessage(message, group, body);
}
@@ -236,7 +236,7 @@ public class GroupInvitationValidatorTest extends ValidatorTestCase {
@Test
public void testAcceptsValidInviteMessage() throws Exception {
BdfList body = BdfList.of(INVITE.getValue(), creatorList, groupName,
salt, content, signature);
salt, text, signature);
expectInviteMessage(false);
BdfMessageContext messageContext =
validator.validateMessage(message, group, body);

View File

@@ -21,7 +21,7 @@ import static org.briarproject.bramble.test.TestUtils.getAuthor;
import static org.briarproject.bramble.test.TestUtils.getLocalAuthor;
import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_MSG_LENGTH;
import static org.briarproject.briar.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_TEXT_LENGTH;
import static org.briarproject.briar.privategroup.invitation.InviteeState.ACCEPTED;
import static org.briarproject.briar.privategroup.invitation.InviteeState.DISSOLVED;
import static org.briarproject.briar.privategroup.invitation.InviteeState.ERROR;
@@ -327,7 +327,7 @@ public class InviteeProtocolEngineTest extends AbstractProtocolEngineTest {
privateGroupId, session.getInviteTimestamp() + 1,
privateGroup.getName(), privateGroup.getCreator(),
privateGroup.getSalt(),
getRandomString(MAX_GROUP_INVITATION_MSG_LENGTH),
getRandomString(MAX_GROUP_INVITATION_TEXT_LENGTH),
signature);
Author notCreator = getAuthor();
Contact notCreatorContact = new Contact(contactId, notCreator,

View File

@@ -159,7 +159,7 @@ public class BlogSharingIntegrationTest
assertEquals(blog2.getAuthor().getName(),
invitation.getName());
assertFalse(invitation.getNameable().isRssFeed());
assertEquals("Hi!", invitation.getMessage());
assertEquals("Hi!", invitation.getText());
} else {
BlogInvitationResponse response = (BlogInvitationResponse) m;
assertEquals(blog2.getId(), response.getShareableId());
@@ -232,7 +232,7 @@ public class BlogSharingIntegrationTest
assertEquals(rssBlog.getAuthor().getName(),
invitation.getName());
assertTrue(invitation.getNameable().isRssFeed());
assertEquals("Hi!", invitation.getMessage());
assertEquals("Hi!", invitation.getText());
} else {
BlogInvitationResponse response = (BlogInvitationResponse) m;
assertEquals(rssBlog.getId(), response.getShareableId());
@@ -293,7 +293,7 @@ public class BlogSharingIntegrationTest
assertTrue(invitation.wasAnswered());
assertEquals(blog2.getAuthor().getName(),
invitation.getName());
assertNull(invitation.getMessage());
assertNull(invitation.getText());
} else {
BlogInvitationResponse response = (BlogInvitationResponse) m;
assertEquals(blog2.getId(), response.getShareableId());

View File

@@ -10,7 +10,7 @@ import org.junit.Test;
import static org.briarproject.bramble.test.TestUtils.getAuthor;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.sharing.SharingConstants.MAX_INVITATION_MESSAGE_LENGTH;
import static org.briarproject.briar.api.sharing.SharingConstants.MAX_INVITATION_TEXT_LENGTH;
import static org.briarproject.briar.sharing.MessageType.INVITE;
public class BlogSharingValidatorTest extends SharingValidatorTest {
@@ -20,8 +20,7 @@ public class BlogSharingValidatorTest extends SharingValidatorTest {
private final BdfList authorList = BdfList.of(author.getFormatVersion(),
author.getName(), author.getPublicKey());
private final BdfList descriptor = BdfList.of(authorList, false);
private final String content =
getRandomString(MAX_INVITATION_MESSAGE_LENGTH);
private final String text = getRandomString(MAX_INVITATION_TEXT_LENGTH);
@Override
SharingValidator getValidator() {
@@ -30,17 +29,16 @@ public class BlogSharingValidatorTest extends SharingValidatorTest {
}
@Test
public void testAcceptsInvitationWithContent() throws Exception {
public void testAcceptsInvitationWithText() throws Exception {
expectCreateBlog();
expectEncodeMetadata(INVITE);
BdfMessageContext context = validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, descriptor,
content));
BdfList.of(INVITE.getValue(), previousMsgId, descriptor, text));
assertExpectedContext(context, previousMsgId);
}
@Test
public void testAcceptsInvitationWithNullContent() throws Exception {
public void testAcceptsInvitationWithNullText() throws Exception {
expectCreateBlog();
expectEncodeMetadata(INVITE);
BdfMessageContext context = validator.validateMessage(message, group,
@@ -53,7 +51,7 @@ public class BlogSharingValidatorTest extends SharingValidatorTest {
expectCreateBlog();
expectEncodeMetadata(INVITE);
BdfMessageContext context = validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), null, descriptor, content));
BdfList.of(INVITE.getValue(), null, descriptor, text));
assertExpectedContext(context, null);
}
@@ -64,7 +62,7 @@ public class BlogSharingValidatorTest extends SharingValidatorTest {
BdfList rssDescriptor = BdfList.of(authorList, true);
BdfMessageContext context = validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, rssDescriptor,
content));
text));
assertExpectedContext(context, previousMsgId);
}
@@ -85,32 +83,30 @@ public class BlogSharingValidatorTest extends SharingValidatorTest {
}
@Test(expected = FormatException.class)
public void testRejectsNonStringContent() throws Exception {
public void testRejectsNonStringText() throws Exception {
expectCreateBlog();
validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, descriptor,
123));
BdfList.of(INVITE.getValue(), previousMsgId, descriptor, 123));
}
@Test
public void testAcceptsMinLengthContent() throws Exception {
String shortContent = getRandomString(1);
public void testAcceptsMinLengthText() throws Exception {
String shortText = getRandomString(1);
expectCreateBlog();
expectEncodeMetadata(INVITE);
BdfMessageContext context = validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, descriptor,
shortContent));
shortText));
assertExpectedContext(context, previousMsgId);
}
@Test(expected = FormatException.class)
public void testRejectsTooLongContent() throws Exception {
String invalidContent =
getRandomString(MAX_INVITATION_MESSAGE_LENGTH + 1);
public void testRejectsTooLongText() throws Exception {
String invalidText = getRandomString(MAX_INVITATION_TEXT_LENGTH + 1);
expectCreateBlog();
validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, descriptor,
invalidContent));
invalidText));
}
private void expectCreateBlog() throws Exception {

View File

@@ -139,7 +139,7 @@ public class ForumSharingIntegrationTest
assertTrue(invitation.wasAnswered());
assertEquals(forum0.getName(), invitation.getName());
assertEquals(forum0, invitation.getNameable());
assertEquals("Hi!", invitation.getMessage());
assertEquals("Hi!", invitation.getText());
assertTrue(invitation.canBeOpened());
} else {
ForumInvitationResponse response = (ForumInvitationResponse) m;
@@ -195,7 +195,7 @@ public class ForumSharingIntegrationTest
assertEquals(forum0, invitation.getNameable());
assertTrue(invitation.wasAnswered());
assertEquals(forum0.getName(), invitation.getName());
assertNull(invitation.getMessage());
assertNull(invitation.getText());
assertFalse(invitation.canBeOpened());
} else {
ForumInvitationResponse response = (ForumInvitationResponse) m;
@@ -635,10 +635,9 @@ public class ForumSharingIntegrationTest
// sharer posts into the forum
long time = clock.currentTimeMillis();
String body = getRandomString(42);
String text = getRandomString(42);
ForumPost p = forumPostFactory
.createPost(forum0.getId(), time, null, author0,
body);
.createPost(forum0.getId(), time, null, author0, text);
forumManager0.addLocalPost(p);
// sync forum post
@@ -654,10 +653,9 @@ public class ForumSharingIntegrationTest
// now invitee creates a post
time = clock.currentTimeMillis();
body = getRandomString(42);
text = getRandomString(42);
p = forumPostFactory
.createPost(forum0.getId(), time, null, author1,
body);
.createPost(forum0.getId(), time, null, author1, text);
forumManager1.addLocalPost(p);
// sync forum post
@@ -697,10 +695,9 @@ public class ForumSharingIntegrationTest
// now invitee creates a post
time = clock.currentTimeMillis();
body = getRandomString(42);
text = getRandomString(42);
p = forumPostFactory
.createPost(forum0.getId(), time, null, author1,
body);
.createPost(forum0.getId(), time, null, author1, text);
forumManager1.addLocalPost(p);
// sync forum post

View File

@@ -11,7 +11,7 @@ import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_SALT_LENGTH;
import static org.briarproject.briar.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
import static org.briarproject.briar.api.sharing.SharingConstants.MAX_INVITATION_MESSAGE_LENGTH;
import static org.briarproject.briar.api.sharing.SharingConstants.MAX_INVITATION_TEXT_LENGTH;
import static org.briarproject.briar.sharing.MessageType.INVITE;
public class ForumSharingValidatorTest extends SharingValidatorTest {
@@ -20,8 +20,7 @@ public class ForumSharingValidatorTest extends SharingValidatorTest {
private final byte[] salt = getRandomBytes(FORUM_SALT_LENGTH);
private final Forum forum = new Forum(group, forumName, salt);
private final BdfList descriptor = BdfList.of(forumName, salt);
private final String content =
getRandomString(MAX_INVITATION_MESSAGE_LENGTH);
private final String text = getRandomString(MAX_INVITATION_TEXT_LENGTH);
@Override
SharingValidator getValidator() {
@@ -30,17 +29,16 @@ public class ForumSharingValidatorTest extends SharingValidatorTest {
}
@Test
public void testAcceptsInvitationWithContent() throws Exception {
public void testAcceptsInvitationWithText() throws Exception {
expectCreateForum(forumName);
expectEncodeMetadata(INVITE);
BdfMessageContext context = validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, descriptor,
content));
BdfList.of(INVITE.getValue(), previousMsgId, descriptor, text));
assertExpectedContext(context, previousMsgId);
}
@Test
public void testAcceptsInvitationWithNullContent() throws Exception {
public void testAcceptsInvitationWithNullText() throws Exception {
expectCreateForum(forumName);
expectEncodeMetadata(INVITE);
BdfMessageContext context = validator.validateMessage(message, group,
@@ -137,14 +135,14 @@ public class ForumSharingValidatorTest extends SharingValidatorTest {
}
@Test(expected = FormatException.class)
public void testRejectsNonStringContent() throws Exception {
public void testRejectsNonStringText() throws Exception {
expectCreateForum(forumName);
validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, descriptor, 123));
}
@Test
public void testAcceptsMinLengthContent() throws Exception {
public void testAcceptsMinLengthText() throws Exception {
expectCreateForum(forumName);
expectEncodeMetadata(INVITE);
BdfMessageContext context = validator.validateMessage(message, group,
@@ -153,13 +151,12 @@ public class ForumSharingValidatorTest extends SharingValidatorTest {
}
@Test(expected = FormatException.class)
public void testRejectsTooLongContent() throws Exception {
String invalidContent =
getRandomString(MAX_INVITATION_MESSAGE_LENGTH + 1);
public void testRejectsTooLongText() throws Exception {
String invalidText = getRandomString(MAX_INVITATION_TEXT_LENGTH + 1);
expectCreateForum(forumName);
validator.validateMessage(message, group,
BdfList.of(INVITE.getValue(), previousMsgId, descriptor,
invalidContent));
invalidText));
}
private void expectCreateForum(String name) {