public void testDuplicatePersistence() throws CacheLoaderException { cache.put(Fqn.fromElements("a", "b"), "k", "v"); assert "v".equals(cache.get(Fqn.fromElements("a", "b"), "k")); cache.stop(); cache.start(); cache.put(Fqn.fromElements("a", "b"), "k", "v"); assert "v".equals(cache.get(Fqn.fromElements("a", "b"), "k")); }
@Test public void testCacheManager() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.transaction().invocationBatching().enable(); EmbeddedCacheManager cm = new DefaultCacheManager(builder.build()); Cache<String, String> cache = cm.getCache(); TreeCacheFactory tcf = new TreeCacheFactory(); TreeCache<String, String> tree = tcf.createTreeCache(cache); Fqn leafFqn = Fqn.fromElements("branch", "leaf"); Node<String, String> leaf = tree.getRoot().addChild(leafFqn); leaf.put("fruit", "orange"); cm.stop(); }
public void testGetChildAPI() { Node<Object, Object> rootNode = cache.getRoot(); // creates a Node<Object, Object> with fqn /a/b/c Node childA = rootNode.addChild(A); childA.addChild(B).addChild(C); rootNode.getChild(A).put("key", "value"); rootNode.getChild(A).getChild(B).put("key", "value"); rootNode.getChild(A).getChild(B).getChild(C).put("key", "value"); assertEquals("value", rootNode.getChild(A).get("key")); assertEquals("value", rootNode.getChild(A).getChild(B).get("key")); assertEquals("value", rootNode.getChild(A).getChild(B).getChild(C).get("key")); assertNull(rootNode.getChild(Fqn.fromElements("nonexistent"))); }