harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r431509 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/PropertyEditorSupport.java test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java
Date Tue, 15 Aug 2006 03:21:21 GMT
Author: mloenko
Date: Mon Aug 14 20:21:20 2006
New Revision: 431509

URL: http://svn.apache.org/viewvc?rev=431509&view=rev
Log:
Enabled some tests in PropertyEditorSupportTest
Used patches from HARMONY-1113

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java?rev=431509&r1=431508&r2=431509&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorSupport.java
Mon Aug 14 20:21:20 2006
@@ -53,6 +53,7 @@
      * @com.intel.drl.spec_ref
      */
     public PropertyEditorSupport() {
+        source = this;
     }
 
     /**
@@ -65,7 +66,11 @@
      * @com.intel.drl.spec_ref
      */
     public void setAsText(String text) throws IllegalArgumentException {
-        setValue(text);
+        if (newValue instanceof String){
+            setValue(text);
+        } else {
+            throw new IllegalArgumentException(text);
+        }
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java?rev=431509&r1=431508&r2=431509&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java
Mon Aug 14 20:21:20 2006
@@ -32,7 +32,7 @@
      */
     public void testPropertyEditorSupport() {
         // Regression for HARMONY-516
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
 
         assertEquals("null", support.getAsText());
         assertNull(support.getValue());
@@ -52,7 +52,7 @@
      */
     public void testPropertyEditorSupportObject() {
         MockSource source = new MockSource();
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport(
+        PropertyEditorSupport support = new PropertyEditorSupport(
                 source);
 
         assertEquals("null", support.getAsText());
@@ -69,7 +69,7 @@
      */
     public void testPropertyEditorSupportObject_null() {
         try {
-            new MockPropertyEditorSupport(null);
+            new PropertyEditorSupport(null);
             fail("Should throw NullPointerException.");
         } catch (NullPointerException e) {
             // expected
@@ -81,7 +81,7 @@
      */
     public void testAddPropertyChangeListener() {
         MockTarget target = new MockTarget();
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         support.addPropertyChangeListener(EventHandler.create(
                 PropertyChangeListener.class, target, "setCalled"));
         support.firePropertyChange();
@@ -92,7 +92,7 @@
     public void testAddPropertyChangeListener_source() {
         MockTarget target = new MockTarget();
         MockSource source = new MockSource();
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport(
+        PropertyEditorSupport support = new PropertyEditorSupport(
                 source);
         support.addPropertyChangeListener(EventHandler.create(
                 PropertyChangeListener.class, target, "eventSource", "source"));
@@ -102,7 +102,7 @@
 
     public void testAddPropertyChangeListener_source_null() {
         MockTarget target = new MockTarget();
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         support.addPropertyChangeListener(EventHandler.create(
                 PropertyChangeListener.class, target, "eventSource", ""));
         support.firePropertyChange();
@@ -114,7 +114,7 @@
     }
 
     public void testFirePropertyChange_noListener() {
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         support.firePropertyChange();
     }
 
@@ -122,7 +122,7 @@
      * listener is null
      */
     public void testAddPropertyChangeListener_null() {
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         support.addPropertyChangeListener(null);
         try {
             support.firePropertyChange();
@@ -133,13 +133,13 @@
     }
 
     public void testPaintValue() {
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         support.paintValue(null, null);
     }
 
     public void testRemovePropertyChangeListener() {
         MockTarget target = new MockTarget();
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         PropertyChangeListener proxy = EventHandler.create(
                 PropertyChangeListener.class, target, "eventSource", "source");
         support.addPropertyChangeListener(proxy);
@@ -154,7 +154,7 @@
 
     public void testRemovePropertyChangeListener_null() {
         MockTarget target = new MockTarget();
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         PropertyChangeListener proxy = EventHandler.create(
                 PropertyChangeListener.class, target, "eventSource", "source");
         support.addPropertyChangeListener(proxy);
@@ -172,7 +172,7 @@
      */
     public void testRemovePropertyChangeListener_diff() {
         MockTarget target = new MockTarget();
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         PropertyChangeListener proxy = EventHandler.create(
                 PropertyChangeListener.class, target, "eventSource", "source");
         support.addPropertyChangeListener(proxy);
@@ -191,7 +191,7 @@
      * remove null listener
      */
     public void testRemovePropertyChangeListener_null_null() {
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         support.addPropertyChangeListener(null);
         try {
             support.firePropertyChange();
@@ -205,18 +205,31 @@
     }
 
     public void testSetAsText() {
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-        String asText = "100";
+        // Regression for HARMONY-1113
+        PropertyEditorSupport support;
+
+        support = new PropertyEditorSupport();
         try {
-            support.setAsText(asText);
+            support.setAsText("100");
             fail("Should throw IllegalArgumentException.");
         } catch (IllegalArgumentException e) {
             // expected
         }
+
+        support = new PropertyEditorSupport();
+        support.setValue(new Object());
+        try {
+            support.setAsText("string");
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {}
+
+        support = new PropertyEditorSupport();
+        support.setValue(new String());
+        support.setAsText("string");
     }
 
     public void testSetValue() {
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         String[] value = new String[] { "This is a sample value." };
         support.setValue(value);
 
@@ -232,7 +245,7 @@
     }
 
     public void testSetValue_null() {
-        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyEditorSupport support = new PropertyEditorSupport();
         support.setValue(null);
 
         assertEquals(null, support.getValue());
@@ -254,17 +267,6 @@
         assertNull(support.getTags());
         assertFalse(support.supportsCustomEditor());
         assertFalse(support.isPaintable());
-    }
-
-    public static class MockPropertyEditorSupport extends PropertyEditorSupport {
-
-        public MockPropertyEditorSupport() {
-            super();
-        }
-
-        public MockPropertyEditorSupport(Object source) {
-            super(source);
-        }
     }
 
     public static class MockSource {



Mime
View raw message