Author: sebb
Date: Wed Mar  5 17:16:31 2008
New Revision: 634106

URL: http://svn.apache.org/viewvc?rev=634106&view=rev
Log:
Sort the JMeter variables

Modified:
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java?rev=634106&r1=634105&r2=634106&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java 
(original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java 
Wed Mar  5 17:16:31 2008
@@ -23,7 +23,6 @@
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 
 import org.apache.jmeter.samplers.AbstractSampler;
@@ -31,17 +30,16 @@
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.testbeans.TestBean;
 import org.apache.jmeter.threads.JMeterContextService;
-import org.apache.jmeter.threads.JMeterVariables;
 import org.apache.jmeter.util.JMeterUtils;
 
 /**
- * This TestBean is just an example about how to write testbeans. The intent is
- * to demonstrate usage of the TestBean features to podential TestBean
- * developers. Note that only the class's introspector view matters: the 
methods
- * do nothing -- nothing useful, in any case.
+ * The Debug Sampler can be used to "sample" JMeter variables, JMeter 
properties and System Properties.
+ * 
  */
 public class DebugSampler extends AbstractSampler implements TestBean {
     
+    private static final long serialVersionUID = 232L;
+    
        private boolean displayJMeterVariables;
        
        private boolean displayJMeterProperties;
@@ -57,29 +55,21 @@
         if (isDisplayJMeterVariables()){
                rd.append("JMeterVariables\n");
                sb.append("JMeterVariables:\n");
-               JMeterVariables vars = 
JMeterContextService.getContext().getVariables();
-               Iterator i = vars.getIterator();
-               while(i.hasNext())
-               {
-                 Map.Entry me = (Map.Entry) i.next();
-                  if(String.class.equals(me.getValue().getClass())){
-                        sb.append(me.toString()).append("\n");
-                  }
-               }
+               formatSet(sb, 
JMeterContextService.getContext().getVariables().entrySet());
                sb.append("\n");
         }
         
         if (isDisplayJMeterProperties()){
                rd.append("JMeterProperties\n");
                sb.append("JMeterProperties:\n");
-                   formatProperties(sb, JMeterUtils.getJMeterProperties());    
        
+               formatSet(sb, JMeterUtils.getJMeterProperties().entrySet());    
        
                sb.append("\n");
         }
         
         if (isDisplaySystemProperties()){
                rd.append("SystemProperties\n");
                sb.append("SystemProperties:\n");
-                   formatProperties(sb, System.getProperties());               
                
+               formatSet(sb, System.getProperties().entrySet());               
                
                sb.append("\n");
         }
         
@@ -91,8 +81,7 @@
         return res;
        }
 
-       private void formatProperties(StringBuffer sb, Properties p) {
-               Set s = p.entrySet();
+       private void formatSet(StringBuffer sb, Set s) {
                ArrayList al = new ArrayList(s);
                Collections.sort(al, new Comparator(){
                        public int compare(Object o1, Object o2) {
@@ -112,7 +101,7 @@
                }
        }
 
-       public boolean isDisplayJMeterVariables() {
+    public boolean isDisplayJMeterVariables() {
                return displayJMeterVariables;
        }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to