Skip to content

Commit

Permalink
OF-2437: Introduce CachingPubsubPersistenceProviderTest
Browse files Browse the repository at this point in the history
These new unit tests verify behavior of CachingPubsubPersistenceProvider (which fails, as indicated by some of these test failing).

The tests introduced here cover three (of four) types of operations that are being scheduled by the implementation:
- Node creation/changing/removal
- Subscription creation/update/removal
- Affiliation creation/update/removal

This other type of operation still need to be added:
- publishing/removal of items
  • Loading branch information
guusdk committed Jan 23, 2025
1 parent 9ff9b79 commit ae98b05
Show file tree
Hide file tree
Showing 4 changed files with 1,964 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2020-2025 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,7 @@
*/
package org.jivesoftware.openfire.pubsub;

import com.google.common.annotations.VisibleForTesting;
import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.pep.PEPService;
import org.jivesoftware.openfire.pubsub.cluster.FlushTask;
Expand Down Expand Up @@ -69,20 +70,24 @@ public class CachingPubsubPersistenceProvider implements PubSubPersistenceProvid
/**
* Queue that holds the (wrapped) items that need to be added to the database.
*/
private Deque<PublishedItem> itemsToAdd = new ConcurrentLinkedDeque<>();
@VisibleForTesting
Deque<PublishedItem> itemsToAdd = new ConcurrentLinkedDeque<>();

/**
* Queue that holds the items that need to be deleted from the database.
*/
private Deque<PublishedItem> itemsToDelete = new ConcurrentLinkedDeque<>();
@VisibleForTesting
Deque<PublishedItem> itemsToDelete = new ConcurrentLinkedDeque<>();

/**
* Keeps reference to published items that haven't been persisted yet so they
* can be removed before being deleted.
*/
private final HashMap<PublishedItem.UniqueIdentifier, PublishedItem> itemsPending = new HashMap<>();
@VisibleForTesting
final HashMap<PublishedItem.UniqueIdentifier, PublishedItem> itemsPending = new HashMap<>();

private ConcurrentMap<Node.UniqueIdentifier, List<NodeOperation>> nodesToProcess = new ConcurrentHashMap<>();
@VisibleForTesting
final ConcurrentMap<Node.UniqueIdentifier, List<NodeOperation>> nodesToProcess = new ConcurrentHashMap<>();

/**
* Cache name for recently accessed published items.
Expand Down
Loading

0 comments on commit ae98b05

Please sign in to comment.