harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r472046 - in /incubator/harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/ test/api/java/common/javax/swing/
Date Tue, 07 Nov 2006 09:32:39 GMT
Author: smishura
Date: Tue Nov  7 01:32:38 2006
New Revision: 472046

URL: http://svn.apache.org/viewvc?view=rev&rev=472046
Log:
Apply patches for HARMONY-1965 ([classlib][swing] javax.swing.JList.addSelectionInterval(int,
int) doesn't throw IndexOutOfBoundsException if parameter < -1)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DefaultListSelectionModelTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JListTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java?view=diff&rev=472046&r1=472045&r2=472046
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultListSelectionModel.java
Tue Nov  7 01:32:38 2006
@@ -494,6 +494,14 @@
     }
 
     private boolean isValidInterval(final int n1, final int n2) {
-        return n1 >= 0 && n2 >= 0;
+        if (n1 == -1 || n2 == -1) {
+            return false;
+        }
+
+        if (n1 < -1 || n2 < -1) {
+            throw new IndexOutOfBoundsException(); // According to the API specification
+        }
+
+        return true;
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DefaultListSelectionModelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DefaultListSelectionModelTest.java?view=diff&rev=472046&r1=472045&r2=472046
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DefaultListSelectionModelTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/DefaultListSelectionModelTest.java
Tue Nov  7 01:32:38 2006
@@ -660,4 +660,60 @@
             events.clear();
         }
     }
+
+    public void testIsValidInterval() throws Exception {
+        // regression test for HARMONY-1965
+        try {
+            model.addSelectionInterval(-2, 0);
+            fail("addSelectionInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        try {
+            model.addSelectionInterval(0, -2);
+            fail("addSelectionInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        try {
+            model.setSelectionInterval(-2, 0);
+            fail("setSelectionInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        try {
+            model.setSelectionInterval(0, -2);
+            fail("setSelectionInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        try {
+            model.removeSelectionInterval(-2, 0);
+            fail("removeSelectionInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        try {
+            model.removeSelectionInterval(0, -2);
+            fail("removeSelectionInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        try {
+            model.insertIndexInterval(-2, 0, true);
+            fail("insertIndexInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        if (isHarmony()) {
+            try {
+                model.insertIndexInterval(0, -2, true);
+                fail("insertIndexInterval should throw IndexOutOfBoundsException");
+            } catch (IndexOutOfBoundsException e) {
+            }
+        }
+        try {
+            model.removeIndexInterval(-2, 0);
+            fail("removeIndexInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+        try {
+            model.removeIndexInterval(0, -2);
+            fail("removeIndexInterval should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JListTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JListTest.java?view=diff&rev=472046&r1=472045&r2=472046
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JListTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JListTest.java
Tue Nov  7 01:32:38 2006
@@ -129,6 +129,20 @@
         list.addSelectionInterval(1, 2);
         assertFalse(list.isSelectionEmpty());
         assertFalse(list.getSelectionModel().isSelectionEmpty());
+
+        try {
+            // Regression for HARMONY-1965
+            list.addSelectionInterval(1, -2);
+            fail("IndexOutOfBoundsException expected.");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            // Regression for HARMONY-1965
+            list.addSelectionInterval(-2, 2);
+            fail("IndexOutOfBoundsException expected.");
+        } catch (IndexOutOfBoundsException e) {            
+        }
     }
 
     public void testClearSelection() throws Exception {



Mime
View raw message