1 17 18 19 20 package org.apache.lenya.cms.publication; 21 22 import junit.framework.TestCase; 23 24 public class SiteTreeNodeImplTest extends TestCase { 25 26 private SiteTreeNode node = null; 27 28 32 public SiteTreeNodeImplTest(String test) { 33 super(test); 34 } 35 36 42 public static void main(String [] args) { 43 junit.textui.TestRunner.run(SiteTreeNodeImplTest.class); 44 } 45 46 49 protected void setUp() throws Exception { 50 super.setUp(); 51 DefaultSiteTree siteTree = new DefaultSiteTree("testTree"); 52 Label label = new Label("Foo", "en"); 53 Label[] fooLabels = { label }; 54 siteTree.addNode("/foo", fooLabels, true, null, null, false); 55 label = new Label("Bar", "en"); 56 Label label_de = new Label("Stab", "de"); 57 Label[] barLabels = { label, label_de }; 58 siteTree.addNode( 59 "/foo/bar", 60 barLabels, 61 true, 62 "http://exact.biz", 63 "suffix", 64 true); 65 66 node = siteTree.getNode("/foo/bar"); 67 } 68 69 72 protected void tearDown() throws Exception { 73 super.tearDown(); 74 } 75 76 80 final public void testGetParentId() { 81 assertEquals(node.getParentId(), "foo"); 82 } 83 84 88 final public void testGetAbsoluteId() { 89 assertEquals(node.getAbsoluteId(), "/foo/bar"); 90 } 91 92 96 final public void testGetId() { 97 assertEquals(node.getId(), "bar"); 98 } 99 100 104 final public void testGetLabels() { 105 assertEquals(node.getLabels().length, 2); 106 for (int i = 0; i < node.getLabels().length; i++) { 107 Label label = node.getLabels()[i]; 108 Label label1 = new Label("Bar", "en"); 109 Label label2 = new Label("Stab", "de"); 110 assertTrue(label.equals(label1) || label.equals(label2)); 111 } 112 } 113 114 118 final public void testGetLabel() { 119 Label label = node.getLabel("en"); 120 assertNotNull(label); 121 assertEquals(label.getLabel(), "Bar"); 122 } 123 124 128 final public void testAddLabel() { 129 Label label = new Label("Barolo", "it"); 130 node.addLabel(label); 131 label = node.getLabel("it"); 132 assertNotNull(label); 133 assertEquals(label.getLabel(), "Barolo"); 134 label = node.getLabel("ch"); 135 assertNull(label); 136 } 137 138 142 final public void testRemoveLabel() { 143 Label label = new Label("Bar", "en"); 144 assertNotNull(node.getLabel("en")); 145 node.removeLabel(label); 146 assertNull(node.getLabel("en")); 147 } 148 149 153 final public void testGetHref() { 154 assertEquals(node.getHref(), "http://exact.biz"); 155 } 156 157 162 final public void testGetSuffix() { 163 assertEquals(node.getSuffix(), "suffix"); 164 } 165 166 170 final public void testHasLink() { 171 assertTrue(node.hasLink()); 172 } 173 174 } 175 | Popular Tags |