KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > core > tree > BuilderTestCase


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

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 JavaDoc;
17
18 import java.net.URL JavaDoc;
19 import java.util.Arrays JavaDoc;
20
21 /**
22  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
23  * @version $Revision: 1.1 $
24  */

25 public class BuilderTestCase extends TestCase
26 {
27
28    public BuilderTestCase(String JavaDoc name)
29    {
30       super(name);
31    }
32
33    private Tree model;
34
35    protected void setUp() throws Exception JavaDoc
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 JavaDoc
45    {
46       TreeImpl jbcm = (TreeImpl)model;
47       jbcm.stop();
48       jbcm.destroy();
49    }
50
51    public void testA() throws Exception JavaDoc
52    {
53       URL JavaDoc url = Thread.currentThread().getContextClassLoader().getResource("test/sample-model.xml");
54       Document JavaDoc 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 JavaDoc[]{"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