| 1 9 package org.jboss.portal.test.core.tree; 10 11 import junit.framework.TestCase; 12 import org.jboss.portal.common.util.XML; 13 import org.jboss.portal.common.tree.Tree; 14 import org.jboss.portal.common.tree.Node; 15 import org.jboss.portal.core.impl.tree.TreeImpl; 16 import org.w3c.dom.Document ; 17 18 import java.net.URL ; 19 import java.util.Arrays ; 20 21 25 public class BuilderTestCase extends TestCase 26 { 27 28 public BuilderTestCase(String name) 29 { 30 super(name); 31 } 32 33 private Tree model; 34 35 protected void setUp() throws Exception  36 { 37 TreeImpl jbcm = new TreeImpl(); 38 jbcm.setCacheConfiguration("test/cache/local.xml"); 39 jbcm.create(); 40 jbcm.start(); 41 model = jbcm; 42 } 43 44 protected void tearDown() throws Exception  45 { 46 TreeImpl jbcm = (TreeImpl)model; 47 jbcm.stop(); 48 jbcm.destroy(); 49 } 50 51 public void testA() throws Exception  52 { 53 URL url = Thread.currentThread().getContextClassLoader().getResource("test/sample-model.xml"); 54 Document doc = XML.getDocumentBuilderFactory().newDocumentBuilder().parse(url.getFile()); 55 56 Node root = model.getRoot(); 57 58 Node node1 = root.getChild("node1"); 59 assertNotNull(node1); 60 assertEquals("value1", node1.getProperty("prop1")); 61 assertEquals(Arrays.asList(new Object []{"value2.1","value2.2","value2.3"}), node1.getProperty("prop2")); 62 63 Node node1_1 = node1.getChild("node1.1"); 64 assertNotNull(node1_1); 65 } 66 67 } 68 | Popular Tags |