use of org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache in project Smack by igniterealtime.
the class EntityCapsManagerTest method testSimpleDirectoryCache.
private static void testSimpleDirectoryCache(StringEncoder stringEncoder) throws IOException {
EntityCapsPersistentCache cache = new SimpleDirectoryPersistentCache(createTempDirectory());
EntityCapsManager.setPersistentCache(cache);
DiscoverInfo di = createComplexSamplePacket();
CapsVersionAndHash versionAndHash = EntityCapsManager.generateVerificationString(di, StringUtils.SHA1);
String nodeVer = di.getNode() + "#" + versionAndHash.version;
// Save the data in EntityCapsManager
EntityCapsManager.addDiscoverInfoByNode(nodeVer, di);
// Lose all the data
EntityCapsManager.clearMemoryCache();
DiscoverInfo restored_di = EntityCapsManager.getDiscoveryInfoByNodeVer(nodeVer);
assertNotNull(restored_di);
assertEquals(di.toXML().toString(), restored_di.toXML().toString());
}
Aggregations