This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: DefaultMutableTreeNode tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Tue, 07 Mar 2006 11:33:22 +0000
- Subject: FYI: DefaultMutableTreeNode tests
I committed this patch which updates a couple of existing tests and adds
many new tests for the methods in DefaultMutableTreeNode. A patch for
GNU Classpath to fix the failing tests is on the way.
2006-03-07 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/add.java
(test): Reworked and added ancestor tests,
* gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/clone.java:
New file,
* gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/constructors.java
(check): Removed,
(test): Split into three calls,
(testConstructor1): New method,
(testConstructor2): Likewise,
(testConstructor3): Likewise,
* gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getIndex.java:
New file,
*
gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getParent.java: New
file,
* gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/insert.java:
New file,
*
gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeAncestor.java:
New file,
*
gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeChild.java:
New file,
*
gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeDescendant.java:
New file,
* gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/remove.java:
New file,
*
gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/removeAllChildren.java:
New file,
*
gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/setAllowsChildren.java:
New file,
* gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/toString.java:
New file.
Regards,
Dave
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/add.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/add.java,v
retrieving revision 1.1
diff -u -r1.1 add.java
--- gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/add.java 30 Nov 2004 16:03:27 -0000 1.1
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/add.java 7 Mar 2006 10:58:51 -0000
@@ -1,6 +1,6 @@
// Tags: JDK1.2
-// Copyright (C) 2004 Michael Koch <konqueror@gmx.de>
+// Copyright (C) 2004, 2006, Michael Koch <konqueror@gmx.de>
// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -14,63 +14,90 @@
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA. */
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA.
package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
-import javax.swing.tree.*;
+import javax.swing.tree.DefaultMutableTreeNode;
public class add implements Testlet
{
public void test(TestHarness h)
{
- DefaultMutableTreeNode A, B, C;
+ h.checkPoint("(MutableTreeNode)");
+ DefaultMutableTreeNode a, b, c;
- A = new DefaultMutableTreeNode();
- B = new DefaultMutableTreeNode();
- C = new DefaultMutableTreeNode(null, false);
+ a = new DefaultMutableTreeNode();
+ b = new DefaultMutableTreeNode();
+ c = new DefaultMutableTreeNode(null, false);
+ // try adding null
boolean ok = false;
-
try
{
- A.add(null);
+ a.add(null);
}
catch (IllegalArgumentException e)
{
ok = true;
}
+ h.check(ok);
- h.check(ok, "accepts null");
-
+ // try adding to a node that doesn't allow children
ok = false;
-
try
{
- C.add(A);
+ c.add(a);
}
catch (IllegalStateException e)
{
ok = true;
}
+ h.check(ok);
- h.check(ok, "rejects additions");
-
- A.add(B);
- A.add(C);
+ a.add(b);
+ a.add(c);
- h.check(A.isNodeChild(B));
- h.check(A.isNodeChild(C));
- h.check(!B.isNodeChild(C));
+ h.check(a.isNodeChild(b));
+ h.check(b.getParent(), a);
+ h.check(a.isNodeChild(c));
+ h.check(c.getParent(), a);
+ h.check(!b.isNodeChild(c));
- B.add(C);
+ b.add(c);
- h.check(A.isNodeChild(B));
- h.check(!A.isNodeChild(C));
- h.check(B.isNodeChild(C));
+ h.check(a.isNodeChild(b));
+ h.check(!a.isNodeChild(c));
+ h.check(b.isNodeChild(c));
+
+ // can we add a node to itself? no because a node is considered its own
+ // ancestor
+ boolean pass = false;
+ try
+ {
+ a.add(a);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ h.check(pass);
+
+ // same goes for adding a as a child of c
+ pass = false;
+ try
+ {
+ b.add(a);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ h.check(pass);
+
}
}
\ No newline at end of file
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/clone.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/clone.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/clone.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/clone.java 7 Mar 2006 10:58:52 -0000
@@ -0,0 +1,51 @@
+/* clone.java -- Some checks for the clone() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class clone implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("clone()");
+ Integer i1 = new Integer(100);
+ Integer i2 = new Integer(200);
+ Integer i3 = new Integer(300);
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(i1);
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(i2);
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode(i3);
+ n1.add(n2);
+ n2.add(n3);
+ DefaultMutableTreeNode c = (DefaultMutableTreeNode) n2.clone();
+ harness.check(c.getUserObject() == i2);
+ harness.check(c.getChildCount(), 0);
+ harness.check(c.getDepth(), 0);
+ harness.check(c.getParent(), null);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/constructors.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/constructors.java,v
retrieving revision 1.1
diff -u -r1.1 constructors.java
--- gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/constructors.java 30 Nov 2004 16:03:27 -0000 1.1
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/constructors.java 7 Mar 2006 10:58:52 -0000
@@ -1,6 +1,6 @@
// Tags: JDK1.2
-// Copyright (C) 2004 Michael Koch <konqueror@gmx.de>
+// Copyright (C) 2004, 2006, Michael Koch <konqueror@gmx.de>
// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -14,36 +14,69 @@
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA. */
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA.
package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
-import javax.swing.tree.*;
+import javax.swing.tree.DefaultMutableTreeNode;
public class constructors implements Testlet
{
- private void check(TestHarness h, DefaultMutableTreeNode node,
- Object userObject, boolean allowsChildren)
+
+ public void test(TestHarness h)
{
- h.check(node.getUserObject(), userObject, "userObject");
- h.check(node.getAllowsChildren(), allowsChildren, "allowsChildren");
+ testConstructor1(h);
+ testConstructor2(h);
+ testConstructor3(h);
}
- public void test(TestHarness h)
+ public void testConstructor1(TestHarness harness)
+ {
+ harness.checkPoint("()");
+ DefaultMutableTreeNode n = new DefaultMutableTreeNode();
+ harness.check(n.getUserObject(), null);
+ harness.check(n.getAllowsChildren(), true);
+ harness.check(n.getLevel(), 0);
+ harness.check(n.getChildCount(), 0);
+ harness.check(n.children(), DefaultMutableTreeNode.EMPTY_ENUMERATION);
+ harness.check(n.getDepth(), 0);
+ }
+
+ public void testConstructor2(TestHarness harness)
{
- Object userObject = new Object();
-
- check(h, new DefaultMutableTreeNode(),
- null, true);
- check(h, new DefaultMutableTreeNode(userObject),
- userObject, true);
- check(h, new DefaultMutableTreeNode(userObject, true),
- userObject, true);
- check(h, new DefaultMutableTreeNode(userObject, false),
- userObject, false);
+ harness.checkPoint("(Object)");
+ DefaultMutableTreeNode n = new DefaultMutableTreeNode("ABC");
+ harness.check(n.getUserObject(), "ABC");
+ harness.check(n.getAllowsChildren(), true);
+ harness.check(n.getLevel(), 0);
+ harness.check(n.getChildCount(), 0);
+ harness.check(n.children(), DefaultMutableTreeNode.EMPTY_ENUMERATION);
+ harness.check(n.getDepth(), 0);
+
+ // try null argument
+ n = new DefaultMutableTreeNode(null);
+ harness.check(n.getUserObject(), null);
}
+
+ public void testConstructor3(TestHarness harness)
+ {
+ harness.checkPoint("(Object, boolean)");
+ DefaultMutableTreeNode n = new DefaultMutableTreeNode("ABC", false);
+ harness.check(n.getUserObject(), "ABC");
+ harness.check(n.getAllowsChildren(), false);
+ harness.check(n.getLevel(), 0);
+ harness.check(n.getChildCount(), 0);
+ harness.check(n.children(), DefaultMutableTreeNode.EMPTY_ENUMERATION);
+ harness.check(n.getDepth(), 0);
+
+ // try null argument
+ n = new DefaultMutableTreeNode(null, true);
+ harness.check(n.getUserObject(), null);
+ harness.check(n.getAllowsChildren(), true);
+ }
+
}
\ No newline at end of file
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getIndex.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getIndex.java 7 Mar 2006 10:58:52 -0000
@@ -0,0 +1,61 @@
+/* getIndex.java -- some checks for the getIndex() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class getIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("D");
+ DefaultMutableTreeNode n5 = new DefaultMutableTreeNode("E");
+ n1.add(n2);
+ n1.add(n3);
+ n1.add(n4);
+ harness.check(n1.getIndex(n2), 0);
+ harness.check(n1.getIndex(n3), 1);
+ harness.check(n1.getIndex(n4), 2);
+ harness.check(n1.getIndex(n5), -1);
+
+ // try null argument
+ boolean pass = false;
+ try
+ {
+ n1.getIndex(null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getParent.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getParent.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getParent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/getParent.java 7 Mar 2006 10:58:52 -0000
@@ -0,0 +1,46 @@
+/* getParent.java -- Some checks for the parent() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class getParent implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("()");
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ harness.check(n1.getParent(), null);
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ n1.add(n2);
+ harness.check(n2.getParent(), n1);
+ n2.setParent(null);
+ harness.check(n2.getParent(), null);
+ harness.check(n1.getChildCount(), 1);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/insert.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/insert.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/insert.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/insert.java 7 Mar 2006 10:58:52 -0000
@@ -0,0 +1,119 @@
+/* insert.java -- Some checks for the insert() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class insert implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("(MutableTreeNode, int)");
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("D");
+ n1.insert(n2, 0);
+ harness.check(n1.getChildAt(0), n2);
+ n1.insert(n3, 0);
+ harness.check(n1.getChildAt(0), n3);
+ harness.check(n1.getChildAt(1), n2);
+ n1.insert(n4, 2);
+ harness.check(n1.getChildAt(0), n3);
+ harness.check(n1.getChildAt(1), n2);
+ harness.check(n1.getChildAt(2), n4);
+
+ // null
+ boolean pass = false;
+ try
+ {
+ n1.insert(null, 0);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // negative
+ pass = false;
+ DefaultMutableTreeNode n5 = new DefaultMutableTreeNode("E");
+ try
+ {
+ n1.insert(n5, -1);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // count + 1
+ pass = false;
+ try
+ {
+ n1.insert(n5, 4);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // node that doesn't allow children
+ DefaultMutableTreeNode n6 = new DefaultMutableTreeNode("F", false);
+ DefaultMutableTreeNode n7 = new DefaultMutableTreeNode("G");
+ pass = false;
+ try
+ {
+ n6.insert(n7, 0);
+ }
+ catch (IllegalStateException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // node that is an ancestor
+ DefaultMutableTreeNode n8 = new DefaultMutableTreeNode("H");
+ DefaultMutableTreeNode n9 = new DefaultMutableTreeNode("I");
+ DefaultMutableTreeNode n10 = new DefaultMutableTreeNode("J");
+ n8.add(n9);
+ n9.add(n10);
+ pass = false;
+ try
+ {
+ n10.insert(n8, 0);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeAncestor.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeAncestor.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeAncestor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeAncestor.java 7 Mar 2006 10:58:52 -0000
@@ -0,0 +1,52 @@
+/* isNodeAncestor.java -- Some checks for the isNodeAncestor() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class isNodeAncestor implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("(MutableTreeNode)");
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ n1.add(n2);
+ n2.add(n3);
+ harness.check(n2.isNodeAncestor(n1), true);
+ harness.check(n2.isNodeAncestor(n2), true);
+ harness.check(n3.isNodeAncestor(n1), true);
+ harness.check(n3.isNodeAncestor(n2), true);
+ harness.check(n3.isNodeAncestor(n3), true);
+
+ harness.check(n1.isNodeAncestor(n2), false);
+ harness.check(n1.isNodeAncestor(n3), false);
+ harness.check(n1.isNodeAncestor(null), false);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeChild.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeChild.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeChild.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeChild.java 7 Mar 2006 10:58:52 -0000
@@ -0,0 +1,46 @@
+/* isNodeChild.java -- Some checks for the isNodeChild() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class isNodeChild implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("(MutableTreeNode)");
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ n1.add(n2);
+ harness.check(n1.isNodeChild(n2), true);
+ harness.check(n1.isNodeChild(n3), false);
+ harness.check(n1.isNodeChild(null), false);
+ harness.check(n1.isNodeChild(n1), false);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeDescendant.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeDescendant.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeDescendant.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/isNodeDescendant.java 7 Mar 2006 10:58:53 -0000
@@ -0,0 +1,53 @@
+/* isNodeDescendant.java -- some checks for the isNodeDescendant() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class isNodeDescendant implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("(MutableTreeNode)");
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ n1.add(n2);
+ n2.add(n3);
+ harness.check(n1.isNodeDescendant(n1), true);
+ harness.check(n1.isNodeDescendant(n2), true);
+ harness.check(n1.isNodeDescendant(n3), true);
+ harness.check(n1.isNodeDescendant(null), false);
+ harness.check(n2.isNodeDescendant(n1), false);
+ harness.check(n2.isNodeDescendant(n2), true);
+ harness.check(n2.isNodeDescendant(n3), true);
+ harness.check(n3.isNodeDescendant(n1), false);
+ harness.check(n3.isNodeDescendant(n2), false);
+ harness.check(n3.isNodeDescendant(n3), true);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/remove.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/remove.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/remove.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/remove.java 7 Mar 2006 10:58:53 -0000
@@ -0,0 +1,123 @@
+/* remove.java -- Some checks for the remove() methods in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class remove implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ test1(harness);
+ test2(harness);
+ }
+
+ public void test1(TestHarness harness)
+ {
+ harness.checkPoint("(int)");
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("D");
+ n1.add(n2);
+ n1.add(n3);
+ n1.add(n4);
+
+ // remove valid item
+ n1.remove(2);
+ harness.check(n1.getChildCount(), 2);
+ harness.check(n1.isNodeChild(n4), false);
+ harness.check(n4.getParent(), null);
+
+ // remove negative index
+ boolean pass = false;
+ try
+ {
+ n1.remove(-1);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // remove index = childCount
+ pass = false;
+ try
+ {
+ n1.remove(n1.getChildCount());
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+ public void test2(TestHarness harness)
+ {
+ harness.checkPoint("(MutableTreeNode)");
+
+ // remove known item
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("D");
+ n1.add(n2);
+ n1.add(n3);
+ n1.add(n4);
+ n1.remove(n4);
+ harness.check(n1.getChildCount(), 2);
+ harness.check(n1.isNodeChild(n4), false);
+ harness.check(n4.getParent(), null);
+
+ // remove unknown item
+ boolean pass = false;
+ try
+ {
+ n1.remove(new DefaultMutableTreeNode("Z"));
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // remove null
+ pass = false;
+ try
+ {
+ n1.remove(null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/removeAllChildren.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/removeAllChildren.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/removeAllChildren.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/removeAllChildren.java 7 Mar 2006 10:58:53 -0000
@@ -0,0 +1,50 @@
+/* removeAllChildren.java -- some checks for the removeAllChildren() method in
+ the DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class removeAllChildren implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ // calling when there are no children should do nothing
+ n1.removeAllChildren();
+ harness.check(n1.getChildCount(), 0);
+
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("C");
+ n1.add(n2);
+ n1.add(n3);
+ n1.removeAllChildren();
+ harness.check(n1.getChildCount(), 0);
+ harness.check(n2.getParent(), null);
+ harness.check(n3.getParent(), null);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/setAllowsChildren.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/setAllowsChildren.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/setAllowsChildren.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/setAllowsChildren.java 7 Mar 2006 10:58:53 -0000
@@ -0,0 +1,49 @@
+/* setAllowsChildren.java -- some checks for the setAllowsChildren() method in
+ the DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class setAllowsChildren implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("A");
+ n1.setAllowsChildren(false);
+ harness.check(n1.getAllowsChildren(), false);
+ n1.setAllowsChildren(true);
+ harness.check(n1.getAllowsChildren(), true);
+
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("B");
+ n1.add(n2);
+ n1.setAllowsChildren(false);
+ harness.check(n1.getAllowsChildren(), false);
+ harness.check(n1.getChildCount(), 0);
+ harness.check(n2.getParent(), null);
+ }
+}
Index: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/toString.java
===================================================================
RCS file: gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/toString.java
diff -N gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/toString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/tree/DefaultMutableTreeNode/toString.java 7 Mar 2006 10:58:53 -0000
@@ -0,0 +1,42 @@
+/* toString.java -- Some checks for the toString() method in the
+ DefaultMutableTreeNode class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.tree.DefaultMutableTreeNode;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class toString implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("()");
+ DefaultMutableTreeNode n0 = new DefaultMutableTreeNode(null);
+ harness.check(n0.toString(), null);
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(new Integer(100));
+ harness.check(n1.toString(), "100");
+ }
+}