Search in sources :

Example 1 with EntityCapsPersistentCache

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());
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) EntityCapsPersistentCache(org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache) SimpleDirectoryPersistentCache(org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache)

Aggregations

EntityCapsPersistentCache (org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache)1 SimpleDirectoryPersistentCache (org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache)1 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)1