harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r466036 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/GradientPaint.java test/api/java/common/java/awt/GradientPaintTest.java
Date Fri, 20 Oct 2006 08:35:30 GMT
Author: mloenko
Date: Fri Oct 20 01:35:28 2006
New Revision: 466036

URL: http://svn.apache.org/viewvc?view=rev&rev=466036
Log:
applied patch from HARMONY-1470
[classlib][awt] GradientPaint doesn't throw NPE if Color is null

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/GradientPaintTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java?view=diff&rev=466036&r1=466035&r2=466036
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java
Fri Oct 20 01:35:28 2006
@@ -49,8 +49,15 @@
      */
     boolean cyclic;
 
-    public GradientPaint(Point2D point1, Color color1, Point2D point2, Color color2,
-            boolean cyclic) {
+    public GradientPaint(Point2D point1, Color color1, Point2D point2,
+            Color color2, boolean cyclic) {
+        if (point1 == null || point2 == null) {
+            throw new NullPointerException("Point is null");
+        }
+        if (color1 == null || color2 == null) {
+            throw new NullPointerException("Color is null");
+        }
+
         this.point1 = point1;
         this.point2 = point2;
         this.color1 = color1;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/GradientPaintTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/GradientPaintTest.java?view=diff&rev=466036&r1=466035&r2=466036
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/GradientPaintTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/GradientPaintTest.java
Fri Oct 20 01:35:28 2006
@@ -30,19 +30,60 @@
 
     GradientPaint gp;
 
-    public GradientPaintTest(String name) {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-//      gp = new GradientPaint();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
+    public void testContructorBad() {
+        // Regression for HARMONY-1470
+        try {
+            new GradientPaint(1, 2, null, 3, 4, new Color(255), false);
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
+            new GradientPaint(1, 2, new Color(255), 3, 4, null, false);
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
+            new GradientPaint(1, 2, null, 4, 5, new Color(255));
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
+            new GradientPaint(1, 2, new Color(255), 4, 5, null);
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
+            new GradientPaint(null, new Color(255), new Point2D.Float(),
+                    new Color(255));
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
+            new GradientPaint(new Point2D.Float(), null, new Point2D.Float(),
+                    new Color(255));
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
+            new GradientPaint(new Point2D.Float(), new Color(255), null,
+                    new Color(255));
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        try {
+            new GradientPaint(new Point2D.Float(), new Color(255),
+                    new Point2D.Float(), null);
+            fail("expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
     }
 
     public void testGetPoint1() {



Mime
View raw message