Author: sebb
Date: Sat Mar 19 12:15:58 2016
New Revision: 1735765

URL: http://svn.apache.org/viewvc?rev=1735765&view=rev
Log:
New fields/changed defaults cause earlier test plans to be marked as changed
Fix AccessLogSampler; added TestBean support for not saving default values
Bugzilla Id: 59173

Added:
    jmeter/trunk/latest.patch   (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java
    
jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java
    jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java
    
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java

Added: jmeter/trunk/latest.patch
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/latest.patch?rev=1735765&view=auto
==============================================================================
--- jmeter/trunk/latest.patch (added)
+++ jmeter/trunk/latest.patch Sat Mar 19 12:15:58 2016
@@ -0,0 +1,101 @@
+### Eclipse Workspace Patch 1.0
+#P JMeter
+Index: src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java
+===================================================================
+--- src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java  (revision 
1735468)
++++ src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java  (working copy)
+@@ -82,6 +82,9 @@
+     /** Default value, must be provided if {@link #NOT_UNDEFINED} is TRUE */
+     public static final String DEFAULT = GenericTestBeanCustomizer.DEFAULT;
+ 
++    /** Default value is not saved; only non-defaults are saved */
++    public static final String DEFAULT_NOT_SAVED = 
GenericTestBeanCustomizer.DEFAULT_NOT_SAVED;
++
+     /** Pointer to the resource bundle, if any (will generally be null) */
+     public static final String RESOURCE_BUNDLE = 
GenericTestBeanCustomizer.RESOURCE_BUNDLE;
+ 
+Index: src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java
+===================================================================
+--- src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java  (revision 
1735468)
++++ src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java  (working copy)
+@@ -249,12 +249,22 @@
+             log.debug("Modify " + name + " to " + value);
+             if (value == null) {
+                 if (GenericTestBeanCustomizer.notNull(desc)) { // cannot be 
null
+-                    setPropertyInElement(element, name, 
desc.getValue(GenericTestBeanCustomizer.DEFAULT));
++                    if (GenericTestBeanCustomizer.noSaveDefault(desc)) {
++                        log.debug("Did not set DEFAULT for " + name);
++                        element.removeProperty(name);
++                    } else {
++                        setPropertyInElement(element, name, 
desc.getValue(GenericTestBeanCustomizer.DEFAULT));
++                    }
+                 } else {
+                     element.removeProperty(name);
+                 }
+             } else {
+-                setPropertyInElement(element, name, value);
++                if (GenericTestBeanCustomizer.noSaveDefault(desc) && 
value.equals(desc.getValue(GenericTestBeanCustomizer.DEFAULT))) {
++                    log.debug("Did not set " + name + " to the default: " + 
value);
++                    element.removeProperty(name);
++                } else {
++                    setPropertyInElement(element, name, value);
++                }
+             }
+         }
+     }
+Index: 
src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java
+===================================================================
+--- 
src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java
    (revision 1735468)
++++ 
src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java
    (working copy)
+@@ -84,6 +84,7 @@
+             p = property("protocol"); // $NON-NLS-1$
+             p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+             p.setValue(DEFAULT, "http"); // $NON-NLS-1$
++            p.setValue(DEFAULT_NOT_SAVED, Boolean.TRUE);
+ 
+             p = property("portString"); // $NON-NLS-1$
+             p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+Index: src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java
+===================================================================
+--- src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java    
(revision 1735468)
++++ src/core/org/apache/jmeter/testbeans/gui/GenericTestBeanCustomizer.java    
(working copy)
+@@ -141,6 +141,9 @@
+     /** Default value, must be provided if {@link #NOT_UNDEFINED} is TRUE */
+     public static final String DEFAULT = "default"; //$NON-NLS-1$
+ 
++    /** Default value is not saved; only non-defaults are saved */
++    public static final String DEFAULT_NOT_SAVED = "defaultNoSave"; 
//$NON-NLS-1$
++
+     /** Pointer to the resource bundle, if any (will generally be null) */
+     public static final String RESOURCE_BUNDLE = "resourceBundle"; 
//$NON-NLS-1$
+ 
+@@ -326,7 +329,10 @@
+         if (deflt == null) {
+             if (notNull(pd)) {
+                 log.warn(getDetails(pd) + " requires a value but does not 
provide a default.");
+-            }            
++            }
++            if (noSaveDefault(pd)) {
++                log.warn(getDetails(pd) + " specifies DEFAULT_NO_SAVE but 
does not provide a default.");                
++            }
+         } else {
+             final Class<?> defltClass = deflt.getClass(); // the DEFAULT class
+             // Convert int to Integer etc:
+@@ -451,6 +457,17 @@
+     }
+ 
+     /**
++     * Returns true if the property default value is not saved
++     * 
++     * @param descriptor the property descriptor
++     * @return true if the attribute {@link #DEFAULT_NOT_SAVED} is defined 
and equal to Boolean.TRUE;
++     *  otherwise the default is false
++     */
++    static boolean noSaveDefault(PropertyDescriptor descriptor) {
++        return Boolean.TRUE.equals(descriptor.getValue(DEFAULT_NOT_SAVED));
++    }
++
++    /**
+      * Set the value of the i-th property, properly reporting a possible
+      * failure.
+      *

Propchange: jmeter/trunk/latest.patch
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java?rev=1735765&r1=1735764&r2=1735765&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java 
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java Sat 
Mar 19 12:15:58 2016
@@ -82,6 +82,9 @@ public abstract class BeanInfoSupport ex
     /** Default value, must be provided if {@link #NOT_UNDEFINED} is TRUE */
     public static final String DEFAULT = GenericTestBeanCustomizer.DEFAULT;
 
+    /** Default value is not saved; only non-defaults are saved */
+    public static final String DEFAULT_NOT_SAVED = 
GenericTestBeanCustomizer.DEFAULT_NOT_SAVED;
+
     /** Pointer to the resource bundle, if any (will generally be null) */
     public static final String RESOURCE_BUNDLE = 
GenericTestBeanCustomizer.RESOURCE_BUNDLE;
 

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=1735765&r1=1735764&r2=1735765&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
 Sat Mar 19 12:15:58 2016
@@ -141,6 +141,9 @@ public class GenericTestBeanCustomizer e
     /** Default value, must be provided if {@link #NOT_UNDEFINED} is TRUE */
     public static final String DEFAULT = "default"; //$NON-NLS-1$
 
+    /** Default value is not saved; only non-defaults are saved */
+    public static final String DEFAULT_NOT_SAVED = "defaultNoSave"; 
//$NON-NLS-1$
+
     /** Pointer to the resource bundle, if any (will generally be null) */
     public static final String RESOURCE_BUNDLE = "resourceBundle"; 
//$NON-NLS-1$
 
@@ -326,7 +329,10 @@ public class GenericTestBeanCustomizer e
         if (deflt == null) {
             if (notNull(pd)) {
                 log.warn(getDetails(pd) + " requires a value but does not 
provide a default.");
-            }            
+            }
+            if (noSaveDefault(pd)) {
+                log.warn(getDetails(pd) + " specifies DEFAULT_NO_SAVE but does 
not provide a default.");                
+            }
         } else {
             final Class<?> defltClass = deflt.getClass(); // the DEFAULT class
             // Convert int to Integer etc:
@@ -451,6 +457,17 @@ public class GenericTestBeanCustomizer e
     }
 
     /**
+     * Returns true if the property default value is not saved
+     * 
+     * @param descriptor the property descriptor
+     * @return true if the attribute {@link #DEFAULT_NOT_SAVED} is defined and 
equal to Boolean.TRUE;
+     *  otherwise the default is false
+     */
+    static boolean noSaveDefault(PropertyDescriptor descriptor) {
+        return Boolean.TRUE.equals(descriptor.getValue(DEFAULT_NOT_SAVED));
+    }
+
+    /**
      * Set the value of the i-th property, properly reporting a possible
      * failure.
      *

Modified: jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java?rev=1735765&r1=1735764&r2=1735765&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java 
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java Sat 
Mar 19 12:15:58 2016
@@ -249,12 +249,22 @@ public TestElement createTestElement() {
             log.debug("Modify " + name + " to " + value);
             if (value == null) {
                 if (GenericTestBeanCustomizer.notNull(desc)) { // cannot be 
null
-                    setPropertyInElement(element, name, 
desc.getValue(GenericTestBeanCustomizer.DEFAULT));
+                    if (GenericTestBeanCustomizer.noSaveDefault(desc)) {
+                        log.debug("Did not set DEFAULT for " + name);
+                        element.removeProperty(name);
+                    } else {
+                        setPropertyInElement(element, name, 
desc.getValue(GenericTestBeanCustomizer.DEFAULT));
+                    }
                 } else {
                     element.removeProperty(name);
                 }
             } else {
-                setPropertyInElement(element, name, value);
+                if (GenericTestBeanCustomizer.noSaveDefault(desc) && 
value.equals(desc.getValue(GenericTestBeanCustomizer.DEFAULT))) {
+                    log.debug("Did not set " + name + " to the default: " + 
value);
+                    element.removeProperty(name);
+                } else {
+                    setPropertyInElement(element, name, value);
+                }
             }
         }
     }

Modified: 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java?rev=1735765&r1=1735764&r2=1735765&view=diff
==============================================================================
--- 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java
 (original)
+++ 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSamplerBeanInfo.java
 Sat Mar 19 12:15:58 2016
@@ -84,6 +84,7 @@ public class AccessLogSamplerBeanInfo ex
             p = property("protocol"); // $NON-NLS-1$
             p.setValue(NOT_UNDEFINED, Boolean.TRUE);
             p.setValue(DEFAULT, "http"); // $NON-NLS-1$
+            p.setValue(DEFAULT_NOT_SAVED, Boolean.TRUE);
 
             p = property("portString"); // $NON-NLS-1$
             p.setValue(NOT_UNDEFINED, Boolean.TRUE);


Reply via email to