harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r495930 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/text/StyledEditorKit.java test/api/java/common/javax/swing/text/StyledEditorKitTest.java
Date Sat, 13 Jan 2007 17:28:53 GMT
Author: hindessm
Date: Sat Jan 13 09:28:51 2007
New Revision: 495930

URL: http://svn.apache.org/viewvc?view=rev&rev=495930
Log:
Applying patch from "[#HARMONY-2594] [classlib][swing]
javax.swing.text.StyledEditorKit.createInputAttributes(Element element,
MutableAttributeSet set) doesn't throw NPE when any of arguments is null".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java?view=diff&rev=495930&r1=495929&r2=495930
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java
Sat Jan 13 09:28:51 2007
@@ -358,9 +358,6 @@
 
     protected void createInputAttributes(final Element element,
                                          final MutableAttributeSet set) {
-        if (element == null || set == null) {
-            return;
-        }
         AttributeSet as = element.getAttributes();
         set.removeAttributes(set);
         for (Enumeration keys = as.getAttributeNames();

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java?view=diff&rev=495930&r1=495929&r2=495930
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java
Sat Jan 13 09:28:51 2007
@@ -20,9 +20,12 @@
  */
 package javax.swing.text;
 
+import java.util.Enumeration;
+
 import javax.swing.Action;
 import javax.swing.JEditorPane;
 import javax.swing.SwingTestCase;
+import javax.swing.event.ChangeListener;
 
 public class StyledEditorKitTest extends SwingTestCase {
     StyledEditorKit kit;
@@ -280,4 +283,99 @@
 
     public void testInstallJEditorPane() {
     }
+    
+    
+    
+    /**
+     * Regression test for HARMONY-2594
+     * */
+    public void testcreateInputAttributes() {
+        MyStyledEditorKit msek = new MyStyledEditorKit();
+        MutableAttributeSet set = new Style() {
+            public void removeChangeListener(ChangeListener p0) {
+                return;
+            }
+            public void addChangeListener(ChangeListener p0) {
+                return;
+            }
+            public String getName() {
+                return "AA";
+            }
+            public void setResolveParent(AttributeSet p0) {
+                return;
+            }
+            public void removeAttributes(AttributeSet p0) {
+                return;
+            }
+            public void removeAttributes(Enumeration p0) {
+                return;
+            }
+            public void removeAttribute(Object p0) {
+                return;
+            }
+            public void addAttributes(AttributeSet p0) {
+                return;
+            }
+            public void addAttribute(Object p0, Object p1) {
+                return;
+            }
+            public AttributeSet getResolveParent() {
+                return null;
+            }
+            public boolean containsAttributes(AttributeSet p0) {
+                return false;
+            }
+            public boolean containsAttribute(Object p0, Object p1) {
+                return false;
+            }
+            public Enumeration getAttributeNames() {
+                return null;
+            }
+            public Object getAttribute(Object p0) {
+                return null;
+            }
+            public AttributeSet copyAttributes() {
+                return null;
+            }
+            public boolean isEqual(AttributeSet p0) {
+                return false;
+            }
+            public boolean isDefined(Object p0) {
+                return false;
+            }
+            public int getAttributeCount() {
+                return 0;
+            }
+        };
+        try {
+            msek.createInputAttributes(null, set);
+            fail("NPE not thrown when Element is null!");
+        } catch (NullPointerException npe) {
+            // expected
+        }
+    }
+
+    /**
+     * Regression test for HARMONY-2594
+     * */
+    public void testCreateInputAttributes2() {
+        MyStyledEditorKit msek = new MyStyledEditorKit();
+        try {
+            msek.createInputAttributes(new SimpleElement(""), null);
+            fail("NPE not thrown when MutableAttributeSet is null!");
+        } catch (NullPointerException npe) {
+            // expected
+        }
+    }
+    
+    class MyStyledEditorKit extends StyledEditorKit {
+        public MyStyledEditorKit() {
+            super();
+        }
+
+        public void createInputAttributes(Element element, MutableAttributeSet set) {
+            super.createInputAttributes(element, set);
+        }
+    }
+    
 }



Mime
View raw message