Unit tests to catch a noobish JDBC error.

This commit is contained in:
akwizgran
2013-12-19 23:13:08 +00:00
parent 17ef84c070
commit 676ef9518b
2 changed files with 41 additions and 6 deletions

View File

@@ -1628,6 +1628,39 @@ public class H2DatabaseTest extends BriarTestCase {
db.close();
}
@Test
public void testGetInboxMessageHeaders() throws Exception {
Database<Connection> db = open(false);
Connection txn = db.startTransaction();
// Add a contact and an inbox group - no headers should be returned
db.addLocalAuthor(txn, localAuthor);
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
Group inbox = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH],
true);
db.addGroup(txn, inbox);
db.setInboxGroup(txn, contactId, inbox);
assertEquals(Collections.emptyList(),
db.getInboxMessageHeaders(txn, contactId));
// Add a message to the inbox group - the header should be returned
db.addMessage(txn, message, false);
Collection<MessageHeader> headers =
db.getInboxMessageHeaders(txn, contactId);
assertEquals(1, headers.size());
MessageHeader header = headers.iterator().next();
assertEquals(messageId, header.getId());
assertNull(header.getParent());
assertEquals(groupId, header.getGroupId());
assertEquals(localAuthor, header.getAuthor());
assertEquals(contentType, header.getContentType());
assertEquals(timestamp, header.getTimestamp());
assertFalse(header.isRead());
db.commitTransaction(txn);
db.close();
}
@Test
public void testExceptionHandling() throws Exception {
Database<Connection> db = open(false);