mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Add method for getting cooked message from DB.
This commit is contained in:
@@ -613,11 +613,11 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
|
||||
throws Exception {
|
||||
context.checking(new Expectations() {{
|
||||
// Check whether the message is in the DB (which it's not)
|
||||
exactly(11).of(database).startTransaction();
|
||||
exactly(12).of(database).startTransaction();
|
||||
will(returnValue(txn));
|
||||
exactly(11).of(database).containsMessage(txn, messageId);
|
||||
exactly(12).of(database).containsMessage(txn, messageId);
|
||||
will(returnValue(false));
|
||||
exactly(11).of(database).abortTransaction(txn);
|
||||
exactly(12).of(database).abortTransaction(txn);
|
||||
// This is needed for getMessageStatus() to proceed
|
||||
exactly(1).of(database).containsContact(txn, contactId);
|
||||
will(returnValue(true));
|
||||
@@ -645,6 +645,16 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
|
||||
db.endTransaction(transaction);
|
||||
}
|
||||
|
||||
transaction = db.startTransaction(false);
|
||||
try {
|
||||
db.getMessage(transaction, messageId);
|
||||
fail();
|
||||
} catch (NoSuchMessageException expected) {
|
||||
// Expected
|
||||
} finally {
|
||||
db.endTransaction(transaction);
|
||||
}
|
||||
|
||||
transaction = db.startTransaction(false);
|
||||
try {
|
||||
db.getRawMessage(transaction, messageId);
|
||||
|
||||
@@ -1638,6 +1638,13 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
|
||||
ids = db.getMessagesToOffer(txn, contactId, 100);
|
||||
assertEquals(singletonList(messageId), ids);
|
||||
|
||||
// The message should be available
|
||||
Message m = db.getMessage(txn, messageId);
|
||||
assertEquals(messageId, m.getId());
|
||||
assertEquals(groupId, m.getGroupId());
|
||||
assertEquals(message.getTimestamp(), m.getTimestamp());
|
||||
assertArrayEquals(message.getRaw(), m.getRaw());
|
||||
|
||||
// The raw message should be available
|
||||
assertArrayEquals(message.getRaw(), db.getRawMessage(txn, messageId));
|
||||
|
||||
@@ -1653,6 +1660,14 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
|
||||
ids = db.getMessagesToOffer(txn, contactId, 100);
|
||||
assertTrue(ids.isEmpty());
|
||||
|
||||
// Requesting the message should throw an exception
|
||||
try {
|
||||
db.getMessage(txn, messageId);
|
||||
fail();
|
||||
} catch (MessageDeletedException expected) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
// Requesting the raw message should throw an exception
|
||||
try {
|
||||
db.getRawMessage(txn, messageId);
|
||||
|
||||
Reference in New Issue
Block a user