This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: SpinnerNumberModel/SpinnerDateModel new tests


I added these new tests:

2006-02-08 David Gilbert <david.gilbert@object-refinery.com>

* gnu/testlet/javax/swing/SpinnerDateModel/constructors.java: New file,
* gnu/testlet/javax/swing/SpinnerDateModel/getNextValue.java: Likewise,
* gnu/testlet/javax/swing/SpinnerDateModel/getPreviousValue.java: Likewise,
* gnu/testlet/javax/swing/SpinnerDateModel/setEnd.java: Likewise,
* gnu/testlet/javax/swing/SpinnerDateModel/setStart.java: Likewise,
* gnu/testlet/javax/swing/SpinnerDateModel/setValue.java: Likewise,
* gnu/testlet/javax/swing/SpinnerNumberModel/constructors.java: Likewise,
* gnu/testlet/javax/swing/SpinnerNumberModel/getNextValue.java: Likewise,
* gnu/testlet/javax/swing/SpinnerNumberModel/getPreviousValue.java: Likewise,
* gnu/testlet/javax/swing/SpinnerNumberModel/setMaximum.java: Likewise,
* gnu/testlet/javax/swing/SpinnerNumberModel/setMinimum.java: Likewise,
* gnu/testlet/javax/swing/SpinnerNumberModel/setStepSize.java: Likewise,
* gnu/testlet/javax/swing/SpinnerNumberModel/setValue.java: Likewise.


There are some failures with GNU Classpath CVS, I have a patch to fix those that I'll submit soon.

Regards,

Dave
Index: gnu/testlet/javax/swing/SpinnerDateModel/constructors.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerDateModel/constructors.java
diff -N gnu/testlet/javax/swing/SpinnerDateModel/constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerDateModel/constructors.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,191 @@
+/* constructors.java -- some checks for the constructors in the 
+                        SpinnerDateModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerDateModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.swing.SpinnerDateModel;
+
+/**
+ * Some tests for the constructors in the {@link SpinnerDateModel} class.
+ */
+public class constructors implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    testConstructor1(harness);
+    testConstructor2(harness);
+  }
+
+  private void testConstructor1(TestHarness harness) 
+  {
+    harness.checkPoint("()");
+    Date before = new Date();
+    SpinnerDateModel m = new SpinnerDateModel();
+    Date after = new Date();
+    Date date = (Date) m.getValue();
+    harness.check(date.getTime() >= before.getTime());
+    harness.check(date.getTime() <= after.getTime());
+    harness.check(m.getStart(), null);
+    harness.check(m.getEnd(), null);
+    harness.check(m.getCalendarField(), Calendar.DAY_OF_MONTH);
+  }
+
+  private void testConstructor2(TestHarness harness)  
+  {
+    harness.checkPoint("(Date, Comparable, Comparable, int)");
+    Date now = new Date();
+    Date start = new Date(now.getTime() - 1L);
+    Date end = new Date(now.getTime() + 1L);
+    Date preStart = new Date(now.getTime() - 2L);
+    Date postEnd = new Date(now.getTime() + 2L);
+    SpinnerDateModel m = new SpinnerDateModel(now, start, end, Calendar.YEAR);
+    harness.check(m.getValue(), now);
+    harness.check(m.getStart(), start);
+    harness.check(m.getEnd(), end);
+    harness.check(m.getCalendarField(), Calendar.YEAR);
+    
+    // value equal to start 
+    m = new SpinnerDateModel(start, start, end, Calendar.YEAR);
+    harness.check(m.getValue(), start);
+    harness.check(m.getStart(), start);
+    harness.check(m.getEnd(), end);
+    harness.check(m.getCalendarField(), Calendar.YEAR);
+
+    // value before start
+    boolean pass = false;
+    try
+    {
+      m = new SpinnerDateModel(preStart, start, end, Calendar.YEAR);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // value equal to end
+    m = new SpinnerDateModel(end, start, end, Calendar.YEAR);
+    harness.check(m.getValue(), end);
+    harness.check(m.getStart(), start);
+    harness.check(m.getEnd(), end);
+    harness.check(m.getCalendarField(), Calendar.YEAR);
+    
+    // value above maximum
+    pass = false;
+    try
+    {
+      m = new SpinnerDateModel(postEnd, start, end, Calendar.YEAR);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // check null value
+    pass = false;
+    try
+    {
+      m = new SpinnerDateModel(null, start, end, Calendar.YEAR);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // check valid calendar fields
+    m = new SpinnerDateModel(now, start, end, Calendar.ERA);
+    harness.check(m.getCalendarField(), Calendar.ERA);
+    m = new SpinnerDateModel(now, start, end, Calendar.YEAR);
+    harness.check(m.getCalendarField(), Calendar.YEAR);
+    m = new SpinnerDateModel(now, start, end, Calendar.MONTH);
+    harness.check(m.getCalendarField(), Calendar.MONTH);
+    m = new SpinnerDateModel(now, start, end, Calendar.WEEK_OF_YEAR);
+    harness.check(m.getCalendarField(), Calendar.WEEK_OF_YEAR);
+    m = new SpinnerDateModel(now, start, end, Calendar.WEEK_OF_MONTH);
+    harness.check(m.getCalendarField(), Calendar.WEEK_OF_MONTH);
+    m = new SpinnerDateModel(now, start, end, Calendar.DAY_OF_MONTH);
+    harness.check(m.getCalendarField(), Calendar.DAY_OF_MONTH);
+    m = new SpinnerDateModel(now, start, end, Calendar.DAY_OF_YEAR);
+    harness.check(m.getCalendarField(), Calendar.DAY_OF_YEAR);
+    m = new SpinnerDateModel(now, start, end, Calendar.DAY_OF_WEEK);
+    harness.check(m.getCalendarField(), Calendar.DAY_OF_WEEK);
+    m = new SpinnerDateModel(now, start, end, Calendar.DAY_OF_WEEK_IN_MONTH);
+    harness.check(m.getCalendarField(), Calendar.DAY_OF_WEEK_IN_MONTH);
+    m = new SpinnerDateModel(now, start, end, Calendar.AM_PM);
+    harness.check(m.getCalendarField(), Calendar.AM_PM);
+    m = new SpinnerDateModel(now, start, end, Calendar.HOUR);
+    harness.check(m.getCalendarField(), Calendar.HOUR);
+    m = new SpinnerDateModel(now, start, end, Calendar.HOUR_OF_DAY);
+    harness.check(m.getCalendarField(), Calendar.HOUR_OF_DAY);
+    m = new SpinnerDateModel(now, start, end, Calendar.MINUTE);
+    harness.check(m.getCalendarField(), Calendar.MINUTE);
+    m = new SpinnerDateModel(now, start, end, Calendar.SECOND);
+    harness.check(m.getCalendarField(), Calendar.SECOND);
+    m = new SpinnerDateModel(now, start, end, Calendar.MILLISECOND);
+    harness.check(m.getCalendarField(), Calendar.MILLISECOND);
+    m = new SpinnerDateModel(now, start, end, Calendar.DATE);
+    harness.check(m.getCalendarField(), Calendar.DATE);
+    
+    // check invalid calendar fields
+
+    pass = false;
+    try
+    {
+      m = new SpinnerDateModel(now, start, end, Calendar.DST_OFFSET);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+
+    pass = false;
+    try
+    {
+      m = new SpinnerDateModel(now, start, end, Calendar.ZONE_OFFSET);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  
+  }
+
+}
Index: gnu/testlet/javax/swing/SpinnerDateModel/getNextValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerDateModel/getNextValue.java
diff -N gnu/testlet/javax/swing/SpinnerDateModel/getNextValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerDateModel/getNextValue.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,56 @@
+/* getNextValue.java -- some checks for the getNextValue() method in the
+                        SpinnerDateModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerDateModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.swing.SpinnerDateModel;
+
+public class getNextValue implements Testlet {
+
+  public void test(TestHarness harness) 
+  {
+    Date now = new Date();
+    Date next = new Date(now.getTime() + 1L);  
+    Date start = new Date(now.getTime() - 2L);
+    Date end = new Date(now.getTime() + 2L);
+      
+    SpinnerDateModel m = new SpinnerDateModel(now, start, end, 
+              Calendar.MILLISECOND);
+    harness.check(m.getValue(), now);
+    harness.check(m.getNextValue(), next);
+    
+    // accessing the next value doesn't update the current value
+    harness.check(m.getValue(), now);
+    m.setValue(next);
+    harness.check(m.getNextValue(), end);
+    m.setValue(end);
+    harness.check(m.getNextValue(), null);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerDateModel/getPreviousValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerDateModel/getPreviousValue.java
diff -N gnu/testlet/javax/swing/SpinnerDateModel/getPreviousValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerDateModel/getPreviousValue.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,56 @@
+/* getPreviousValue.java -- some checks for the getPreviousValue() method in 
+                            the SpinnerDateModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerDateModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.swing.SpinnerDateModel;
+
+public class getPreviousValue implements Testlet {
+
+  public void test(TestHarness harness) 
+  {
+    Date now = new Date();
+    Date prev = new Date(now.getTime() - 1L);  
+    Date start = new Date(now.getTime() - 2L);
+    Date end = new Date(now.getTime() + 2L);
+      
+    SpinnerDateModel m = new SpinnerDateModel(now, start, end, 
+              Calendar.MILLISECOND);
+    harness.check(m.getValue(), now);
+    harness.check(m.getPreviousValue(), prev);
+    
+    // accessing the previous value doesn't update the current value
+    harness.check(m.getValue(), now);
+    m.setValue(prev);
+    harness.check(m.getPreviousValue(), start);
+    m.setValue(start);
+    harness.check(m.getPreviousValue(), null);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerDateModel/setEnd.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerDateModel/setEnd.java
diff -N gnu/testlet/javax/swing/SpinnerDateModel/setEnd.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerDateModel/setEnd.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,81 @@
+/* setEnd.java -- some checks for the setEnd() method in the
+                  SpinnerDateModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerDateModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.swing.SpinnerDateModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setEnd implements Testlet, ChangeListener {
+  
+  private ChangeEvent event;
+  
+  public void stateChanged(ChangeEvent e)
+  {
+    this.event = e;    
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    Date now = new Date();
+    Date start = new Date(now.getTime() - 1L);
+    Date preStart = new Date(now.getTime() - 2L);
+    Date end1 = new Date(now.getTime() + 1L);
+    Date end2 = new Date(now.getTime() + 2L);
+    
+    SpinnerDateModel m = new SpinnerDateModel(now, start, end1, 
+            Calendar.DAY_OF_MONTH);
+    m.addChangeListener(this);
+    m.setEnd(end2);
+    harness.check(m.getEnd(), end2);
+    harness.check(this.event.getSource(), m);
+    
+    // same value triggers no event
+    this.event = null;
+    m.setEnd(end2);
+    harness.check(this.event == null);
+    
+    // set null end
+    this.event = null;
+    m.setEnd(null);
+    harness.check(m.getEnd(), null);
+    harness.check(this.event.getSource(), m);
+
+    // same null value triggers no event
+    this.event = null;
+    m.setEnd(null);
+    harness.check(this.event == null);
+    
+    // set end earlier than start
+    m.setEnd(preStart);
+    harness.check(m.getEnd(), preStart);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerDateModel/setStart.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerDateModel/setStart.java
diff -N gnu/testlet/javax/swing/SpinnerDateModel/setStart.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerDateModel/setStart.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,81 @@
+/* setStart.java -- some checks for the setStart() method in the
+                    SpinnerDateModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerDateModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.swing.SpinnerDateModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setStart implements Testlet, ChangeListener {
+  
+  private ChangeEvent event;
+  
+  public void stateChanged(ChangeEvent e)
+  {
+    this.event = e;    
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    Date now = new Date();
+    Date start1 = new Date(now.getTime() - 1L);
+    Date start2 = new Date(now.getTime() - 2L);
+    Date end = new Date(now.getTime() + 1L);
+    Date postEnd = new Date(now.getTime() + 2L);
+    
+    SpinnerDateModel m = new SpinnerDateModel(now, start1, end, 
+            Calendar.DAY_OF_MONTH);
+    m.addChangeListener(this);
+    m.setStart(start2);
+    harness.check(m.getStart(), start2);
+    harness.check(this.event.getSource(), m);
+    
+    // same value triggers no event
+    this.event = null;
+    m.setStart(start2);
+    harness.check(this.event == null);
+    
+    // set null start
+    this.event = null;
+    m.setStart(null);
+    harness.check(m.getStart(), null);
+    harness.check(this.event.getSource(), m);
+
+    // same null value triggers no event
+    this.event = null;
+    m.setStart(null);
+    harness.check(this.event == null);
+    
+    // set start higher than end
+    m.setStart(postEnd);
+    harness.check(m.getStart(), postEnd);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerDateModel/setValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerDateModel/setValue.java
diff -N gnu/testlet/javax/swing/SpinnerDateModel/setValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerDateModel/setValue.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,98 @@
+/* setValue.java -- some checks for the setValue() method in the
+                    SpinnerDateModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerDateModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.swing.SpinnerDateModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setValue implements Testlet, ChangeListener {
+  
+  private ChangeEvent event;
+  
+  public void stateChanged(ChangeEvent e)
+  {
+    this.event = e;    
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    Date now = new Date();
+    Date v1 = new Date(now.getTime() - 1L);
+    Date start = new Date(now.getTime() - 2L);
+    Date preStart = new Date(now.getTime() - 3L);
+    Date end = new Date(now.getTime() + 2L);
+    Date postEnd = new Date(now.getTime() + 3L);
+    SpinnerDateModel m = new SpinnerDateModel(now, start, end, 
+            Calendar.MILLISECOND);
+    m.addChangeListener(this);
+    m.setValue(v1);
+    harness.check(m.getValue(), v1);
+    harness.check(this.event.getSource(), m);
+    
+    // same value triggers no event
+    this.event = null;
+    m.setValue(v1);
+    harness.check(this.event == null);
+    
+    // set value less than start
+    m.setValue(preStart);        
+    harness.check(m.getValue(), preStart);
+
+    // set value greater than maximum
+    m.setValue(postEnd);        
+    harness.check(m.getValue(), postEnd);
+  
+    // set null value
+    boolean pass = false;
+    try
+    {
+      m.setValue(null);        
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // set a non-date value
+    pass = false;
+    try
+    {
+      m.setValue("123");        
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerNumberModel/constructors.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerNumberModel/constructors.java
diff -N gnu/testlet/javax/swing/SpinnerNumberModel/constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerNumberModel/constructors.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,288 @@
+/* constructors.java -- some checks for the constructors in the 
+                        SpinnerNumberModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerNumberModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SpinnerNumberModel;
+
+/**
+ * Some tests for the constructors in the {@link SpinnerNumberModel} class.
+ */
+public class constructors implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    testConstructor1(harness);
+    testConstructor2(harness);
+    testConstructor3(harness);
+    testConstructor4(harness);
+  }
+
+  private void testConstructor1(TestHarness harness) 
+  {
+    harness.checkPoint("()");
+    SpinnerNumberModel m = new SpinnerNumberModel();
+    harness.check(m.getValue(), new Integer(0));
+    harness.check(m.getMinimum(), null);
+    harness.check(m.getMaximum(), null);
+    harness.check(m.getStepSize(), new Integer(1));
+  }
+
+  private void testConstructor2(TestHarness harness)  
+  {
+    harness.checkPoint("(double, double, double, double)");
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    harness.check(m.getValue(), new Double(2.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(0.5));
+    
+    // value equal to minimum 
+    m = new SpinnerNumberModel(1.0, 1.0, 3.0, 0.5);
+    harness.check(m.getValue(), new Double(1.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(0.5));
+
+    // value below minimum
+    boolean pass = false;
+    try
+    {
+      m = new SpinnerNumberModel(0.9, 1.0, 3.0, 0.5);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // value equal to maximum
+    m = new SpinnerNumberModel(3.0, 1.0, 3.0, 0.5);
+    harness.check(m.getValue(), new Double(3.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(0.5));
+    
+    // value above maximum
+    pass = false;
+    try
+    {
+      m = new SpinnerNumberModel(3.1, 1.0, 3.0, 0.5);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // step size 0
+    m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.0);
+    harness.check(m.getValue(), new Double(2.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(0.0));
+    
+    // step size negative
+    m = new SpinnerNumberModel(2.0, 1.0, 3.0, -0.5);
+    harness.check(m.getValue(), new Double(2.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(-0.5));
+    
+  }
+  
+  private void testConstructor3(TestHarness harness) 
+  {
+    harness.checkPoint("(int, int, int, int)"); 
+    SpinnerNumberModel m = new SpinnerNumberModel(20, 10, 30, 5);
+    harness.check(m.getValue(), new Integer(20));
+    harness.check(m.getMinimum(), new Integer(10));
+    harness.check(m.getMaximum(), new Integer(30));
+    harness.check(m.getStepSize(), new Integer(5));
+
+    // value equal to minimum 
+    m = new SpinnerNumberModel(10, 10, 30, 5);
+    harness.check(m.getValue(), new Integer(10));
+    harness.check(m.getMinimum(), new Integer(10));
+    harness.check(m.getMaximum(), new Integer(30));
+    harness.check(m.getStepSize(), new Integer(5));
+
+    // value below minimum
+    boolean pass = false;
+    try
+    {
+      m = new SpinnerNumberModel(9, 10, 30, 5);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // value equal to maximum
+    m = new SpinnerNumberModel(30, 10, 30, 5);
+    harness.check(m.getValue(), new Integer(30));
+    harness.check(m.getMinimum(), new Integer(10));
+    harness.check(m.getMaximum(), new Integer(30));
+    harness.check(m.getStepSize(), new Integer(5));
+    
+    // value above maximum
+    pass = false;
+    try
+    {
+      m = new SpinnerNumberModel(31, 10, 30, 5);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // step size 0
+    m = new SpinnerNumberModel(20, 10, 30, 0);
+    harness.check(m.getValue(), new Integer(20));
+    harness.check(m.getMinimum(), new Integer(10));
+    harness.check(m.getMaximum(), new Integer(30));
+    harness.check(m.getStepSize(), new Integer(0));
+    
+    // step size negative
+    m = new SpinnerNumberModel(20, 10, 30, -5);
+    harness.check(m.getValue(), new Integer(20));
+    harness.check(m.getMinimum(), new Integer(10));
+    harness.check(m.getMaximum(), new Integer(30));
+    harness.check(m.getStepSize(), new Integer(-5));
+
+  }
+  
+  private void testConstructor4(TestHarness harness)  
+  {
+    harness.checkPoint("Number, Comparable, Comparable, Number");
+    SpinnerNumberModel m = new SpinnerNumberModel(new Long(20), new Long(10), 
+            new Long(30), new Long(5));
+    harness.check(m.getValue(), new Long(20));
+    harness.check(m.getMinimum(), new Long(10));
+    harness.check(m.getMaximum(), new Long(30));
+    harness.check(m.getStepSize(), new Long(5));
+    
+    // value equal to minimum 
+    m = new SpinnerNumberModel(new Double(1.0), new Double(1.0), 
+            new Double(3.0), new Double(0.5));
+    harness.check(m.getValue(), new Double(1.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(0.5));
+
+    // value below minimum
+    boolean pass = false;
+    try
+    {
+      m = new SpinnerNumberModel(new Double(0.9), new Double(1.0), 
+              new Double(3.0), new Double(0.5));
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // value equal to maximum
+    m = new SpinnerNumberModel(new Double(3.0), new Double(1.0), 
+            new Double(3.0), new Double(0.5));
+    harness.check(m.getValue(), new Double(3.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(0.5));
+    
+    // value above maximum
+    pass = false;
+    try
+    {
+      m = new SpinnerNumberModel(new Double(3.1), new Double(1.0), 
+              new Double(3.0), new Double(0.5));
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // step size 0
+    m = new SpinnerNumberModel(new Double(2.0), new Double(1.0), 
+            new Double(3.0), new Double(0.0));
+    harness.check(m.getValue(), new Double(2.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(0.0));
+    
+    // step size negative
+    m = new SpinnerNumberModel(new Double(2.0), new Double(1.0), 
+            new Double(3.0), new Double(-0.5));
+    harness.check(m.getValue(), new Double(2.0));
+    harness.check(m.getMinimum(), new Double(1.0));
+    harness.check(m.getMaximum(), new Double(3.0));
+    harness.check(m.getStepSize(), new Double(-0.5));
+    
+    // check null value
+    pass = false;
+    try
+    {
+      /*SpinnerNumberModel m =*/ new SpinnerNumberModel(null, new Long(10), 
+            new Long(30), new Long(5));
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+
+    // check null minimum
+    
+    // check null maximum
+    
+    // check null step size
+    pass = false;
+    try
+    {
+      /*SpinnerNumberModel m =*/ new SpinnerNumberModel(new Long(20), 
+              new Long(10), new Long(30), null);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  
+  }
+
+}
Index: gnu/testlet/javax/swing/SpinnerNumberModel/getNextValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerNumberModel/getNextValue.java
diff -N gnu/testlet/javax/swing/SpinnerNumberModel/getNextValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerNumberModel/getNextValue.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,48 @@
+/* getNextValue.java -- some checks for the getNextValue() method in the
+                        SpinnerNumberModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerNumberModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SpinnerNumberModel;
+
+public class getNextValue implements Testlet {
+
+  
+  public void test(TestHarness harness) 
+  {
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    harness.check(m.getValue(), new Double(2.0));
+    harness.check(m.getNextValue(), new Double(2.5));
+    
+    // accessing the next value doesn't update the current value
+    harness.check(m.getValue(), new Double(2.0));
+    m.setValue(new Double(2.5));
+    harness.check(m.getNextValue(), new Double(3.0));
+    m.setValue(new Double(3.0));
+    harness.check(m.getNextValue(), null);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerNumberModel/getPreviousValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerNumberModel/getPreviousValue.java
diff -N gnu/testlet/javax/swing/SpinnerNumberModel/getPreviousValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerNumberModel/getPreviousValue.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,47 @@
+/* getPreviousValue.java -- some checks for the getPreviousValue() method in the
+                            SpinnerNumberModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerNumberModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SpinnerNumberModel;
+
+public class getPreviousValue implements Testlet {
+
+  
+  public void test(TestHarness harness) 
+  {
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    harness.check(m.getValue(), new Double(2.0));
+    harness.check(m.getPreviousValue(), new Double(1.5));
+    // accessing the previous value doesn't update the current value
+    harness.check(m.getValue(), new Double(2.0));
+    m.setValue(new Double(1.5));
+    harness.check(m.getPreviousValue(), new Double(1.0));
+    m.setValue(new Double(1.0));
+    harness.check(m.getPreviousValue(), null);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerNumberModel/setMaximum.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerNumberModel/setMaximum.java
diff -N gnu/testlet/javax/swing/SpinnerNumberModel/setMaximum.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerNumberModel/setMaximum.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,71 @@
+/* setMaximum.java -- some checks for the setMaximum() method in the
+                      SpinnerNumberModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerNumberModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SpinnerNumberModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setMaximum implements Testlet, ChangeListener {
+  
+  private ChangeEvent event;
+  
+  public void stateChanged(ChangeEvent e)
+  {
+    this.event = e;    
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    m.addChangeListener(this);
+    m.setMaximum(new Double(3.7));
+    harness.check(m.getMaximum(), new Double(3.7));
+    harness.check(this.event.getSource(), m);
+    
+    // same value triggers no event
+    this.event = null;
+    m.setMaximum(new Double(3.7));
+    harness.check(this.event == null);
+    
+    // set null maximum
+    this.event = null;
+    m.setMaximum(null);
+    harness.check(m.getMaximum(), null);
+    harness.check(this.event.getSource(), m);
+
+    // same null value triggers no event
+    this.event = null;
+    m.setMaximum(null);
+    harness.check(this.event == null);
+    
+    // set maximum lower than minimum
+    m.setMaximum(new Double(-99.0));
+    harness.check(m.getMaximum(), new Double(-99.0));
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerNumberModel/setMinimum.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerNumberModel/setMinimum.java
diff -N gnu/testlet/javax/swing/SpinnerNumberModel/setMinimum.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerNumberModel/setMinimum.java	8 Feb 2006 16:33:14 -0000
@@ -0,0 +1,71 @@
+/* setMinimum.java -- some checks for the setMinimum() method in the
+                      SpinnerNumberModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerNumberModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SpinnerNumberModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setMinimum implements Testlet, ChangeListener {
+  
+  private ChangeEvent event;
+  
+  public void stateChanged(ChangeEvent e)
+  {
+    this.event = e;    
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    m.addChangeListener(this);
+    m.setMinimum(new Double(0.7));
+    harness.check(m.getMinimum(), new Double(0.7));
+    harness.check(this.event.getSource(), m);
+    
+    // same value triggers no event
+    this.event = null;
+    m.setMinimum(new Double(0.7));
+    harness.check(this.event == null);
+    
+    // set null minimum
+    this.event = null;
+    m.setMinimum(null);
+    harness.check(m.getMinimum(), null);
+    harness.check(this.event.getSource(), m);
+
+    // same null value triggers no event
+    this.event = null;
+    m.setMinimum(null);
+    harness.check(this.event == null);
+    
+    // set minimum higher than maximum
+    m.setMinimum(new Double(99.0));
+    harness.check(m.getMinimum(), new Double(99.0));
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerNumberModel/setStepSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerNumberModel/setStepSize.java
diff -N gnu/testlet/javax/swing/SpinnerNumberModel/setStepSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerNumberModel/setStepSize.java	8 Feb 2006 16:33:15 -0000
@@ -0,0 +1,68 @@
+/* setStepSize.java -- some checks for the setStepSize() method in the
+                       SpinnerNumberModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerNumberModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SpinnerNumberModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setStepSize implements Testlet, ChangeListener {
+  
+  private ChangeEvent event;
+  
+  public void stateChanged(ChangeEvent e)
+  {
+    this.event = e;    
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    m.addChangeListener(this);
+    m.setStepSize(new Double(0.7));
+    harness.check(m.getStepSize(), new Double(0.7));
+    harness.check(this.event.getSource(), m);
+    
+    // same value triggers no event
+    this.event = null;
+    m.setStepSize(new Double(0.7));
+    harness.check(this.event == null);
+    
+    // set null step size
+    boolean pass = false;
+    try
+    {
+      m.setStepSize(null);        
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/SpinnerNumberModel/setValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/SpinnerNumberModel/setValue.java
diff -N gnu/testlet/javax/swing/SpinnerNumberModel/setValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SpinnerNumberModel/setValue.java	8 Feb 2006 16:33:15 -0000
@@ -0,0 +1,88 @@
+/* setValue.java -- some checks for the setValue() method in the
+                    SpinnerNumberModel 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.4
+
+package gnu.testlet.javax.swing.SpinnerNumberModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.SpinnerNumberModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setValue implements Testlet, ChangeListener {
+  
+  private ChangeEvent event;
+  
+  public void stateChanged(ChangeEvent e)
+  {
+    this.event = e;    
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    m.addChangeListener(this);
+    m.setValue(new Double(2.2));
+    harness.check(m.getValue(), new Double(2.2));
+    harness.check(this.event.getSource(), m);
+    
+    // same value triggers no event
+    this.event = null;
+    m.setValue(new Double(2.2));
+    harness.check(this.event == null);
+    
+    // set value less than minimum
+    m.setValue(new Double(-99.0));        
+    harness.check(m.getValue(), new Double(-99.0));
+
+    // set value greater than maximum
+    m.setValue(new Double(99.0));        
+    harness.check(m.getValue(), new Double(99.0));
+  
+    // set null value
+    boolean pass = false;
+    try
+    {
+      m.setValue(null);        
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    // set a non-numeric value
+    pass = false;
+    try
+    {
+      m.setValue("123");        
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]