Keep a linked list of the IDs of subscribed groups.

This commit is contained in:
akwizgran
2012-05-17 21:25:10 +02:00
parent 78e1513aae
commit 2f4b347cdf
3 changed files with 152 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
@@ -1882,6 +1883,29 @@ public class H2DatabaseTest extends BriarTestCase {
db.close();
}
@Test
public void testMultipleSubscriptionsAndUnsubscriptions() throws Exception {
// Create some groups
List<Group> groups = new ArrayList<Group>();
for(int i = 0; i < 100; i++) {
GroupId id = new GroupId(TestUtils.getRandomId());
groups.add(groupFactory.createGroup(id, "Group name", null));
}
Database<Connection> db = open(false);
Connection txn = db.startTransaction();
// Add the groups to the database
for(Group g : groups) db.addSubscription(txn, g);
// Remove the groups in a different order
Collections.shuffle(groups);
for(Group g : groups) db.removeSubscription(txn, g.getId());
db.commitTransaction(txn);
db.close();
}
@Test
public void testExceptionHandling() throws Exception {
Database<Connection> db = open(false);