mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Replace transaction.setComplete() by database.commitTransaction()
This commit is contained in:
@@ -509,7 +509,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
queue.sendMessage(txn, group, time, body, new Metadata());
|
queue.sendMessage(txn, group, time, body, new Metadata());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -580,7 +580,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
DatabaseComponent db1 = t1.getDatabaseComponent();
|
DatabaseComponent db1 = t1.getDatabaseComponent();
|
||||||
Transaction txn = db1.startTransaction(false);
|
Transaction txn = db1.startTransaction(false);
|
||||||
db1.addGroup(txn, forum0.getGroup());
|
db1.addGroup(txn, forum0.getGroup());
|
||||||
txn.setComplete();
|
db1.commitTransaction(txn);
|
||||||
db1.endTransaction(txn);
|
db1.endTransaction(txn);
|
||||||
|
|
||||||
// send invitation
|
// send invitation
|
||||||
@@ -707,7 +707,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
queue.sendMessage(txn, group, time, body, new Metadata());
|
queue.sendMessage(txn, group, time, body, new Metadata());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -736,7 +736,7 @@ public class ForumSharingIntegrationTest extends BriarTestCase {
|
|||||||
DatabaseComponent db2 = t2.getDatabaseComponent();
|
DatabaseComponent db2 = t2.getDatabaseComponent();
|
||||||
Transaction txn = db2.startTransaction(false);
|
Transaction txn = db2.startTransaction(false);
|
||||||
db2.addGroup(txn, forum0.getGroup());
|
db2.addGroup(txn, forum0.getGroup());
|
||||||
txn.setComplete();
|
db2.commitTransaction(txn);
|
||||||
db2.endTransaction(txn);
|
db2.endTransaction(txn);
|
||||||
|
|
||||||
// add listeners
|
// add listeners
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ public class PrivateGroupManagerTest extends BriarIntegrationTest {
|
|||||||
t0.getDatabaseComponent()
|
t0.getDatabaseComponent()
|
||||||
.setVisibleToContact(txn0, contactId1, privateGroup0.getId(),
|
.setVisibleToContact(txn0, contactId1, privateGroup0.getId(),
|
||||||
true);
|
true);
|
||||||
txn0.setComplete();
|
t0.getDatabaseComponent().commitTransaction(txn0);
|
||||||
t0.getDatabaseComponent().endTransaction(txn0);
|
t0.getDatabaseComponent().endTransaction(txn0);
|
||||||
|
|
||||||
// author1 joins privateGroup0 and refers to wrong NEW_MEMBER message
|
// author1 joins privateGroup0 and refers to wrong NEW_MEMBER message
|
||||||
@@ -358,7 +358,7 @@ public class PrivateGroupManagerTest extends BriarIntegrationTest {
|
|||||||
t1.getDatabaseComponent()
|
t1.getDatabaseComponent()
|
||||||
.setVisibleToContact(txn1, contactId0, privateGroup0.getId(),
|
.setVisibleToContact(txn1, contactId0, privateGroup0.getId(),
|
||||||
true);
|
true);
|
||||||
txn1.setComplete();
|
t1.getDatabaseComponent().commitTransaction(txn1);
|
||||||
t1.getDatabaseComponent().endTransaction(txn1);
|
t1.getDatabaseComponent().endTransaction(txn1);
|
||||||
|
|
||||||
// sync join messages
|
// sync join messages
|
||||||
@@ -467,7 +467,7 @@ public class PrivateGroupManagerTest extends BriarIntegrationTest {
|
|||||||
t0.getDatabaseComponent()
|
t0.getDatabaseComponent()
|
||||||
.setVisibleToContact(txn0, contactId1, privateGroup0.getId(),
|
.setVisibleToContact(txn0, contactId1, privateGroup0.getId(),
|
||||||
true);
|
true);
|
||||||
txn0.setComplete();
|
t0.getDatabaseComponent().commitTransaction(txn0);;
|
||||||
t0.getDatabaseComponent().endTransaction(txn0);
|
t0.getDatabaseComponent().endTransaction(txn0);
|
||||||
|
|
||||||
// author1 joins privateGroup0
|
// author1 joins privateGroup0
|
||||||
@@ -487,7 +487,7 @@ public class PrivateGroupManagerTest extends BriarIntegrationTest {
|
|||||||
t1.getDatabaseComponent()
|
t1.getDatabaseComponent()
|
||||||
.setVisibleToContact(txn1, contactId0, privateGroup0.getId(),
|
.setVisibleToContact(txn1, contactId0, privateGroup0.getId(),
|
||||||
true);
|
true);
|
||||||
txn1.setComplete();
|
t1.getDatabaseComponent().commitTransaction(txn1);
|
||||||
t1.getDatabaseComponent().endTransaction(txn1);
|
t1.getDatabaseComponent().endTransaction(txn1);
|
||||||
|
|
||||||
// sync join messages
|
// sync join messages
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
Transaction txn = db0.startTransaction(false);
|
Transaction txn = db0.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
sender0.sendMessage(txn, d);
|
sender0.sendMessage(txn, d);
|
||||||
txn.setComplete();
|
db0.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db0.endTransaction(txn);
|
db0.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -637,7 +637,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
Transaction txn = db1.startTransaction(false);
|
Transaction txn = db1.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
map = db1.getMessageMetadata(txn, group1.getId());
|
map = db1.getMessageMetadata(txn, group1.getId());
|
||||||
txn.setComplete();
|
db1.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db1.endTransaction(txn);
|
db1.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -651,7 +651,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
txn = db1.startTransaction(false);
|
txn = db1.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
map = db1.getMessageMetadata(txn, group1.getId());
|
map = db1.getMessageMetadata(txn, group1.getId());
|
||||||
txn.setComplete();
|
db1.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db1.endTransaction(txn);
|
db1.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -694,7 +694,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
Transaction txn = db0.startTransaction(false);
|
Transaction txn = db0.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
map = db0.getMessageMetadata(txn, group1.getId());
|
map = db0.getMessageMetadata(txn, group1.getId());
|
||||||
txn.setComplete();
|
db0.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db0.endTransaction(txn);
|
db0.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -708,7 +708,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
txn = db0.startTransaction(false);
|
txn = db0.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
map = db0.getMessageMetadata(txn, group1.getId());
|
map = db0.getMessageMetadata(txn, group1.getId());
|
||||||
txn.setComplete();
|
db0.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db0.endTransaction(txn);
|
db0.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -722,7 +722,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
txn = db0.startTransaction(false);
|
txn = db0.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
map = db0.getMessageMetadata(txn, group1.getId());
|
map = db0.getMessageMetadata(txn, group1.getId());
|
||||||
txn.setComplete();
|
db0.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db0.endTransaction(txn);
|
db0.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -780,7 +780,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
try {
|
try {
|
||||||
db0.deleteMessage(txn, responseId);
|
db0.deleteMessage(txn, responseId);
|
||||||
sender0.sendMessage(txn, response);
|
sender0.sendMessage(txn, response);
|
||||||
txn.setComplete();
|
db0.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db0.endTransaction(txn);
|
db0.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -804,7 +804,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
txn = db2.startTransaction(true);
|
txn = db2.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
contacts2 = db2.getContacts(txn);
|
contacts2 = db2.getContacts(txn);
|
||||||
txn.setComplete();
|
db2.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db2.endTransaction(txn);
|
db2.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -832,7 +832,7 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
txn = db1.startTransaction(true);
|
txn = db1.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
contacts1 = db1.getContacts(txn);
|
contacts1 = db1.getContacts(txn);
|
||||||
txn.setComplete();
|
db1.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db1.endTransaction(txn);
|
db1.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,11 +52,17 @@ public interface DatabaseComponent {
|
|||||||
Transaction startTransaction(boolean readOnly) throws DbException;
|
Transaction startTransaction(boolean readOnly) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends a transaction. If the transaction is marked as complete, the
|
* Commits a transaction to the database.
|
||||||
* transaction is committed and any events attached to the transaction are
|
|
||||||
* broadcast; otherwise the transaction is aborted.
|
|
||||||
*/
|
*/
|
||||||
void endTransaction(Transaction txn) throws DbException;
|
void commitTransaction(Transaction txn) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ends a transaction. If the transaction has not been committed,
|
||||||
|
* it will be aborted. If the transaction has been committed,
|
||||||
|
* any events attached to the transaction are broadcast.
|
||||||
|
* The database lock will be released in either case.
|
||||||
|
*/
|
||||||
|
void endTransaction(Transaction txn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a contact associated with the given local and remote pseudonyms,
|
* Stores a contact associated with the given local and remote pseudonyms,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class Transaction {
|
|||||||
private final boolean readOnly;
|
private final boolean readOnly;
|
||||||
|
|
||||||
private List<Event> events = null;
|
private List<Event> events = null;
|
||||||
private boolean complete = false;
|
private boolean committed = false;
|
||||||
|
|
||||||
public Transaction(Object txn, boolean readOnly) {
|
public Transaction(Object txn, boolean readOnly) {
|
||||||
this.txn = txn;
|
this.txn = txn;
|
||||||
@@ -55,18 +55,18 @@ public class Transaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the transaction is ready to be committed.
|
* Returns true if the transaction has been committed.
|
||||||
*/
|
*/
|
||||||
public boolean isComplete() {
|
public boolean isCommitted() {
|
||||||
return complete;
|
return committed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the transaction as ready to be committed. This method must not be
|
* Marks the transaction as committed. This method should only be called
|
||||||
* called more than once.
|
* by the DatabaseComponent. It must not be called more than once.
|
||||||
*/
|
*/
|
||||||
public void setComplete() {
|
public void setCommitted() {
|
||||||
if (complete) throw new IllegalStateException();
|
if (committed) throw new IllegalStateException();
|
||||||
complete = true;
|
committed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
boolean canBeRemoved = canBeRemoved(txn, g);
|
boolean canBeRemoved = canBeRemoved(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return canBeRemoved;
|
return canBeRemoved;
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
@@ -228,7 +228,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
for (RemoveBlogHook hook : removeHooks)
|
for (RemoveBlogHook hook : removeHooks)
|
||||||
hook.removingBlog(txn, b);
|
hook.removingBlog(txn, b);
|
||||||
db.removeGroup(txn, b.getGroup());
|
db.removeGroup(txn, b.getGroup());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -239,7 +239,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
addLocalPost(txn, p);
|
addLocalPost(txn, p);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
//noinspection ThrowFromFinallyBlock
|
//noinspection ThrowFromFinallyBlock
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
@@ -309,7 +309,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
meta);
|
meta);
|
||||||
BlogPostAddedEvent event = new BlogPostAddedEvent(groupId, h, true);
|
BlogPostAddedEvent event = new BlogPostAddedEvent(groupId, h, true);
|
||||||
txn.attach(event);
|
txn.attach(event);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
@@ -394,7 +394,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
blog = getBlog(txn, g);
|
blog = getBlog(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -441,7 +441,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
for (Group g : groups) {
|
for (Group g : groups) {
|
||||||
blogs.add(blogFactory.parseBlog(g));
|
blogs.add(blogFactory.parseBlog(g));
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -459,7 +459,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
BdfDictionary meta =
|
BdfDictionary meta =
|
||||||
clientHelper.getMessageMetadataAsDictionary(txn, m);
|
clientHelper.getMessageMetadataAsDictionary(txn, m);
|
||||||
BlogPostHeader h = getPostHeaderFromMetadata(txn, g, m, meta);
|
BlogPostHeader h = getPostHeaderFromMetadata(txn, g, m, meta);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return h;
|
return h;
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
@@ -538,7 +538,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
|||||||
authorStatuses);
|
authorStatuses);
|
||||||
headers.add(h);
|
headers.add(h);
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return headers;
|
return headers;
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public abstract class BdfIncomingMessageHook implements IncomingMessageHook,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
count = getGroupCount(txn, g);
|
count = getGroupCount(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
@@ -157,7 +157,7 @@ public abstract class BdfIncomingMessageHook implements IncomingMessageHook,
|
|||||||
c.getUnreadCount() + (read ? -1 : 1));
|
c.getUnreadCount() + (read ? -1 : 1));
|
||||||
clientHelper.mergeGroupMetadata(txn, g, d);
|
clientHelper.mergeGroupMetadata(txn, g, d);
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
addLocalMessage(txn, m, metadata, shared);
|
addLocalMessage(txn, m, metadata, shared);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
list = getMessageAsList(txn, m);
|
list = getMessageAsList(txn, m);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
dictionary = getGroupMetadataAsDictionary(txn, g);
|
dictionary = getGroupMetadataAsDictionary(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
dictionary = getMessageMetadataAsDictionary(txn, m);
|
dictionary = getMessageMetadataAsDictionary(txn, m);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
map = getMessageMetadataAsDictionary(txn, g);
|
map = getMessageMetadataAsDictionary(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
map = getMessageMetadataAsDictionary(txn, g, query);
|
map = getMessageMetadataAsDictionary(txn, g, query);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
mergeGroupMetadata(txn, g, metadata);
|
mergeGroupMetadata(txn, g, metadata);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
mergeMessageMetadata(txn, m, metadata);
|
mergeMessageMetadata(txn, m, metadata);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ public class ContactExchangeTaskImpl extends Thread
|
|||||||
localAuthor.getId(), master, timestamp, alice, true, true);
|
localAuthor.getId(), master, timestamp, alice, true, true);
|
||||||
transportPropertyManager.addRemoteProperties(txn, contactId,
|
transportPropertyManager.addRemoteProperties(txn, contactId,
|
||||||
remoteProperties);
|
remoteProperties);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
try {
|
try {
|
||||||
c = addContact(txn, remote, local, master, timestamp, alice,
|
c = addContact(txn, remote, local, master, timestamp, alice,
|
||||||
verified, active);
|
verified, active);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
contact = db.getContact(txn, c);
|
contact = db.getContact(txn, c);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
contacts = db.getContacts(txn);
|
contacts = db.getContacts(txn);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
removeContact(txn, c);
|
removeContact(txn, c);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
exists = contactExists(txn, remoteAuthorId, localAuthorId);
|
exists = contactExists(txn, remoteAuthorId, localAuthorId);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,21 +139,28 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endTransaction(Transaction transaction) throws DbException {
|
public void commitTransaction(Transaction transaction) throws DbException {
|
||||||
|
T txn = txnClass.cast(transaction.unbox());
|
||||||
|
if (transaction.isCommitted()) throw new IllegalStateException();
|
||||||
|
transaction.setCommitted();
|
||||||
|
db.commitTransaction(txn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endTransaction(Transaction transaction) {
|
||||||
try {
|
try {
|
||||||
T txn = txnClass.cast(transaction.unbox());
|
T txn = txnClass.cast(transaction.unbox());
|
||||||
if (transaction.isComplete()) db.commitTransaction(txn);
|
if (!transaction.isCommitted()) db.abortTransaction(txn);
|
||||||
else db.abortTransaction(txn);
|
|
||||||
} finally {
|
} finally {
|
||||||
if (transaction.isReadOnly()) lock.readLock().unlock();
|
if (transaction.isReadOnly()) lock.readLock().unlock();
|
||||||
else lock.writeLock().unlock();
|
else lock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
if (transaction.isComplete())
|
if (transaction.isCommitted())
|
||||||
for (Event e : transaction.getEvents()) eventBus.broadcast(e);
|
for (Event e : transaction.getEvents()) eventBus.broadcast(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private T unbox(Transaction transaction) {
|
private T unbox(Transaction transaction) {
|
||||||
if (transaction.isComplete()) throw new IllegalStateException();
|
if (transaction.isCommitted()) throw new IllegalStateException();
|
||||||
return txnClass.cast(transaction.unbox());
|
return txnClass.cast(transaction.unbox());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
|||||||
List<Feed> feeds = getFeeds(txn);
|
List<Feed> feeds = getFeeds(txn);
|
||||||
feeds.add(feed);
|
feeds.add(feed);
|
||||||
storeFeeds(txn, feeds);
|
storeFeeds(txn, feeds);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
|||||||
feeds.remove(feed);
|
feeds.remove(feed);
|
||||||
feeds.add(updatedFeed);
|
feeds.add(updatedFeed);
|
||||||
storeFeeds(txn, feeds);
|
storeFeeds(txn, feeds);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
|||||||
}
|
}
|
||||||
if (!found) throw new DbException();
|
if (!found) throw new DbException();
|
||||||
storeFeeds(txn, feeds);
|
storeFeeds(txn, feeds);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
feeds = getFeeds(txn);
|
feeds = getFeeds(txn);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener {
|
|||||||
if (entryTime > lastEntryTime) lastEntryTime = entryTime;
|
if (entryTime > lastEntryTime) lastEntryTime = entryTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.addGroup(txn, f.getGroup());
|
db.addGroup(txn, f.getGroup());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
|||||||
for (RemoveForumHook hook : removeHooks)
|
for (RemoveForumHook hook : removeHooks)
|
||||||
hook.removingForum(txn, f);
|
hook.removingForum(txn, f);
|
||||||
db.removeGroup(txn, f.getGroup());
|
db.removeGroup(txn, f.getGroup());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
|||||||
meta.put(MSG_KEY_READ, true);
|
meta.put(MSG_KEY_READ, true);
|
||||||
clientHelper.addLocalMessage(txn, p.getMessage(), meta, true);
|
clientHelper.addLocalMessage(txn, p.getMessage(), meta, true);
|
||||||
trackOutgoingMessage(txn, p.getMessage());
|
trackOutgoingMessage(txn, p.getMessage());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -176,7 +176,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
forum = getForum(txn, g);
|
forum = getForum(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
groups = db.getGroups(txn, CLIENT_ID);
|
groups = db.getGroups(txn, CLIENT_ID);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
|||||||
headers.add(getForumPostHeader(txn, entry.getKey(), meta,
|
headers.add(getForumPostHeader(txn, entry.getKey(), meta,
|
||||||
statuses));
|
statuses));
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return headers;
|
return headers;
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class IdentityManagerImpl implements IdentityManager {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
cachedAuthor = localAuthor;
|
cachedAuthor = localAuthor;
|
||||||
LOG.info("Local author registered");
|
LOG.info("Local author registered");
|
||||||
} finally {
|
} finally {
|
||||||
@@ -53,7 +53,7 @@ class IdentityManagerImpl implements IdentityManager {
|
|||||||
try {
|
try {
|
||||||
cachedAuthor = loadLocalAuthor(txn);
|
cachedAuthor = loadLocalAuthor(txn);
|
||||||
LOG.info("Local author loaded");
|
LOG.info("Local author loaded");
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
Group g2 = getContactGroup(c2);
|
Group g2 = getContactGroup(c2);
|
||||||
trackMessage(txn, g1.getId(), timestamp, true);
|
trackMessage(txn, g1.getId(), timestamp, true);
|
||||||
trackMessage(txn, g2.getId(), timestamp, true);
|
trackMessage(txn, g2.getId(), timestamp, true);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
|
|
||||||
introduceeManager.acceptIntroduction(txn, state, timestamp);
|
introduceeManager.acceptIntroduction(txn, state, timestamp);
|
||||||
trackMessage(txn, g.getId(), timestamp, true);
|
trackMessage(txn, g.getId(), timestamp, true);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
|
|
||||||
introduceeManager.declineIntroduction(txn, state, timestamp);
|
introduceeManager.declineIntroduction(txn, state, timestamp);
|
||||||
trackMessage(txn, g.getId(), timestamp, true);
|
trackMessage(txn, g.getId(), timestamp, true);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -458,7 +458,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class LifecycleManagerImpl implements LifecycleManager {
|
|||||||
+ " took " + duration + " ms");
|
+ " took " + duration + " ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class ConversationManagerImpl implements ConversationManager {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
contact = db.getContact(txn, contactId);
|
contact = db.getContact(txn, contactId);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ class ConversationManagerImpl implements ConversationManager {
|
|||||||
if (count.getLatestMsgTime() > latestTime)
|
if (count.getLatestMsgTime() > latestTime)
|
||||||
latestTime = count.getLatestMsgTime();
|
latestTime = count.getLatestMsgTime();
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
meta.put("read", true);
|
meta.put("read", true);
|
||||||
clientHelper.addLocalMessage(txn, m.getMessage(), meta, true);
|
clientHelper.addLocalMessage(txn, m.getMessage(), meta, true);
|
||||||
trackOutgoingMessage(txn, m.getMessage());
|
trackOutgoingMessage(txn, m.getMessage());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -157,7 +157,7 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
contact = db.getContact(txn, c);
|
contact = db.getContact(txn, c);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ class MessagingManagerImpl extends ConversationClientImpl
|
|||||||
g = getContactGroup(db.getContact(txn, c)).getId();
|
g = getContactGroup(db.getContact(txn, c)).getId();
|
||||||
metadata = clientHelper.getMessageMetadataAsDictionary(txn, g);
|
metadata = clientHelper.getMessageMetadataAsDictionary(txn, g);
|
||||||
statuses = db.getMessageStatus(txn, c, g);
|
statuses = db.getMessageStatus(txn, c, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
clientHelper.mergeGroupMetadata(txn, group.getId(), meta);
|
clientHelper.mergeGroupMetadata(txn, group.getId(), meta);
|
||||||
announceNewMember(txn, newMemberMsg);
|
announceNewMember(txn, newMemberMsg);
|
||||||
joinPrivateGroup(txn, joinMsg);
|
joinPrivateGroup(txn, joinMsg);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -145,7 +145,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
}
|
}
|
||||||
Group group = db.getGroup(txn, g);
|
Group group = db.getGroup(txn, g);
|
||||||
db.removeGroup(txn, group);
|
db.removeGroup(txn, group);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
previousMsgId = getPreviousMsgId(txn, g);
|
previousMsgId = getPreviousMsgId(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -216,7 +216,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
setPreviousMsgId(txn, m.getMessage().getGroupId(),
|
setPreviousMsgId(txn, m.getMessage().getGroupId(),
|
||||||
m.getMessage().getId());
|
m.getMessage().getId());
|
||||||
trackOutgoingMessage(txn, m.getMessage());
|
trackOutgoingMessage(txn, m.getMessage());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -242,7 +242,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
privateGroup = getPrivateGroup(txn, g);
|
privateGroup = getPrivateGroup(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
groups = db.getGroups(txn, getClientId());
|
groups = db.getGroups(txn, getClientId());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
headers.add(getGroupMessageHeader(txn, g, entry.getKey(), meta,
|
headers.add(getGroupMessageHeader(txn, g, entry.getKey(), meta,
|
||||||
statuses));
|
statuses));
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return headers;
|
return headers;
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
@@ -387,7 +387,7 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements
|
|||||||
}
|
}
|
||||||
members.add(new GroupMember(a, status, shared));
|
members.add(new GroupMember(a, status, shared));
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return members;
|
return members;
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
local = getLocalProperties(txn);
|
local = getLocalProperties(txn);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
latest.messageId);
|
latest.messageId);
|
||||||
p = parseProperties(message);
|
p = parseProperties(message);
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
remote.put(c.getId(), parseProperties(message));
|
remote.put(c.getId(), parseProperties(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
true, true);
|
true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class SettingsManagerImpl implements SettingsManager {
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
s = db.getSettings(txn, namespace);
|
s = db.getSettings(txn, namespace);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ class SettingsManagerImpl implements SettingsManager {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.mergeSettings(txn, s, namespace);
|
db.mergeSettings(txn, s, namespace);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
long time = update.toSend.get(0).getTime();
|
long time = update.toSend.get(0).getTime();
|
||||||
trackMessage(txn, localState.getGroupId(), time, true);
|
trackMessage(txn, localState.getGroupId(), time, true);
|
||||||
|
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException();
|
throw new DbException();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -317,7 +317,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
// find session state based on shareable
|
// find session state based on shareable
|
||||||
IS localState = getSessionStateForResponse(txn, f, c);
|
IS localState = getSessionStateForResponse(txn, f, c);
|
||||||
respondToInvitation(txn, localState, accept);
|
respondToInvitation(txn, localState, accept);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -333,7 +333,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
try {
|
try {
|
||||||
IS localState = (IS) getSessionState(txn, id, true);
|
IS localState = (IS) getSessionState(txn, id, true);
|
||||||
respondToInvitation(txn, localState, accept);
|
respondToInvitation(txn, localState, accept);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -427,7 +427,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
LOG.log(WARNING, e.toString(), e);
|
LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return list;
|
return list;
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
@@ -468,7 +468,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
new SharingInvitationItem(s, subscribed, newS);
|
new SharingInvitationItem(s, subscribed, newS);
|
||||||
invitations.add(invitation);
|
invitations.add(invitation);
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
return Collections.unmodifiableCollection(invitations);
|
return Collections.unmodifiableCollection(invitations);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
@@ -514,7 +514,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
subscribers = getSharedBy(txn, g);
|
subscribers = getSharedBy(txn, g);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -547,7 +547,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
if (listContains(txn, contactGroup, g, SHARED_BY_US))
|
if (listContains(txn, contactGroup, g, SHARED_BY_US))
|
||||||
shared.add(c);
|
shared.add(c);
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -563,7 +563,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
canBeShared = canBeShared(txn, g, c);
|
canBeShared = canBeShared(txn, g, c);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
a = db.generateAck(txn, contactId, MAX_MESSAGE_IDS);
|
a = db.generateAck(txn, contactId, MAX_MESSAGE_IDS);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
try {
|
try {
|
||||||
b = db.generateRequestedBatch(txn, contactId,
|
b = db.generateRequestedBatch(txn, contactId,
|
||||||
MAX_PACKET_PAYLOAD_LENGTH, maxLatency);
|
MAX_PACKET_PAYLOAD_LENGTH, maxLatency);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
try {
|
try {
|
||||||
o = db.generateOffer(txn, contactId, MAX_MESSAGE_IDS,
|
o = db.generateOffer(txn, contactId, MAX_MESSAGE_IDS,
|
||||||
maxLatency);
|
maxLatency);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
r = db.generateRequest(txn, contactId, MAX_MESSAGE_IDS);
|
r = db.generateRequest(txn, contactId, MAX_MESSAGE_IDS);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.receiveAck(txn, contactId, ack);
|
db.receiveAck(txn, contactId, ack);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.receiveMessage(txn, contactId, message);
|
db.receiveMessage(txn, contactId, message);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.receiveOffer(txn, contactId, offer);
|
db.receiveOffer(txn, contactId, offer);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.receiveRequest(txn, contactId, request);
|
db.receiveRequest(txn, contactId, request);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
a = db.generateAck(txn, contactId, MAX_MESSAGE_IDS);
|
a = db.generateAck(txn, contactId, MAX_MESSAGE_IDS);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
try {
|
try {
|
||||||
b = db.generateBatch(txn, contactId,
|
b = db.generateBatch(txn, contactId,
|
||||||
MAX_PACKET_PAYLOAD_LENGTH, maxLatency);
|
MAX_PACKET_PAYLOAD_LENGTH, maxLatency);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
unvalidated.addAll(db.getMessagesToValidate(txn, c));
|
unvalidated.addAll(db.getMessagesToValidate(txn, c));
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
byte[] raw = db.getRawMessage(txn, id);
|
byte[] raw = db.getRawMessage(txn, id);
|
||||||
m = parseMessage(id, raw);
|
m = parseMessage(id, raw);
|
||||||
g = db.getGroup(txn, m.getGroupId());
|
g = db.getGroup(txn, m.getGroupId());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
pending.addAll(db.getPendingMessages(txn, c));
|
pending.addAll(db.getPendingMessages(txn, c));
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -338,7 +338,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
db.setMessageState(txn, id, PENDING);
|
db.setMessageState(txn, id, PENDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -397,7 +397,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
toShare.addAll(db.getMessagesToShare(txn, c));
|
toShare.addAll(db.getMessagesToShare(txn, c));
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
MessageId id = toShare.poll();
|
MessageId id = toShare.poll();
|
||||||
db.setMessageShared(txn, id);
|
db.setMessageShared(txn, id);
|
||||||
toShare.addAll(db.getMessageDependencies(txn, id).keySet());
|
toShare.addAll(db.getMessageDependencies(txn, id).keySet());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -465,7 +465,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
invalidateMessage(txn, id);
|
invalidateMessage(txn, id);
|
||||||
invalidate.addAll(getDependentsToInvalidate(txn, id));
|
invalidate.addAll(getDependentsToInvalidate(txn, id));
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -520,7 +520,7 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
Transaction txn = db.startTransaction(true);
|
Transaction txn = db.startTransaction(true);
|
||||||
try {
|
try {
|
||||||
g = db.getGroup(txn, m.getGroupId());
|
g = db.getGroup(txn, m.getGroupId());
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
|||||||
managers.put(e.getKey(), m);
|
managers.put(e.getKey(), m);
|
||||||
m.start(txn);
|
m.start(txn);
|
||||||
}
|
}
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
ctx = m.getStreamContext(txn, c);
|
ctx = m.getStreamContext(txn, c);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
ctx = m.getStreamContext(txn, tag);
|
ctx = m.getStreamContext(txn, tag);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class TransportKeyManager {
|
|||||||
Transaction txn = db.startTransaction(false);
|
Transaction txn = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
rotateKeys(txn);
|
rotateKeys(txn);
|
||||||
txn.setComplete();
|
db.commitTransaction(txn);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,12 +198,12 @@ public class BlogManagerImplTest extends BriarTestCase {
|
|||||||
blog2.getAuthor().getId());
|
blog2.getAuthor().getId());
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
oneOf(db).removeGroup(txn, blog1.getGroup());
|
oneOf(db).removeGroup(txn, blog1.getGroup());
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
blogManager.removeBlog(blog1);
|
blogManager.removeBlog(blog1);
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -227,12 +227,12 @@ public class BlogManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(identityManager)
|
oneOf(identityManager)
|
||||||
.getAuthorStatus(txn, blog1.getAuthor().getId());
|
.getAuthorStatus(txn, blog1.getAuthor().getId());
|
||||||
will(returnValue(VERIFIED));
|
will(returnValue(VERIFIED));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
blogManager.addLocalPost(post);
|
blogManager.addLocalPost(post);
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
|
|
||||||
assertEquals(1, txn.getEvents().size());
|
assertEquals(1, txn.getEvents().size());
|
||||||
assertTrue(txn.getEvents().get(0) instanceof BlogPostAddedEvent);
|
assertTrue(txn.getEvents().get(0) instanceof BlogPostAddedEvent);
|
||||||
@@ -256,11 +256,11 @@ public class BlogManagerImplTest extends BriarTestCase {
|
|||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(identityManager).getLocalAuthor(txn);
|
oneOf(identityManager).getLocalAuthor(txn);
|
||||||
will(returnValue(blog1.getAuthor()));
|
will(returnValue(blog1.getAuthor()));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
assertFalse(blogManager.canBeRemoved(blog1.getId()));
|
assertFalse(blogManager.canBeRemoved(blog1.getId()));
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
|
|
||||||
// check that blogs of contacts can not be removed
|
// check that blogs of contacts can not be removed
|
||||||
final Transaction txn2 = new Transaction(null, true);
|
final Transaction txn2 = new Transaction(null, true);
|
||||||
@@ -271,11 +271,11 @@ public class BlogManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(contactManager).contactExists(txn2, blog1.getAuthor().getId(),
|
oneOf(contactManager).contactExists(txn2, blog1.getAuthor().getId(),
|
||||||
blog2.getAuthor().getId());
|
blog2.getAuthor().getId());
|
||||||
will(returnValue(true));
|
will(returnValue(true));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
}});
|
}});
|
||||||
assertFalse(blogManager.canBeRemoved(blog1.getId()));
|
assertFalse(blogManager.canBeRemoved(blog1.getId()));
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
|
|
||||||
// check that blogs can be removed if they don't belong to a contact
|
// check that blogs can be removed if they don't belong to a contact
|
||||||
final Transaction txn3 = new Transaction(null, true);
|
final Transaction txn3 = new Transaction(null, true);
|
||||||
@@ -286,11 +286,11 @@ public class BlogManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(contactManager).contactExists(txn3, blog1.getAuthor().getId(),
|
oneOf(contactManager).contactExists(txn3, blog1.getAuthor().getId(),
|
||||||
blog2.getAuthor().getId());
|
blog2.getAuthor().getId());
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
}});
|
}});
|
||||||
assertTrue(blogManager.canBeRemoved(blog1.getId()));
|
assertTrue(blogManager.canBeRemoved(blog1.getId()));
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn3.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkGetBlogExpectations(final Transaction txn,
|
private void checkGetBlogExpectations(final Transaction txn,
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
oneOf(metadataEncoder).encode(dictionary);
|
oneOf(metadataEncoder).encode(dictionary);
|
||||||
will(returnValue(metadata));
|
will(returnValue(metadata));
|
||||||
oneOf(db).addLocalMessage(txn, message, metadata, shared);
|
oneOf(db).addLocalMessage(txn, message, metadata, shared);
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -118,6 +119,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getRawMessage(txn, messageId);
|
oneOf(db).getRawMessage(txn, messageId);
|
||||||
will(returnValue(rawMessage));
|
will(returnValue(rawMessage));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -136,6 +138,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
will(returnValue(metadata));
|
will(returnValue(metadata));
|
||||||
oneOf(metadataParser).parse(metadata);
|
oneOf(metadataParser).parse(metadata);
|
||||||
will(returnValue(dictionary));
|
will(returnValue(dictionary));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -155,6 +158,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
will(returnValue(metadata));
|
will(returnValue(metadata));
|
||||||
oneOf(metadataParser).parse(metadata);
|
oneOf(metadataParser).parse(metadata);
|
||||||
will(returnValue(dictionary));
|
will(returnValue(dictionary));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -176,6 +180,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
will(returnValue(Collections.singletonMap(messageId, metadata)));
|
will(returnValue(Collections.singletonMap(messageId, metadata)));
|
||||||
oneOf(metadataParser).parse(metadata);
|
oneOf(metadataParser).parse(metadata);
|
||||||
will(returnValue(dictionary));
|
will(returnValue(dictionary));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -203,6 +208,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
will(returnValue(Collections.singletonMap(messageId, metadata)));
|
will(returnValue(Collections.singletonMap(messageId, metadata)));
|
||||||
oneOf(metadataParser).parse(metadata);
|
oneOf(metadataParser).parse(metadata);
|
||||||
will(returnValue(dictionary));
|
will(returnValue(dictionary));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -221,6 +227,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
oneOf(metadataEncoder).encode(dictionary);
|
oneOf(metadataEncoder).encode(dictionary);
|
||||||
will(returnValue(metadata));
|
will(returnValue(metadata));
|
||||||
oneOf(db).mergeGroupMetadata(txn, groupId, metadata);
|
oneOf(db).mergeGroupMetadata(txn, groupId, metadata);
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -238,6 +245,7 @@ public class ClientHelperImplTest extends BriarTestCase {
|
|||||||
oneOf(metadataEncoder).encode(dictionary);
|
oneOf(metadataEncoder).encode(dictionary);
|
||||||
will(returnValue(metadata));
|
will(returnValue(metadata));
|
||||||
oneOf(db).mergeMessageMetadata(txn, messageId, metadata);
|
oneOf(db).mergeMessageMetadata(txn, messageId, metadata);
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class ContactManagerImplTest extends BriarTestCase {
|
|||||||
.addContact(txn, contactId, master, timestamp, alice);
|
.addContact(txn, contactId, master, timestamp, alice);
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ public class ContactManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -94,6 +96,7 @@ public class ContactManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getContacts(txn);
|
oneOf(db).getContacts(txn);
|
||||||
will(returnValue(contacts));
|
will(returnValue(contacts));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -110,6 +113,7 @@ public class ContactManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(db).getContact(txn, contactId);
|
oneOf(db).getContact(txn, contactId);
|
||||||
will(returnValue(contact));
|
will(returnValue(contact));
|
||||||
oneOf(db).removeContact(txn, contactId);
|
oneOf(db).removeContact(txn, contactId);
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -136,6 +140,7 @@ public class ContactManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).containsContact(txn, remote.getId(), local);
|
oneOf(db).containsContact(txn, remote.getId(), local);
|
||||||
will(returnValue(true));
|
will(returnValue(true));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
db.removeGroup(transaction, group);
|
db.removeGroup(transaction, group);
|
||||||
db.removeContact(transaction, contactId);
|
db.removeContact(transaction, contactId);
|
||||||
db.removeLocalAuthor(transaction, localAuthorId);
|
db.removeLocalAuthor(transaction, localAuthorId);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
Transaction transaction = db.startTransaction(false);
|
Transaction transaction = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.addLocalMessage(transaction, message, metadata, true);
|
db.addLocalMessage(transaction, message, metadata, true);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -850,7 +850,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
assertEquals(contactId,
|
assertEquals(contactId,
|
||||||
db.addContact(transaction, author, localAuthorId, true,
|
db.addContact(transaction, author, localAuthorId, true,
|
||||||
true));
|
true));
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -925,7 +925,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
Ack a = db.generateAck(transaction, contactId, 123);
|
Ack a = db.generateAck(transaction, contactId, 123);
|
||||||
assertEquals(messagesToAck, a.getMessageIds());
|
assertEquals(messagesToAck, a.getMessageIds());
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -969,7 +969,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
assertEquals(messages, db.generateBatch(transaction, contactId,
|
assertEquals(messages, db.generateBatch(transaction, contactId,
|
||||||
size * 2, maxLatency));
|
size * 2, maxLatency));
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1006,7 +1006,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
Offer o = db.generateOffer(transaction, contactId, 123, maxLatency);
|
Offer o = db.generateOffer(transaction, contactId, 123, maxLatency);
|
||||||
assertEquals(ids, o.getMessageIds());
|
assertEquals(ids, o.getMessageIds());
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1040,7 +1040,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
Request r = db.generateRequest(transaction, contactId, 123);
|
Request r = db.generateRequest(transaction, contactId, 123);
|
||||||
assertEquals(ids, r.getMessageIds());
|
assertEquals(ids, r.getMessageIds());
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1085,7 +1085,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
assertEquals(messages, db.generateRequestedBatch(transaction,
|
assertEquals(messages, db.generateRequestedBatch(transaction,
|
||||||
contactId, size * 2, maxLatency));
|
contactId, size * 2, maxLatency));
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1118,7 +1118,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
Ack a = new Ack(Collections.singletonList(messageId));
|
Ack a = new Ack(Collections.singletonList(messageId));
|
||||||
db.receiveAck(transaction, contactId, a);
|
db.receiveAck(transaction, contactId, a);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1173,7 +1173,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
// Receive the message twice
|
// Receive the message twice
|
||||||
db.receiveMessage(transaction, contactId, message);
|
db.receiveMessage(transaction, contactId, message);
|
||||||
db.receiveMessage(transaction, contactId, message);
|
db.receiveMessage(transaction, contactId, message);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1210,7 +1210,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
Transaction transaction = db.startTransaction(false);
|
Transaction transaction = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.receiveMessage(transaction, contactId, message);
|
db.receiveMessage(transaction, contactId, message);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1240,7 +1240,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
Transaction transaction = db.startTransaction(false);
|
Transaction transaction = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.receiveMessage(transaction, contactId, message);
|
db.receiveMessage(transaction, contactId, message);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1294,7 +1294,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
Offer o = new Offer(Arrays.asList(messageId, messageId1,
|
Offer o = new Offer(Arrays.asList(messageId, messageId1,
|
||||||
messageId2, messageId3));
|
messageId2, messageId3));
|
||||||
db.receiveOffer(transaction, contactId, o);
|
db.receiveOffer(transaction, contactId, o);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1328,7 +1328,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
Request r = new Request(Collections.singletonList(messageId));
|
Request r = new Request(Collections.singletonList(messageId));
|
||||||
db.receiveRequest(transaction, contactId, r);
|
db.receiveRequest(transaction, contactId, r);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1368,7 +1368,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
Transaction transaction = db.startTransaction(false);
|
Transaction transaction = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.setVisibleToContact(transaction, contactId, groupId, true);
|
db.setVisibleToContact(transaction, contactId, groupId, true);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1401,7 +1401,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
Transaction transaction = db.startTransaction(false);
|
Transaction transaction = db.startTransaction(false);
|
||||||
try {
|
try {
|
||||||
db.setVisibleToContact(transaction, contactId, groupId, true);
|
db.setVisibleToContact(transaction, contactId, groupId, true);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1444,7 +1444,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
db.updateTransportKeys(transaction, keys);
|
db.updateTransportKeys(transaction, keys);
|
||||||
assertEquals(keys, db.getTransportKeys(transaction, transportId));
|
assertEquals(keys, db.getTransportKeys(transaction, transportId));
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1512,7 +1512,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
db.mergeSettings(transaction, update, "namespace");
|
db.mergeSettings(transaction, update, "namespace");
|
||||||
// Second merge should not broadcast an event
|
// Second merge should not broadcast an event
|
||||||
db.mergeSettings(transaction, update, "namespace");
|
db.mergeSettings(transaction, update, "namespace");
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
@@ -1711,7 +1711,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
db.addMessageDependencies(transaction, message, dependencies);
|
db.addMessageDependencies(transaction, message, dependencies);
|
||||||
db.getMessageDependencies(transaction, messageId);
|
db.getMessageDependencies(transaction, messageId);
|
||||||
db.getMessageDependents(transaction, messageId);
|
db.getMessageDependents(transaction, messageId);
|
||||||
transaction.setComplete();
|
db.commitTransaction(transaction);
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,8 +199,7 @@ public class IntroduceeManagerTest extends BriarTestCase {
|
|||||||
introduceeManager.incomingMessage(txn, state, msg);
|
introduceeManager.incomingMessage(txn, state, msg);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
assertFalse(txn.isCommitted());
|
||||||
assertFalse(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -234,8 +233,7 @@ public class IntroduceeManagerTest extends BriarTestCase {
|
|||||||
introduceeManager.incomingMessage(txn, state, msg);
|
introduceeManager.incomingMessage(txn, state, msg);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
assertFalse(txn.isCommitted());
|
||||||
assertFalse(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -297,7 +295,7 @@ public class IntroduceeManagerTest extends BriarTestCase {
|
|||||||
assertTrue(e.getCause() instanceof GeneralSecurityException);
|
assertTrue(e.getCause() instanceof GeneralSecurityException);
|
||||||
}
|
}
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertFalse(txn.isComplete());
|
assertFalse(txn.isCommitted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -448,6 +446,7 @@ public class IntroduceeManagerTest extends BriarTestCase {
|
|||||||
BdfDictionary result = introduceeManager.initialize(txn, groupId, msg);
|
BdfDictionary result = introduceeManager.initialize(txn, groupId, msg);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
assertFalse(txn.isCommitted());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,8 +179,7 @@ public class IntroducerManagerTest extends BriarTestCase {
|
|||||||
.makeIntroduction(txn, introducee1, introducee2, null, time);
|
.makeIntroduction(txn, introducee1, introducee2, null, time);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
assertFalse(txn.isCommitted());
|
||||||
assertFalse(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientId getClientId() {
|
private ClientId getClientId() {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertTrue;
|
|
||||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID_1;
|
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID_1;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID_2;
|
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID_2;
|
||||||
@@ -153,6 +152,7 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(clientHelper)
|
oneOf(clientHelper)
|
||||||
.mergeGroupMetadata(txn, introductionGroup2.getId(),
|
.mergeGroupMetadata(txn, introductionGroup2.getId(),
|
||||||
metadataAfter);
|
metadataAfter);
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -160,7 +160,6 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
.makeIntroduction(introducee1, introducee2, null, time);
|
.makeIntroduction(introducee1, introducee2, null, time);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -188,6 +187,7 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(clientHelper)
|
oneOf(clientHelper)
|
||||||
.mergeGroupMetadata(txn, introductionGroup1.getId(),
|
.mergeGroupMetadata(txn, introductionGroup1.getId(),
|
||||||
metadataAfter);
|
metadataAfter);
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -195,7 +195,6 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
.acceptIntroduction(introducee1.getId(), sessionId, time);
|
.acceptIntroduction(introducee1.getId(), sessionId, time);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -223,6 +222,7 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(clientHelper)
|
oneOf(clientHelper)
|
||||||
.mergeGroupMetadata(txn, introductionGroup1.getId(),
|
.mergeGroupMetadata(txn, introductionGroup1.getId(),
|
||||||
metadataAfter);
|
metadataAfter);
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -230,7 +230,6 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
.declineIntroduction(introducee1.getId(), sessionId, time);
|
.declineIntroduction(introducee1.getId(), sessionId, time);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -254,13 +253,13 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(db).getMessageStatus(txn, introducee1.getId(),
|
oneOf(db).getMessageStatus(txn, introducee1.getId(),
|
||||||
introductionGroup1.getId());
|
introductionGroup1.getId());
|
||||||
will(returnValue(statuses));
|
will(returnValue(statuses));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
introductionManager.getIntroductionMessages(introducee1.getId());
|
introductionManager.getIntroductionMessages(introducee1.getId());
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -295,7 +294,7 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
.incomingMessage(txn, message1, new BdfList(), msg);
|
.incomingMessage(txn, message1, new BdfList(), msg);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertFalse(txn.isComplete());
|
assertFalse(txn.isCommitted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -334,7 +333,7 @@ public class IntroductionManagerImplTest extends BriarTestCase {
|
|||||||
.incomingMessage(txn, message1, new BdfList(), msg);
|
.incomingMessage(txn, message1, new BdfList(), msg);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertFalse(txn.isComplete());
|
assertFalse(txn.isCommitted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import org.jmock.Expectations;
|
|||||||
import org.jmock.Mockery;
|
import org.jmock.Mockery;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertFalse;
|
|
||||||
import static org.briarproject.api.identity.AuthorConstants.MAX_SIGNATURE_LENGTH;
|
import static org.briarproject.api.identity.AuthorConstants.MAX_SIGNATURE_LENGTH;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID;
|
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.MAC;
|
import static org.briarproject.api.introduction.IntroductionConstants.MAC;
|
||||||
@@ -30,6 +29,7 @@ import static org.briarproject.api.introduction.IntroductionConstants.SESSION_ID
|
|||||||
import static org.briarproject.api.introduction.IntroductionConstants.SIGNATURE;
|
import static org.briarproject.api.introduction.IntroductionConstants.SIGNATURE;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.TYPE;
|
import static org.briarproject.api.introduction.IntroductionConstants.TYPE;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.TYPE_ACK;
|
import static org.briarproject.api.introduction.IntroductionConstants.TYPE_ACK;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
public class MessageSenderTest extends BriarTestCase {
|
public class MessageSenderTest extends BriarTestCase {
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ public class MessageSenderTest extends BriarTestCase {
|
|||||||
messageSender.sendMessage(txn, msg);
|
messageSender.sendMessage(txn, msg);
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
assertFalse(txn.isComplete());
|
assertFalse(txn.isCommitted());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
|||||||
will(returnValue(noAckTxn));
|
will(returnValue(noAckTxn));
|
||||||
oneOf(db).generateAck(noAckTxn, contactId, MAX_MESSAGE_IDS);
|
oneOf(db).generateAck(noAckTxn, contactId, MAX_MESSAGE_IDS);
|
||||||
will(returnValue(null));
|
will(returnValue(null));
|
||||||
|
oneOf(db).commitTransaction(noAckTxn);
|
||||||
oneOf(db).endTransaction(noAckTxn);
|
oneOf(db).endTransaction(noAckTxn);
|
||||||
// No messages to send
|
// No messages to send
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -64,6 +65,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
|||||||
oneOf(db).generateBatch(with(noMsgTxn), with(contactId),
|
oneOf(db).generateBatch(with(noMsgTxn), with(contactId),
|
||||||
with(any(int.class)), with(maxLatency));
|
with(any(int.class)), with(maxLatency));
|
||||||
will(returnValue(null));
|
will(returnValue(null));
|
||||||
|
oneOf(db).commitTransaction(noMsgTxn);
|
||||||
oneOf(db).endTransaction(noMsgTxn);
|
oneOf(db).endTransaction(noMsgTxn);
|
||||||
// Flush the output stream
|
// Flush the output stream
|
||||||
oneOf(packetWriter).flush();
|
oneOf(packetWriter).flush();
|
||||||
@@ -95,6 +97,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
|||||||
will(returnValue(ackTxn));
|
will(returnValue(ackTxn));
|
||||||
oneOf(db).generateAck(ackTxn, contactId, MAX_MESSAGE_IDS);
|
oneOf(db).generateAck(ackTxn, contactId, MAX_MESSAGE_IDS);
|
||||||
will(returnValue(ack));
|
will(returnValue(ack));
|
||||||
|
oneOf(db).commitTransaction(ackTxn);
|
||||||
oneOf(db).endTransaction(ackTxn);
|
oneOf(db).endTransaction(ackTxn);
|
||||||
oneOf(packetWriter).writeAck(ack);
|
oneOf(packetWriter).writeAck(ack);
|
||||||
// One message to send
|
// One message to send
|
||||||
@@ -103,6 +106,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
|||||||
oneOf(db).generateBatch(with(msgTxn), with(contactId),
|
oneOf(db).generateBatch(with(msgTxn), with(contactId),
|
||||||
with(any(int.class)), with(maxLatency));
|
with(any(int.class)), with(maxLatency));
|
||||||
will(returnValue(Arrays.asList(raw)));
|
will(returnValue(Arrays.asList(raw)));
|
||||||
|
oneOf(db).commitTransaction(msgTxn);
|
||||||
oneOf(db).endTransaction(msgTxn);
|
oneOf(db).endTransaction(msgTxn);
|
||||||
oneOf(packetWriter).writeMessage(raw);
|
oneOf(packetWriter).writeMessage(raw);
|
||||||
// No more acks
|
// No more acks
|
||||||
@@ -110,6 +114,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
|||||||
will(returnValue(noAckTxn));
|
will(returnValue(noAckTxn));
|
||||||
oneOf(db).generateAck(noAckTxn, contactId, MAX_MESSAGE_IDS);
|
oneOf(db).generateAck(noAckTxn, contactId, MAX_MESSAGE_IDS);
|
||||||
will(returnValue(null));
|
will(returnValue(null));
|
||||||
|
oneOf(db).commitTransaction(noAckTxn);
|
||||||
oneOf(db).endTransaction(noAckTxn);
|
oneOf(db).endTransaction(noAckTxn);
|
||||||
// No more messages
|
// No more messages
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -117,6 +122,7 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
|||||||
oneOf(db).generateBatch(with(noMsgTxn), with(contactId),
|
oneOf(db).generateBatch(with(noMsgTxn), with(contactId),
|
||||||
with(any(int.class)), with(maxLatency));
|
with(any(int.class)), with(maxLatency));
|
||||||
will(returnValue(null));
|
will(returnValue(null));
|
||||||
|
oneOf(db).commitTransaction(noMsgTxn);
|
||||||
oneOf(db).endTransaction(noMsgTxn);
|
oneOf(db).endTransaction(noMsgTxn);
|
||||||
// Flush the output stream
|
// Flush the output stream
|
||||||
oneOf(packetWriter).flush();
|
oneOf(packetWriter).flush();
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
|||||||
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
||||||
import static org.briarproject.api.sync.ValidationManager.State.PENDING;
|
import static org.briarproject.api.sync.ValidationManager.State.PENDING;
|
||||||
import static org.briarproject.api.sync.ValidationManager.State.UNKNOWN;
|
import static org.briarproject.api.sync.ValidationManager.State.UNKNOWN;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class ValidationManagerImplTest extends BriarTestCase {
|
public class ValidationManagerImplTest extends BriarTestCase {
|
||||||
|
|
||||||
@@ -91,6 +89,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getMessagesToValidate(txn, clientId);
|
oneOf(db).getMessagesToValidate(txn, clientId);
|
||||||
will(returnValue(Arrays.asList(messageId, messageId1)));
|
will(returnValue(Arrays.asList(messageId, messageId1)));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Load the first raw message and group
|
// Load the first raw message and group
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -99,6 +98,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(raw));
|
will(returnValue(raw));
|
||||||
oneOf(db).getGroup(txn1, groupId);
|
oneOf(db).getGroup(txn1, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Validate the first message: valid
|
// Validate the first message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -116,6 +116,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Get any pending dependents
|
// Get any pending dependents
|
||||||
oneOf(db).getMessageDependents(txn2, messageId);
|
oneOf(db).getMessageDependents(txn2, messageId);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Load the second raw message and group
|
// Load the second raw message and group
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -124,6 +125,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(raw));
|
will(returnValue(raw));
|
||||||
oneOf(db).getGroup(txn3, groupId);
|
oneOf(db).getGroup(txn3, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
// Validate the second message: invalid
|
// Validate the second message: invalid
|
||||||
oneOf(validator).validateMessage(message1, group);
|
oneOf(validator).validateMessage(message1, group);
|
||||||
@@ -139,18 +141,21 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Recursively invalidate any dependents
|
// Recursively invalidate any dependents
|
||||||
oneOf(db).getMessageDependents(txn4, messageId1);
|
oneOf(db).getMessageDependents(txn4, messageId1);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn4);
|
||||||
oneOf(db).endTransaction(txn4);
|
oneOf(db).endTransaction(txn4);
|
||||||
// Get pending messages to deliver
|
// Get pending messages to deliver
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn5));
|
will(returnValue(txn5));
|
||||||
oneOf(db).getPendingMessages(txn5, clientId);
|
oneOf(db).getPendingMessages(txn5, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn5);
|
||||||
oneOf(db).endTransaction(txn5);
|
oneOf(db).endTransaction(txn5);
|
||||||
// Get messages to share
|
// Get messages to share
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn6));
|
will(returnValue(txn6));
|
||||||
oneOf(db).getMessagesToShare(txn6, clientId);
|
oneOf(db).getMessagesToShare(txn6, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn6);
|
||||||
oneOf(db).endTransaction(txn6);
|
oneOf(db).endTransaction(txn6);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -161,14 +166,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.startService();
|
vm.startService();
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
assertTrue(txn3.isComplete());
|
|
||||||
assertTrue(txn4.isComplete());
|
|
||||||
assertTrue(txn5.isComplete());
|
|
||||||
assertTrue(txn6.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -192,12 +189,14 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getMessagesToValidate(txn, clientId);
|
oneOf(db).getMessagesToValidate(txn, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Get pending messages to deliver
|
// Get pending messages to deliver
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn1));
|
will(returnValue(txn1));
|
||||||
oneOf(db).getPendingMessages(txn1, clientId);
|
oneOf(db).getPendingMessages(txn1, clientId);
|
||||||
will(returnValue(Collections.singletonList(messageId)));
|
will(returnValue(Collections.singletonList(messageId)));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Check whether the message is ready to deliver
|
// Check whether the message is ready to deliver
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -222,6 +221,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Get any pending dependents
|
// Get any pending dependents
|
||||||
oneOf(db).getMessageDependents(txn2, messageId);
|
oneOf(db).getMessageDependents(txn2, messageId);
|
||||||
will(returnValue(Collections.singletonMap(messageId2, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId2, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Check whether the dependent is ready to deliver
|
// Check whether the dependent is ready to deliver
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -246,6 +246,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Get any pending dependents
|
// Get any pending dependents
|
||||||
oneOf(db).getMessageDependents(txn3, messageId2);
|
oneOf(db).getMessageDependents(txn3, messageId2);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
|
|
||||||
// Get messages to share
|
// Get messages to share
|
||||||
@@ -253,6 +254,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn4));
|
will(returnValue(txn4));
|
||||||
oneOf(db).getMessagesToShare(txn4, clientId);
|
oneOf(db).getMessagesToShare(txn4, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn4);
|
||||||
oneOf(db).endTransaction(txn4);
|
oneOf(db).endTransaction(txn4);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -263,12 +265,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.startService();
|
vm.startService();
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
assertTrue(txn3.isComplete());
|
|
||||||
assertTrue(txn4.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -292,12 +288,14 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getMessagesToValidate(txn, clientId);
|
oneOf(db).getMessagesToValidate(txn, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// No pending messages to deliver
|
// No pending messages to deliver
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn1));
|
will(returnValue(txn1));
|
||||||
oneOf(db).getPendingMessages(txn1, clientId);
|
oneOf(db).getPendingMessages(txn1, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
|
|
||||||
// Get messages to share
|
// Get messages to share
|
||||||
@@ -305,6 +303,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn2));
|
will(returnValue(txn2));
|
||||||
oneOf(db).getMessagesToShare(txn2, clientId);
|
oneOf(db).getMessagesToShare(txn2, clientId);
|
||||||
will(returnValue(Collections.singletonList(messageId)));
|
will(returnValue(Collections.singletonList(messageId)));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Share message and get dependencies
|
// Share message and get dependencies
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -312,6 +311,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(db).setMessageShared(txn3, messageId);
|
oneOf(db).setMessageShared(txn3, messageId);
|
||||||
oneOf(db).getMessageDependencies(txn3, messageId);
|
oneOf(db).getMessageDependencies(txn3, messageId);
|
||||||
will(returnValue(Collections.singletonMap(messageId2, DELIVERED)));
|
will(returnValue(Collections.singletonMap(messageId2, DELIVERED)));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
// Share dependency
|
// Share dependency
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -319,6 +319,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(db).setMessageShared(txn4, messageId2);
|
oneOf(db).setMessageShared(txn4, messageId2);
|
||||||
oneOf(db).getMessageDependencies(txn4, messageId2);
|
oneOf(db).getMessageDependencies(txn4, messageId2);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn4);
|
||||||
oneOf(db).endTransaction(txn4);
|
oneOf(db).endTransaction(txn4);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -329,12 +330,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.startService();
|
vm.startService();
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
assertTrue(txn3.isComplete());
|
|
||||||
assertTrue(txn4.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -355,6 +350,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -378,6 +374,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
// Share message
|
// Share message
|
||||||
oneOf(db).setMessageShared(txn1, messageId);
|
oneOf(db).setMessageShared(txn1, messageId);
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Share dependencies
|
// Share dependencies
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -385,6 +382,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(db).setMessageShared(txn2, messageId1);
|
oneOf(db).setMessageShared(txn2, messageId1);
|
||||||
oneOf(db).getMessageDependencies(txn2, messageId1);
|
oneOf(db).getMessageDependencies(txn2, messageId1);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -395,10 +393,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -423,12 +417,14 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getMessagesToValidate(txn, clientId);
|
oneOf(db).getMessagesToValidate(txn, clientId);
|
||||||
will(returnValue(Arrays.asList(messageId, messageId1)));
|
will(returnValue(Arrays.asList(messageId, messageId1)));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Load the first raw message - *gasp* it's gone!
|
// Load the first raw message - *gasp* it's gone!
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn1));
|
will(returnValue(txn1));
|
||||||
oneOf(db).getRawMessage(txn1, messageId);
|
oneOf(db).getRawMessage(txn1, messageId);
|
||||||
will(throwException(new NoSuchMessageException()));
|
will(throwException(new NoSuchMessageException()));
|
||||||
|
never(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Load the second raw message and group
|
// Load the second raw message and group
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -437,6 +433,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(raw));
|
will(returnValue(raw));
|
||||||
oneOf(db).getGroup(txn2, groupId);
|
oneOf(db).getGroup(txn2, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Validate the second message: invalid
|
// Validate the second message: invalid
|
||||||
oneOf(validator).validateMessage(message1, group);
|
oneOf(validator).validateMessage(message1, group);
|
||||||
@@ -452,18 +449,21 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Recursively invalidate dependents
|
// Recursively invalidate dependents
|
||||||
oneOf(db).getMessageDependents(txn3, messageId1);
|
oneOf(db).getMessageDependents(txn3, messageId1);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
// Get pending messages to deliver
|
// Get pending messages to deliver
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn4));
|
will(returnValue(txn4));
|
||||||
oneOf(db).getPendingMessages(txn4, clientId);
|
oneOf(db).getPendingMessages(txn4, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn4);
|
||||||
oneOf(db).endTransaction(txn4);
|
oneOf(db).endTransaction(txn4);
|
||||||
// Get messages to share
|
// Get messages to share
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn5));
|
will(returnValue(txn5));
|
||||||
oneOf(db).getMessagesToShare(txn5, clientId);
|
oneOf(db).getMessagesToShare(txn5, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn5);
|
||||||
oneOf(db).endTransaction(txn5);
|
oneOf(db).endTransaction(txn5);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -474,13 +474,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.startService();
|
vm.startService();
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertFalse(txn1.isComplete()); // Aborted due to NoSuchMessageException
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
assertTrue(txn3.isComplete());
|
|
||||||
assertTrue(txn4.isComplete());
|
|
||||||
assertTrue(txn5.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -505,6 +498,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getMessagesToValidate(txn, clientId);
|
oneOf(db).getMessagesToValidate(txn, clientId);
|
||||||
will(returnValue(Arrays.asList(messageId, messageId1)));
|
will(returnValue(Arrays.asList(messageId, messageId1)));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Load the first raw message
|
// Load the first raw message
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -514,6 +508,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Load the group - *gasp* it's gone!
|
// Load the group - *gasp* it's gone!
|
||||||
oneOf(db).getGroup(txn1, groupId);
|
oneOf(db).getGroup(txn1, groupId);
|
||||||
will(throwException(new NoSuchGroupException()));
|
will(throwException(new NoSuchGroupException()));
|
||||||
|
never(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Load the second raw message and group
|
// Load the second raw message and group
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -522,6 +517,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(raw));
|
will(returnValue(raw));
|
||||||
oneOf(db).getGroup(txn2, groupId);
|
oneOf(db).getGroup(txn2, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Validate the second message: invalid
|
// Validate the second message: invalid
|
||||||
oneOf(validator).validateMessage(message1, group);
|
oneOf(validator).validateMessage(message1, group);
|
||||||
@@ -537,18 +533,21 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Recursively invalidate dependents
|
// Recursively invalidate dependents
|
||||||
oneOf(db).getMessageDependents(txn3, messageId1);
|
oneOf(db).getMessageDependents(txn3, messageId1);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
// Get pending messages to deliver
|
// Get pending messages to deliver
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn4));
|
will(returnValue(txn4));
|
||||||
oneOf(db).getPendingMessages(txn4, clientId);
|
oneOf(db).getPendingMessages(txn4, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn4);
|
||||||
oneOf(db).endTransaction(txn4);
|
oneOf(db).endTransaction(txn4);
|
||||||
// Get messages to share
|
// Get messages to share
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn5));
|
will(returnValue(txn5));
|
||||||
oneOf(db).getMessagesToShare(txn5, clientId);
|
oneOf(db).getMessagesToShare(txn5, clientId);
|
||||||
will(returnValue(Collections.emptyList()));
|
will(returnValue(Collections.emptyList()));
|
||||||
|
oneOf(db).commitTransaction(txn5);
|
||||||
oneOf(db).endTransaction(txn5);
|
oneOf(db).endTransaction(txn5);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -559,13 +558,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.startService();
|
vm.startService();
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertFalse(txn1.isComplete()); // Aborted due to NoSuchGroupException
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
assertTrue(txn3.isComplete());
|
|
||||||
assertTrue(txn4.isComplete());
|
|
||||||
assertTrue(txn5.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -585,6 +577,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -602,6 +595,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Get any pending dependents
|
// Get any pending dependents
|
||||||
oneOf(db).getMessageDependents(txn1, messageId);
|
oneOf(db).getMessageDependents(txn1, messageId);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -612,9 +606,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -655,6 +646,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -668,6 +660,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(Collections.singletonMap(messageId1, UNKNOWN)));
|
will(returnValue(Collections.singletonMap(messageId1, UNKNOWN)));
|
||||||
oneOf(db).mergeMessageMetadata(txn1, messageId, metadata);
|
oneOf(db).mergeMessageMetadata(txn1, messageId, metadata);
|
||||||
oneOf(db).setMessageState(txn1, messageId, PENDING);
|
oneOf(db).setMessageState(txn1, messageId, PENDING);
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -678,9 +671,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -701,6 +691,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -722,6 +713,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Get any pending dependents
|
// Get any pending dependents
|
||||||
oneOf(db).getMessageDependents(txn1, messageId);
|
oneOf(db).getMessageDependents(txn1, messageId);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -732,9 +724,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -756,6 +745,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -777,6 +767,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Recursively invalidate dependents
|
// Recursively invalidate dependents
|
||||||
oneOf(db).getMessageDependents(txn1, messageId);
|
oneOf(db).getMessageDependents(txn1, messageId);
|
||||||
will(returnValue(Collections.singletonMap(messageId2, UNKNOWN)));
|
will(returnValue(Collections.singletonMap(messageId2, UNKNOWN)));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Invalidate dependent in a new transaction
|
// Invalidate dependent in a new transaction
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -788,6 +779,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
oneOf(db).deleteMessageMetadata(txn2, messageId2);
|
oneOf(db).deleteMessageMetadata(txn2, messageId2);
|
||||||
oneOf(db).getMessageDependents(txn2, messageId2);
|
oneOf(db).getMessageDependents(txn2, messageId2);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -798,10 +790,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -831,6 +819,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: invalid
|
// Validate the message: invalid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -846,6 +835,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// The message has two dependents: 1 and 2
|
// The message has two dependents: 1 and 2
|
||||||
oneOf(db).getMessageDependents(txn1, messageId);
|
oneOf(db).getMessageDependents(txn1, messageId);
|
||||||
will(returnValue(twoDependents));
|
will(returnValue(twoDependents));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Invalidate message 1
|
// Invalidate message 1
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -858,6 +848,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 1 has one dependent: 3
|
// Message 1 has one dependent: 3
|
||||||
oneOf(db).getMessageDependents(txn2, messageId1);
|
oneOf(db).getMessageDependents(txn2, messageId1);
|
||||||
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Invalidate message 2
|
// Invalidate message 2
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -870,6 +861,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 2 has one dependent: 3 (same dependent as 1)
|
// Message 2 has one dependent: 3 (same dependent as 1)
|
||||||
oneOf(db).getMessageDependents(txn3, messageId2);
|
oneOf(db).getMessageDependents(txn3, messageId2);
|
||||||
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
// Invalidate message 3 (via 1)
|
// Invalidate message 3 (via 1)
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -882,12 +874,14 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 3 has one dependent: 4
|
// Message 3 has one dependent: 4
|
||||||
oneOf(db).getMessageDependents(txn4, messageId3);
|
oneOf(db).getMessageDependents(txn4, messageId3);
|
||||||
will(returnValue(Collections.singletonMap(messageId4, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId4, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn4);
|
||||||
oneOf(db).endTransaction(txn4);
|
oneOf(db).endTransaction(txn4);
|
||||||
// Invalidate message 3 (again, via 2)
|
// Invalidate message 3 (again, via 2)
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
will(returnValue(txn5));
|
will(returnValue(txn5));
|
||||||
oneOf(db).getMessageState(txn5, messageId3);
|
oneOf(db).getMessageState(txn5, messageId3);
|
||||||
will(returnValue(INVALID)); // Already invalidated
|
will(returnValue(INVALID)); // Already invalidated
|
||||||
|
oneOf(db).commitTransaction(txn5);
|
||||||
oneOf(db).endTransaction(txn5);
|
oneOf(db).endTransaction(txn5);
|
||||||
// Invalidate message 4 (via 1 and 3)
|
// Invalidate message 4 (via 1 and 3)
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -900,6 +894,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 4 has no dependents
|
// Message 4 has no dependents
|
||||||
oneOf(db).getMessageDependents(txn6, messageId4);
|
oneOf(db).getMessageDependents(txn6, messageId4);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn6);
|
||||||
oneOf(db).endTransaction(txn6);
|
oneOf(db).endTransaction(txn6);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -910,10 +905,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -950,6 +941,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -967,6 +959,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// The message has two pending dependents: 1 and 2
|
// The message has two pending dependents: 1 and 2
|
||||||
oneOf(db).getMessageDependents(txn1, messageId);
|
oneOf(db).getMessageDependents(txn1, messageId);
|
||||||
will(returnValue(twoDependents));
|
will(returnValue(twoDependents));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Check whether message 1 is ready to be delivered
|
// Check whether message 1 is ready to be delivered
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -991,6 +984,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 1 has one pending dependent: 3
|
// Message 1 has one pending dependent: 3
|
||||||
oneOf(db).getMessageDependents(txn2, messageId1);
|
oneOf(db).getMessageDependents(txn2, messageId1);
|
||||||
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Check whether message 2 is ready to be delivered
|
// Check whether message 2 is ready to be delivered
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -1015,6 +1009,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 2 has one pending dependent: 3 (same dependent as 1)
|
// Message 2 has one pending dependent: 3 (same dependent as 1)
|
||||||
oneOf(db).getMessageDependents(txn3, messageId2);
|
oneOf(db).getMessageDependents(txn3, messageId2);
|
||||||
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId3, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
// Check whether message 3 is ready to be delivered (via 1)
|
// Check whether message 3 is ready to be delivered (via 1)
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -1038,12 +1033,14 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 3 has one pending dependent: 4
|
// Message 3 has one pending dependent: 4
|
||||||
oneOf(db).getMessageDependents(txn4, messageId3);
|
oneOf(db).getMessageDependents(txn4, messageId3);
|
||||||
will(returnValue(Collections.singletonMap(messageId4, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId4, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn4);
|
||||||
oneOf(db).endTransaction(txn4);
|
oneOf(db).endTransaction(txn4);
|
||||||
// Check whether message 3 is ready to be delivered (again, via 2)
|
// Check whether message 3 is ready to be delivered (again, via 2)
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
will(returnValue(txn5));
|
will(returnValue(txn5));
|
||||||
oneOf(db).getMessageState(txn5, messageId3);
|
oneOf(db).getMessageState(txn5, messageId3);
|
||||||
will(returnValue(DELIVERED)); // Already delivered
|
will(returnValue(DELIVERED)); // Already delivered
|
||||||
|
oneOf(db).commitTransaction(txn5);
|
||||||
oneOf(db).endTransaction(txn5);
|
oneOf(db).endTransaction(txn5);
|
||||||
// Check whether message 4 is ready to be delivered (via 1 and 3)
|
// Check whether message 4 is ready to be delivered (via 1 and 3)
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -1068,6 +1065,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Message 4 has no pending dependents
|
// Message 4 has no pending dependents
|
||||||
oneOf(db).getMessageDependents(txn6, messageId4);
|
oneOf(db).getMessageDependents(txn6, messageId4);
|
||||||
will(returnValue(Collections.emptyMap()));
|
will(returnValue(Collections.emptyMap()));
|
||||||
|
oneOf(db).commitTransaction(txn6);
|
||||||
oneOf(db).endTransaction(txn6);
|
oneOf(db).endTransaction(txn6);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -1078,14 +1076,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
assertTrue(txn3.isComplete());
|
|
||||||
assertTrue(txn4.isComplete());
|
|
||||||
assertTrue(txn5.isComplete());
|
|
||||||
assertTrue(txn6.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1109,6 +1099,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -1126,6 +1117,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
// Get any pending dependents
|
// Get any pending dependents
|
||||||
oneOf(db).getMessageDependents(txn1, messageId);
|
oneOf(db).getMessageDependents(txn1, messageId);
|
||||||
will(returnValue(Collections.singletonMap(messageId1, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId1, PENDING)));
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Check whether the pending dependent is ready to be delivered
|
// Check whether the pending dependent is ready to be delivered
|
||||||
oneOf(db).startTransaction(false);
|
oneOf(db).startTransaction(false);
|
||||||
@@ -1134,6 +1126,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(PENDING));
|
will(returnValue(PENDING));
|
||||||
oneOf(db).getMessageDependencies(txn2, messageId1);
|
oneOf(db).getMessageDependencies(txn2, messageId1);
|
||||||
will(returnValue(twoDependencies));
|
will(returnValue(twoDependencies));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -1144,10 +1137,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
assertTrue(txn2.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1172,6 +1161,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
oneOf(db).getGroup(txn, groupId);
|
oneOf(db).getGroup(txn, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn);
|
||||||
oneOf(db).endTransaction(txn);
|
oneOf(db).endTransaction(txn);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message, group);
|
oneOf(validator).validateMessage(message, group);
|
||||||
@@ -1185,12 +1175,14 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(Collections.singletonMap(messageId1, UNKNOWN)));
|
will(returnValue(Collections.singletonMap(messageId1, UNKNOWN)));
|
||||||
oneOf(db).mergeMessageMetadata(txn1, messageId, metadata);
|
oneOf(db).mergeMessageMetadata(txn1, messageId, metadata);
|
||||||
oneOf(db).setMessageState(txn1, messageId, PENDING);
|
oneOf(db).setMessageState(txn1, messageId, PENDING);
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
// Second message is coming in
|
// Second message is coming in
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
will(returnValue(txn2));
|
will(returnValue(txn2));
|
||||||
oneOf(db).getGroup(txn2, groupId);
|
oneOf(db).getGroup(txn2, groupId);
|
||||||
will(returnValue(group));
|
will(returnValue(group));
|
||||||
|
oneOf(db).commitTransaction(txn2);
|
||||||
oneOf(db).endTransaction(txn2);
|
oneOf(db).endTransaction(txn2);
|
||||||
// Validate the message: valid
|
// Validate the message: valid
|
||||||
oneOf(validator).validateMessage(message1, group);
|
oneOf(validator).validateMessage(message1, group);
|
||||||
@@ -1204,6 +1196,7 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
will(returnValue(Collections.singletonMap(messageId, PENDING)));
|
will(returnValue(Collections.singletonMap(messageId, PENDING)));
|
||||||
oneOf(db).mergeMessageMetadata(txn3, messageId1, metadata);
|
oneOf(db).mergeMessageMetadata(txn3, messageId1, metadata);
|
||||||
oneOf(db).setMessageState(txn3, messageId1, PENDING);
|
oneOf(db).setMessageState(txn3, messageId1, PENDING);
|
||||||
|
oneOf(db).commitTransaction(txn3);
|
||||||
oneOf(db).endTransaction(txn3);
|
oneOf(db).endTransaction(txn3);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -1215,9 +1208,6 @@ public class ValidationManagerImplTest extends BriarTestCase {
|
|||||||
vm.eventOccurred(new MessageAddedEvent(message1, contactId));
|
vm.eventOccurred(new MessageAddedEvent(message1, contactId));
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
|
|
||||||
assertTrue(txn.isComplete());
|
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import static org.briarproject.util.ByteUtils.MAX_32_BIT_UNSIGNED;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class TransportKeyManagerTest extends BriarTestCase {
|
public class TransportKeyManagerTest extends BriarTestCase {
|
||||||
|
|
||||||
@@ -453,13 +452,13 @@ public class TransportKeyManagerTest extends BriarTestCase {
|
|||||||
oneOf(scheduler).schedule(with(any(Runnable.class)),
|
oneOf(scheduler).schedule(with(any(Runnable.class)),
|
||||||
with(rotationPeriodLength), with(MILLISECONDS));
|
with(rotationPeriodLength), with(MILLISECONDS));
|
||||||
// Commit the key rotation transaction
|
// Commit the key rotation transaction
|
||||||
|
oneOf(db).commitTransaction(txn1);
|
||||||
oneOf(db).endTransaction(txn1);
|
oneOf(db).endTransaction(txn1);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
TransportKeyManager transportKeyManager = new TransportKeyManager(db,
|
TransportKeyManager transportKeyManager = new TransportKeyManager(db,
|
||||||
crypto, dbExecutor, scheduler, clock, transportId, maxLatency);
|
crypto, dbExecutor, scheduler, clock, transportId, maxLatency);
|
||||||
transportKeyManager.start(txn);
|
transportKeyManager.start(txn);
|
||||||
assertTrue(txn1.isComplete());
|
|
||||||
|
|
||||||
context.assertIsSatisfied();
|
context.assertIsSatisfied();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user