* Expectation: passes
*/
@Test
public void t30_cc_2Clients1Cache() throws Exception {
// 1: connect new client2 to top level (cascaded) SC
SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
client2.attach();
SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));
// 2: load data to cache (cid=700) by client1
SCMessage request = new SCMessage();
request.setData("cacheFor1Hour_managedData");
request.setCacheId("700");
request.setMessageInfo(TestConstants.cacheCmd);
sessionService1.execute(request);
// 3: start cache guardian1 for client1 - do nothing
SCSubscribeMessage subMsg = new SCSubscribeMessage();
subMsg.setMask(TestConstants.mask);
subMsg.setData("700");
subMsg.setSessionInfo(TestConstants.doNothingCmd);
guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);
// 4: start cache guardian1 for client2 - publish 3 large appendix
subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
client2.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk2);
// 5: verify callback of guardian1 retrieval - 3 appendix within 100sec
cacheGuardianCbk.waitForAppendMessage(3, 10);
// 6: verify callback of guardian1 retrieval - 3 appendix within 100sec
cacheGuardianCbk2.waitForAppendMessage(3, 10);
// 7: verify data is now in top level cache
Map<String, String> inspectResponse = guardianClient.inspectCache("700");
this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "700", "3",
"700/0/0=0&700/1/0=1&700/2/0=1&700/3/0=1&", TestConstants.cacheGuardian1);
// 8: stop cache guardian of client1
guardianClient.stopCacheGuardian();
// 9: verify data is still now in top level cache
inspectResponse = guardianClient.inspectCache("700");
this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "700", "3",
"700/0/0=0&700/1/0=1&700/2/0=1&700/3/0=1&", TestConstants.cacheGuardian1);
// 10: stop cache guardian of client2
client2.stopCacheGuardian();
// 11: verify data is now NOT in top level cache
inspectResponse = guardianClient.inspectCache("700");
this.checkCacheInspectString(inspectResponse, "notfound", SC_CACHE_ENTRY_STATE.LOADED, "", "", "");
}