1 package org.jboss.cache; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 import junit.framework.TestSuite; 6 7 13 public class TreeNodeTest extends TestCase 14 { 15 CacheImpl cache; 16 17 protected void setUp() throws Exception 18 { 19 super.setUp(); 20 cache = new CacheImpl(); 21 startCache(cache); 22 } 23 24 protected void tearDown() throws Exception 25 { 26 super.tearDown(); 27 stopCache(cache); 28 } 29 30 public void testChildExist() throws Exception 31 { 32 Object key = 1; 33 cache.put("/a/b/c", key, "test"); 34 Node node; 35 node = cache.get("/a/b"); 36 assertFalse(node.getChildren().isEmpty()); 37 assertTrue(node.getChild(new Fqn("c")) != null); 38 39 Fqn fqn = Fqn.fromString("/e/f"); 40 cache.put(fqn, "1", "1"); 41 node = cache.get("/e"); 42 assertFalse(node.getChildren().isEmpty()); 43 assertTrue(node.getChild(new Fqn("f")) != null); 44 45 } 46 47 86 87 void startCache(CacheImpl c) throws Exception 88 { 89 c.create(); 90 c.start(); 91 } 92 93 void stopCache(CacheImpl c) 94 { 95 c.stop(); 96 c.destroy(); 97 } 98 99 public static Test suite() 100 { 101 return new TestSuite(TreeNodeTest.class); 102 } 103 104 public static void main(String [] args) 105 { 106 junit.textui.TestRunner.run(suite()); 107 } 108 109 } 110 | Popular Tags |