You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2014/10/10 18:58:50 UTC

svn commit: r1630937 - in /jmeter/trunk: src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java xdocs/changes.xml

Author: sebb
Date: Fri Oct 10 16:58:50 2014
New Revision: 1630937

URL: http://svn.apache.org/r1630937
Log:
BooleanPropertyEditor#getAsText() must return a value that is in getTags()
Bugzilla Id: 57076

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java
    jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java?rev=1630937&r1=1630936&r2=1630937&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java Fri Oct 10 16:58:50 2014
@@ -28,10 +28,21 @@ public class BooleanPropertyEditor exten
     // These are the mixed-case values as returned by the RI JVM boolean property editor
     // However, they are different from the lower-case values returned by e.g. Boolean.FALSE.toString() 
     private static final String FALSE = "False"; // $NON-NLS-1$
-    private static final String TRUE = "True";   // $NON-NLS-1$
+    private static final String TRUE  = "True";  // $NON-NLS-1$
 
     private static final String[] TAGS = {TRUE, FALSE};
 
+    // Make sure we return one of the TAGS
+    @Override
+    public String getAsText() {
+        Object value = getValue();
+        return value instanceof Boolean ?  toString((Boolean) value) : null; 
+    }
+
+    private String toString(Boolean value) {
+        return value.booleanValue() ? TRUE : FALSE;
+    }
+
     @Override
     public void setAsText(String text) {
         this.setValue(text);

Modified: jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java?rev=1630937&r1=1630936&r2=1630937&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java Fri Oct 10 16:58:50 2014
@@ -22,7 +22,8 @@ import java.beans.PropertyEditorManager;
 /**
  * Test class to check that the JVM provides sensible behaviour for the boolean PropertyEditor, i.e.
  * that getAsText() can only return values that match getTags().
- * 
+ *
+ * Also checks that BooleanPropertyEditor behaves in the same way.
  */
 public class TestBooleanPropertyEditor extends junit.framework.TestCase {
  
@@ -32,8 +33,8 @@ public class TestBooleanPropertyEditor e
      * which returns lower-case only. The getAsText() method converts
      * the result to mixed case.
      */
-    private static final String FALSE = "False";
-    private static final String TRUE = "True";
+    private static final String FALSE = "False"; // $NON-NLS-1$
+    private static final String TRUE  = "True";  // $NON-NLS-1$
 
     public TestBooleanPropertyEditor(String name) {
         super(name);
@@ -41,7 +42,17 @@ public class TestBooleanPropertyEditor e
 
     public void testBooleanEditor(){
         PropertyEditor propertyEditor = PropertyEditorManager.findEditor(boolean.class);
-        assertNotNull(propertyEditor);
+        testBooleanEditor(propertyEditor);
+    }
+
+    public void testBooleanPropertyEditor() {
+        PropertyEditor propertyEditor = new BooleanPropertyEditor();
+        testBooleanEditor(propertyEditor);
+    }
+
+    private void testBooleanEditor(PropertyEditor propertyEditor) {
+        assertNotNull("Expected to find property editor", propertyEditor);
+        System.out.println(propertyEditor.getClass().getCanonicalName());
         String tags[] = propertyEditor.getTags();
         assertEquals(2,tags.length);
         assertEquals(TRUE,tags[0]);
@@ -53,6 +64,10 @@ public class TestBooleanPropertyEditor e
         assertEquals(FALSE,propertyEditor.getAsText());
         propertyEditor.setAsText("false");
         assertEquals(FALSE,propertyEditor.getAsText());
+        propertyEditor.setAsText("False");
+        assertEquals(FALSE,propertyEditor.getAsText());
+        propertyEditor.setAsText("FALSE");
+        assertEquals(FALSE,propertyEditor.getAsText());
         
         propertyEditor.setValue(Boolean.TRUE);
         assertEquals(TRUE,propertyEditor.getAsText());
@@ -60,5 +75,9 @@ public class TestBooleanPropertyEditor e
         assertEquals(TRUE,propertyEditor.getAsText());
         propertyEditor.setAsText("true");
         assertEquals(TRUE,propertyEditor.getAsText());
-        }
+        propertyEditor.setAsText("True");
+        assertEquals(TRUE,propertyEditor.getAsText());
+        propertyEditor.setAsText("TRUE");
+        assertEquals(TRUE,propertyEditor.getAsText());
+    }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1630937&r1=1630936&r2=1630937&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Oct 10 16:58:50 2014
@@ -269,6 +269,7 @@ for details on configuring this componen
 <li><bugzilla>56962</bugzilla> - JMS GUIs should disable all fields affected by jndi.properties checkbox</li>
 <li><bugzilla>57061</bugzilla> - Save as Test Fragment fails to clone deeply selected node. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
 <li><bugzilla>57075</bugzilla> - BeanInfoSupport.MULTILINE attribute is not processed</li>
+<li><bugzilla>57076</bugzilla> - BooleanPropertyEditor#getAsText() must return a value that is in getTags()</li>
 </ul>
 
 <!-- =================== Improvements =================== -->