harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r496120 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/Raster.java test/api/java/common/java/awt/image/RasterTest.java
Date Sun, 14 Jan 2007 20:04:06 GMT
Author: hindessm
Date: Sun Jan 14 12:04:06 2007
New Revision: 496120

URL: http://svn.apache.org/viewvc?view=rev&rev=496120
Log:
Applying patches from "[#HARMONY-2743] [classlib][awt]
java.awt.image.Raster.createCompatibleWritableRaster() throws unspecified
IllegalArgumentException".  The test is too verbose and the exception
handling needs improving but I'll commit that separately.

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java?view=diff&rev=496120&r1=496119&r2=496120
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
Sun Jan 14 12:04:06 2007
@@ -686,6 +686,11 @@
     }
 
     public WritableRaster createCompatibleWritableRaster(int w, int h) {
+        if (w <= 0 || h <= 0) {
+            // awt.22E=w or h is less than or equal to zero
+            throw new RasterFormatException(Messages.getString("awt.22E")); //$NON-NLS-1$
+        }
+
         SampleModel sm = sampleModel.createCompatibleSampleModel(w, h);
 
         return new OrdinaryWritableRaster(sm, new Point(0, 0));

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java?view=diff&rev=496120&r1=496119&r2=496120
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java
Sun Jan 14 12:04:06 2007
@@ -21,6 +21,8 @@
 import junit.framework.TestCase;
 import java.awt.Point;
 
+import java.awt.*;
+
 public class RasterTest extends TestCase {
     // Regression test for harmony-2717
     public void test_createPackedRaster()
@@ -46,6 +48,22 @@
             fail("RasterFormatException expected!");
         } catch (RasterFormatException expectedException) {
             // Expected
+        }
+    }
+
+    // Regression test for Harmony-2743
+    public void test_createCompatibleWritableRaster() {
+        MultiPixelPackedSampleModel localMultiPixelPackedSampleModel =
+                new MultiPixelPackedSampleModel(0, 5, 22, -1, -25, 40825);
+        Point localPoint = new Point();
+        Raster localRaster = Raster.createWritableRaster(localMultiPixelPackedSampleModel,localPoint);
+        try {
+            localRaster.createCompatibleWritableRaster(-32,8);
+            fail("Exception expected");
+        } catch (RasterFormatException expectedException) {
+            System.out.println(expectedException +" was thrown");
+        } catch (IllegalArgumentException expectedException) {
+            fail(expectedException +" was thrown");
         }
     }
 }



Mime
View raw message