public void testQueueHoldAndFlush() throws Exception
{
assert replQ != null;
// mock the RPCManager used in the cache
RPCManager mockRpcManager = EasyMock.createStrictMock(RPCManager.class);
injectRpcManager(mockRpcManager);
// expect basic cluster related calls
expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
replay(mockRpcManager);
// check that nothing on the RPCManager will be called until we hit the replication queue threshold.
for (int i = 0; i < COUNT - 1; i++) cache.put("/a/b/c/" + i, "k", "v");
assert replQ.elements.size() == COUNT - 1;
// verify that no calls have been made on the mockRpcManager
verify(mockRpcManager);
// reset the mock
reset(mockRpcManager);
// now try the last PUT which should result in the queue being flushed.
expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
expect(mockRpcManager.callRemoteMethods((List<Address>) anyObject(), (MethodCall) anyObject(), anyBoolean(), anyBoolean(), anyInt(), anyBoolean())).andReturn(Collections.emptyList()).once();
replay(mockRpcManager);
cache.put("/a/b/c/LAST", "k", "v");
assert replQ.elements.size() == 0;