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()); }
/** * Set the persistent cache implementation * * @param cache */ public static void setPersistentCache(EntityCapsPersistentCache cache) { persistentCache = cache; }