Java 类org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache 实例源码

项目:Smack    文件:EntityCapsManagerTest.java   
private 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());
    }
项目:Smack    文件:EntityCapsManager.java   
/**
 * Set the persistent cache implementation
 * 
 * @param cache
 */
public static void setPersistentCache(EntityCapsPersistentCache cache) {
    persistentCache = cache;
}