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 2011/11/25 01:40:35 UTC

svn commit: r1206025 - in /jmeter/trunk: src/core/org/apache/jmeter/testbeans/gui/ xdocs/

Author: sebb
Date: Fri Nov 25 00:40:34 2011
New Revision: 1206025

URL: http://svn.apache.org/viewvc?rev=1206025&view=rev
Log:
Bug 52240 - TestBeans should support Boolean, Integer and Long

Added:
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java   (with props)
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/IntegerPropertyEditor.java   (with props)
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/LongPropertyEditor.java   (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java
    jmeter/trunk/xdocs/changes.xml

Added: 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=1206025&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java Fri Nov 25 00:40:34 2011
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.testbeans.gui;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * Property Editor which handles Boolean properties.
+ */
+public class BooleanPropertyEditor extends PropertyEditorSupport {
+
+    @Override
+    public void setAsText(String text) {
+        this.setValue(text);
+    }
+
+    @Override
+    public void setValue(Object value){
+        if (value instanceof String) {
+            super.setValue(Boolean.valueOf((String) value));
+        } else if (value == null || value instanceof Boolean) {
+            super.setValue(value); // not sure if null is passed in but no harm in setting it
+        } else {
+            throw new java.lang.IllegalArgumentException("Unexpected type: "+value.getClass().getName());
+        }
+    }
+
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/BooleanPropertyEditor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java?rev=1206025&r1=1206024&r2=1206025&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java Fri Nov 25 00:40:34 2011
@@ -97,6 +97,12 @@ public class GenericTestBeanCustomizer e
 
     private static final Logger log = LoggingManager.getLoggerForClass();
 
+    static {
+        PropertyEditorManager.registerEditor(Long.class,    LongPropertyEditor.class);
+        PropertyEditorManager.registerEditor(Integer.class, IntegerPropertyEditor.class);
+        PropertyEditorManager.registerEditor(Boolean.class, BooleanPropertyEditor.class);
+    }
+
     public static final String GROUP = "group"; //$NON-NLS-1$
 
     public static final String ORDER = "order"; //$NON-NLS-1$

Added: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/IntegerPropertyEditor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/IntegerPropertyEditor.java?rev=1206025&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/IntegerPropertyEditor.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/IntegerPropertyEditor.java Fri Nov 25 00:40:34 2011
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.testbeans.gui;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * Property Editor which handles Integer properties.
+ * Uses {@link Integer#decode(String)} so supports hex and octal input.
+ */
+public class IntegerPropertyEditor extends PropertyEditorSupport {
+
+    @Override
+    public void setAsText(String text) {
+        this.setValue(text);
+    }
+
+    @Override
+    public void setValue(Object value){
+        if (value instanceof String) {
+            super.setValue(Integer.decode((String) value)); // handles hex as well
+        } else if (value == null || value instanceof Integer) {
+            super.setValue(value); // not sure if null is passed in but no harm in setting it
+        } else {
+            throw new java.lang.IllegalArgumentException("Unexpected type: "+value.getClass().getName());
+        }
+    }
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/IntegerPropertyEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/IntegerPropertyEditor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/LongPropertyEditor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/LongPropertyEditor.java?rev=1206025&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/LongPropertyEditor.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/LongPropertyEditor.java Fri Nov 25 00:40:34 2011
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.testbeans.gui;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * Property Editor which handles Long properties.
+ * Uses {@link Long#decode(String)} so supports hex and octal input.
+ */
+public class LongPropertyEditor extends PropertyEditorSupport {
+
+    @Override
+    public void setAsText(String text) {
+        this.setValue(text);
+    }
+
+    @Override
+    public void setValue(Object value){
+        if (value instanceof String) {
+            super.setValue(Long.decode((String) value)); // handles hex as well
+        } else if (value == null || value instanceof Long) {
+            super.setValue(value); // not sure if null is passed in but no harm in setting it
+        } else {
+            throw new java.lang.IllegalArgumentException("Unexpected type: "+value.getClass().getName());
+        }
+    }
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/LongPropertyEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/LongPropertyEditor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1206025&r1=1206024&r2=1206025&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Nov 25 00:40:34 2011
@@ -226,6 +226,7 @@ This behaviour can be changed with prope
 Loads any additional properties found in META-INF/resources/org.apache.jmeter.nameupdater.properties files</li>
 <li>Bug 42538 - Add "duplicate node" in context menu</li>
 <li>Bug 46921 - Add Ability to Change Controller elements</li>
+<li>Bug 52240 - TestBeans should support Boolean, Integer and Long</li>
 </ul>
 
 <h2>Non-functional changes</h2>