Author: sergeyhalipov
Date: 2007-03-16 15:26:04 -0400 (Fri, 16 Mar 2007)
New Revision: 89
Added:
trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java
Log:
JUnit test for TreeNodeImpl class.
Added: trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java
(rev 0)
+++
trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java 2007-03-16
19:26:04 UTC (rev 89)
@@ -0,0 +1,93 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIViewRoot;
+
+import org.richfaces.component.html.HtmlTree;
+
+import junit.framework.TestCase;
+
+/**
+ * @author hans
+ *
+ */
+public class TreeNodeTest extends TestCase {
+
+ protected TreeNode node = null;
+ protected static final int TEST_CHILDREN_COUNT = 7;
+
+ /**
+ * @param arg0
+ */
+ public TreeNodeTest(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ node = new TreeNodeImpl();
+ }
+
+ public void testChildrenNew() {
+ assertFalse(node.getChildren().hasNext());
+ }
+
+ public void testChildrenCount() {
+ for (int i = 0; i < TEST_CHILDREN_COUNT; i++)
+ node.addChild(new Integer(i), new TreeNodeImpl());
+ Iterator it = node.getChildren();
+ int count = 0;
+ for (; it.hasNext(); it.next())
+ count++;
+ assertEquals(count, TEST_CHILDREN_COUNT);
+ }
+
+ public void testIsLeafNew() {
+ assertTrue(node.isLeaf());
+ }
+
+ public void testIsLeaf() {
+ node.addChild("first", new TreeNodeImpl());
+ assertFalse(node.isLeaf());
+ }
+
+ public void testParent() {
+ TreeNode child = new TreeNodeImpl();
+ node.addChild("first", child);
+ assertEquals(child.getParent(), node);
+ }
+
+ public void testGetChild() {
+ TreeNode firstNode = new TreeNodeImpl();
+ firstNode.setData("First Node");
+ TreeNode secondNode = new TreeNodeImpl();
+ secondNode.setData("Second Node");
+ node.addChild("first", firstNode);
+ node.addChild("second", secondNode);
+ node.addChild("third", new TreeNodeImpl());
+ assertTrue(node.getChild("second").getData().equals("Second
Node"));
+ }
+
+}
Show replies by date