harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r646758 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/org/apache/harmony/beans/editors/BooleanEditor.java test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
Date Thu, 10 Apr 2008 11:14:11 GMT
Author: tellison
Date: Thu Apr 10 04:14:05 2008
New Revision: 646758

URL: http://svn.apache.org/viewvc?rev=646758&view=rev
Log:
Fix for HARMONY-5711 (Boolean Property editor returns true/false from getAsText(), but True/False
from getTags())

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java?rev=646758&r1=646757&r2=646758&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
Thu Apr 10 04:14:05 2008
@@ -42,6 +42,15 @@
     }
 
     @Override
+    public String getAsText() {
+        Object value = getValue();
+        if (value == null) {
+            return null;
+        }
+        return Boolean.TRUE.equals(value) ? "True" : "False"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    @Override
     public String getJavaInitializationString() {
         return getValueAsString();
     }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java?rev=646758&r1=646757&r2=646758&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
Thu Apr 10 04:14:05 2008
@@ -223,6 +223,38 @@
         }
     }
 
+    // Regression test for HARMONY-5711
+    @SuppressWarnings("nls")
+    public void testBooleanEditor() {
+        PropertyEditor propertyEditor = PropertyEditorManager
+                .findEditor(boolean.class);
+        assertNotNull(propertyEditor);
+        String tags[] = propertyEditor.getTags();
+        assertEquals(2, tags.length);
+        assertEquals("True", tags[0]);
+        assertEquals("False", tags[1]);
+
+        propertyEditor.setValue(Boolean.FALSE);
+        assertEquals("False", propertyEditor.getAsText());
+        assertEquals("false", propertyEditor.getJavaInitializationString());
+        propertyEditor.setAsText("False");
+        assertEquals("False", propertyEditor.getAsText());
+        assertEquals("false", propertyEditor.getJavaInitializationString());
+        propertyEditor.setAsText("false");
+        assertEquals("False", propertyEditor.getAsText());
+        assertEquals("false", propertyEditor.getJavaInitializationString());
+
+        propertyEditor.setValue(Boolean.TRUE);
+        assertEquals("True", propertyEditor.getAsText());
+        assertEquals("true", propertyEditor.getJavaInitializationString());
+        propertyEditor.setAsText("True");
+        assertEquals("True", propertyEditor.getAsText());
+        assertEquals("true", propertyEditor.getJavaInitializationString());
+        propertyEditor.setAsText("true");
+        assertEquals("True", propertyEditor.getAsText());
+        assertEquals("true", propertyEditor.getJavaInitializationString());
+    }
+    
     public void testByteEditor() {
         PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
         byte b = (byte) 0x7F;



Mime
View raw message