--- /dev/null 2004-08-16 21:12:55.000000000 +0100 +++ ArrayModel.java 2004-08-19 01:34:49.000000000 +0100 @@ -0,0 +1,62 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes + +// 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, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +package gnu.testlet.javax.swing.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import javax.swing.SpinnerListModel; + +public class ArrayModel implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + Object[] array; + + /* Create array */ + array = new Object[]{"GNU", "Classpath"}; + /* Create model */ + model = new SpinnerListModel(array); + /* Check retrieval */ + harness.check(model.getList() != null, "Array model creation check"); + harness.check(model.getValue(), "GNU", "Array model current value check"); + harness.check(model.getNextValue(), "Classpath", "Array model next value check"); + harness.check(model.getValue(), "GNU", "Array model no change of current value after next check"); + harness.check(model.getPreviousValue(), null, "Array model previous value check"); + /* Value change check */ + array[0] = "GNU's Not UNIX"; + harness.check(model.getValue(), "GNU's Not UNIX", "Array model backing list change check"); + /* Value setting check */ + model.setValue("Classpath"); + harness.check(model.getValue(), "Classpath", "Array model successful set check"); + try + { + model.setValue("Sun"); + harness.fail("Exception not thrown for non-existant value with array model."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + } +} --- /dev/null 2004-08-16 21:12:55.000000000 +0100 +++ Constructors.java 2004-08-19 01:34:49.000000000 +0100 @@ -0,0 +1,73 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes + +// 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, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +package gnu.testlet.javax.swing.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import javax.swing.SpinnerListModel; + +public class Constructors implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + + /* Invalid values */ + try + { + model = new SpinnerListModel((Object[]) null); + harness.fail("Null array supplied to constructor failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + try + { + model = new SpinnerListModel(new ArrayList()); + harness.fail("Empty list supplied to constructor failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + try + { + model = new SpinnerListModel(new Object[]{}); + harness.fail("Empty array supplied to constructor failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + + /* Test the default model */ + model = new SpinnerListModel(); + harness.check(model.getList() != null, "Default list construction check."); + harness.check(model.getValue(), "empty", "Default list current value check."); + harness.check(model.getNextValue(), null, "Default list next value check."); + harness.check(model.getPreviousValue(), null, "Default list previous value check."); + + } +} --- /dev/null 2004-08-16 21:12:55.000000000 +0100 +++ ListModel.java 2004-08-19 01:34:49.000000000 +0100 @@ -0,0 +1,66 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes + +// 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, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +package gnu.testlet.javax.swing.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import java.util.List; +import javax.swing.SpinnerListModel; + +public class ListModel implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + List list; + + /* Create list */ + list = new ArrayList(); + list.add("GNU"); + list.add("Classpath"); + /* Create model */ + model = new SpinnerListModel(list); + /* Check retrieval */ + harness.check(model.getList() != null, "List model creation check"); + harness.check(model.getValue(), "GNU", "List model current value check"); + harness.check(model.getNextValue(), "Classpath", "List model next value check"); + harness.check(model.getValue(), "GNU", "List model no change of current value after next check"); + harness.check(model.getPreviousValue(), null, "List model previous value check"); + /* Value change check */ + list.set(0, "GNU's Not UNIX"); + harness.check(model.getValue(), "GNU's Not UNIX", "List model backing list change check"); + /* Value setting check */ + model.setValue("Classpath"); + harness.check(model.getValue(), "Classpath", "List model successful set check"); + try + { + model.setValue("Sun"); + harness.fail("Exception not thrown for non-existant value with list model."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + } +} --- /dev/null 2004-08-16 21:12:55.000000000 +0100 +++ Ordering.java 2004-08-19 01:34:49.000000000 +0100 @@ -0,0 +1,58 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes + +// 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, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +package gnu.testlet.javax.swing.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import java.util.List; +import javax.swing.SpinnerListModel; + +public class Ordering implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + List list; + + /* Create list */ + list = new ArrayList(); + list.add("a"); + list.add("z"); + list.add("a"); + list.add("b"); + /* Create model */ + model = new SpinnerListModel(list); + /* Check retrieval */ + harness.check(model.getList() != null, "Array model ordering creation check"); + harness.check(model.getValue(), "a", "Array model ordering current value check"); + harness.check(model.getNextValue(), "z", "Array model ordering next value check"); + harness.check(model.getValue(), "a", "Array model ordering no change of current value after next check"); + harness.check(model.getPreviousValue(), null, "Array model ordering previous value check"); + /* Value ordering of setting check */ + model.setValue("a"); + harness.check(model.getValue(), "a", "Array model ordering successful set check"); + harness.check(model.getPreviousValue(), null, "Array model ordering post-set previous value check"); + harness.check(model.getNextValue(), "z", "Array model ordering post-set next value check"); + } +} --- /dev/null 2004-08-16 21:12:55.000000000 +0100 +++ SetList.java 2004-08-19 01:34:49.000000000 +0100 @@ -0,0 +1,67 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes + +// 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, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +package gnu.testlet.javax.swing.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import java.util.List; +import javax.swing.SpinnerListModel; + +public class SetList implements Testlet +{ + +public void test(TestHarness harness) +{ + SpinnerListModel model; + List list; + + /* Create default model */ + model = new SpinnerListModel(); + /* Invalid values */ + try + { + model.setList((ArrayList) null); + harness.fail("Null list supplied to setList failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + try + { + model.setList(new ArrayList()); + harness.fail("Empty list supplied to setList failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + + /* Test a successful change */ + list = new ArrayList(); + list.add("GNU"); + model.setList(list); + harness.check(model.getList(), list, "Model allowed successful change of list."); + } + +} --- /dev/null 2004-08-16 21:12:55.000000000 +0100 +++ SpinnerListModelTest.java 2004-08-19 01:34:49.000000000 +0100 @@ -0,0 +1,98 @@ +import java.util.ArrayList; +import java.util.List; +import javax.swing.SpinnerListModel; + +public class SpinnerListModelTest +{ + public static void main(String[] args) + { + SpinnerListModel model; + List list; + Object[] array; + + /* Quick constructor tests */ + try + { + model = new SpinnerListModel((Object[]) null); + } + catch (IllegalArgumentException exception) + { + System.out.println("Null correctly threw exception."); + } + try + { + model = new SpinnerListModel(new ArrayList()); + } + catch (IllegalArgumentException exception) + { + System.out.println("Zero elements correctly threw exception."); + } + try + { + model = new SpinnerListModel(new Object[]{}); + } + catch (IllegalArgumentException exception) + { + System.out.println("Zero elements correctly threw exception."); + } + + /* Test the default model */ + model = new SpinnerListModel(); + System.out.println("Model created with list " + model.getList() + "."); + System.out.println("Current value should be 'empty', is " + model.getValue() + "."); + System.out.println("Next value should be null, is " + model.getNextValue() + "."); + System.out.println("Previous value should be null, is " + model.getPreviousValue() + "."); + + /* Test with a list */ + list = new ArrayList(); + list.add("GNU"); + list.add("Classpath"); + model = new SpinnerListModel(list); + System.out.println("Model created with list " + model.getList() + "."); + System.out.println("Current value should be 'GNU', is " + model.getValue() + "."); + System.out.println("Next value should be 'Classpath', is " + model.getNextValue() + "."); + System.out.println("Current value should be 'GNU', is " + model.getValue() + "."); + System.out.println("Previous value should be null, is " + model.getPreviousValue() + "."); + /* Change a value */ + list.set(0, "GNU's Not UNIX"); + System.out.println("Current value should be 'GNU's Not UNIX', is " + model.getValue() + "."); + /* Move to 'Classpath' */ + model.setValue("Classpath"); + System.out.println("Current value should be 'Classpath', is " + model.getValue() + ","); + /* Check exception throwing */ + try + { + model.setValue("Sun"); + System.out.println("Exception not thrown for non-existant value."); + } + catch (IllegalArgumentException exception) + { + System.out.println("Value 'Sun' correctly threw exception."); + } + /* Test with a array */ + array = new Object[]{"GNU", "Classpath"}; + model = new SpinnerListModel(array); + System.out.println("Model created with list " + model.getList() + "."); + System.out.println("Current value should be 'GNU', is " + model.getValue() + "."); + System.out.println("Next value should be 'Classpath', is " + model.getNextValue() + "."); + System.out.println("Current value should be 'GNU', is " + model.getValue() + "."); + System.out.println("Previous value should be null, is " + model.getPreviousValue() + "."); + /* Change a value */ + array[0] = "GNU's Not UNIX"; + System.out.println("Current value should be 'GNU's Not UNIX', is " + model.getValue() + "."); + /* Move to 'Classpath' */ + model.setValue("Classpath"); + System.out.println("Current value should be 'Classpath', is " + model.getValue() + ","); + /* Check exception throwing */ + try + { + model.setValue("Sun"); + System.out.println("Exception not thrown for non-existant value."); + } + catch (IllegalArgumentException exception) + { + System.out.println("Value 'Sun' correctly threw exception."); + } + + } +}