Author: sebb
Date: Sat Nov 14 21:52:31 2009
New Revision: 836270

URL: http://svn.apache.org/viewvc?rev=836270&view=rev
Log:
Bug 47907 - Improvements (enhancements and I18N) Comparison Assertion and 
Comparison Visualizer

Modified:
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertionBeanInfo.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ComparisonVisualizer.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/TreeNodeRenderer.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/CompareAssertionResult.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java
 Sat Nov 14 21:52:31 2009
@@ -40,7 +40,7 @@
     
        private transient List<SampleResult> responses;
 
-       private transient final StringSubstitution emptySub = new 
StringSubstitution("");
+       private transient final StringSubstitution emptySub = new 
StringSubstitution(""); //$NON-NLS-1$
 
        private boolean compareContent = true;
 
@@ -80,13 +80,14 @@
                                        result.setFailure(true);
                     StringBuilder buf = new StringBuilder();
                     appendResultDetails(buf, prevResult);
-                    buf.append("Response Time: ").append(prevTime);
+                    
buf.append(JMeterUtils.getResString("comparison_response_time")).append(prevTime);
                                        result.addToBaseResult(buf.toString());
                                        buf = new StringBuilder();
                     appendResultDetails(buf, sResult);
-                                       buf.append("Response Time: 
").append(currentTime);
+                    
buf.append(JMeterUtils.getResString("comparison_response_time")).append(currentTime);
                                        
result.addToSecondaryResult(buf.toString());
-                                       result.setFailureMessage("Responses 
differ in response time by more than "+compareTime+" ms");
+                   
result.setFailureMessage(JMeterUtils.getResString("comparison_differ_time") 
//$NON-NLS-1$
+                           
+compareTime+JMeterUtils.getResString("comparison_unit")); //$NON-NLS-1$
                                        break;
                                }
                                prevResult = sResult;
@@ -118,7 +119,7 @@
                                        appendResultDetails(buf, sResult);
                                        buf.append(currentContent);
                                        
result.addToSecondaryResult(buf.toString());
-                                       result.setFailureMessage("Responses 
differ in content");
+                                       
result.setFailureMessage(JMeterUtils.getResString("comparison_differ_content"));
 //$NON-NLS-1$
                                        break;
                                }
                                prevResult = sResult;
@@ -132,12 +133,12 @@
         if (samplerData != null){
             buf.append(samplerData.trim());
         }
-        buf.append("\n");
+        buf.append("\n"); //$NON-NLS-1$
         final String requestHeaders = result.getRequestHeaders();
         if (requestHeaders != null){
             buf.append(requestHeaders);
         }
-        buf.append("\n\n");        
+        buf.append("\n\n"); //$NON-NLS-1$
     }
 
        private String filterString(String content) {

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertionBeanInfo.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertionBeanInfo.java?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertionBeanInfo.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertionBeanInfo.java
 Sat Nov 14 21:52:31 2009
@@ -23,25 +23,28 @@
 
 import org.apache.jmeter.testbeans.BeanInfoSupport;
 import org.apache.jmeter.testbeans.gui.TableEditor;
+import org.apache.jmeter.util.JMeterUtils;
 
 public class CompareAssertionBeanInfo extends BeanInfoSupport {
 
        public CompareAssertionBeanInfo() {
                super(CompareAssertion.class);
-               createPropertyGroup("compareChoices", new String[] { 
"compareContent", "compareTime" });
-               createPropertyGroup("comparison_filters", new 
String[]{"stringsToSkip"});
-               PropertyDescriptor p = property("compareContent");
+               createPropertyGroup("compareChoices", new String[] { 
"compareContent", "compareTime" }); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
+        createPropertyGroup("comparison_filters", new 
String[]{"stringsToSkip"}); //$NON-NLS-1$ $NON-NLS-2$
+        PropertyDescriptor p = property("compareContent"); //$NON-NLS-1$
                p.setValue(NOT_UNDEFINED, Boolean.TRUE);
                p.setValue(DEFAULT, Boolean.TRUE);
                p.setValue(NOT_EXPRESSION, Boolean.TRUE);
-               p = property("compareTime");
+               p = property("compareTime"); //$NON-NLS-1$
                p.setValue(NOT_UNDEFINED, Boolean.TRUE);
                p.setValue(DEFAULT, new Long(-1));
                p.setValue(NOT_EXPRESSION, Boolean.FALSE);      
-               p = property("stringsToSkip");
+               p = property("stringsToSkip"); //$NON-NLS-1$
                p.setPropertyEditorClass(TableEditor.class);
                
p.setValue(TableEditor.CLASSNAME,SubstitutionElement.class.getName());
-               p.setValue(TableEditor.HEADERS,new String[]{"Regex 
String","Substitution"}); // TODO I18n
+               p.setValue(TableEditor.HEADERS,new String[]{
+                       JMeterUtils.getResString("comparison_regex_string"), 
//$NON-NLS-1$
+                       
JMeterUtils.getResString("comparison_regex_substitution")}); //$NON-NLS-1$
                p.setValue(TableEditor.OBJECT_PROPERTIES, // These are the 
names of the get/set methods
                        new String[]{SubstitutionElement.REGEX, 
SubstitutionElement.SUBSTITUTE});
                p.setValue(NOT_UNDEFINED,Boolean.TRUE);

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ComparisonVisualizer.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ComparisonVisualizer.java?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ComparisonVisualizer.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ComparisonVisualizer.java
 Sat Nov 14 21:52:31 2009
@@ -39,6 +39,7 @@
 import org.apache.jmeter.assertions.CompareAssertionResult;
 import org.apache.jmeter.samplers.Clearable;
 import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
 
 public class ComparisonVisualizer extends AbstractVisualizer implements 
Clearable {
@@ -65,7 +66,7 @@
        }
 
        public String getLabelResource() {
-               return "comparison_visualizer_title";
+               return "comparison_visualizer_title"; //$NON-NLS-1$
        }
 
        private void init() {
@@ -92,16 +93,19 @@
 
        private JTextPane getBaseTextPane() {
                base = new JTextPane();
+               base.setEditable(false);
+               base.setBackground(getBackground());
                return base;
        }
 
        private JTextPane getSecondaryTextPane() {
                secondary = new JTextPane();
+               secondary.setEditable(false);
                return secondary;
        }
 
        private JComponent getTreePanel() {
-               root = new DefaultMutableTreeNode("Root");
+               root = new DefaultMutableTreeNode("Root"); //$NON-NLS-1$
                treeModel = new DefaultTreeModel(root);
                resultsTree = new JTree(treeModel);
                resultsTree.setCellRenderer(new TreeNodeRenderer());
@@ -141,8 +145,8 @@
                                base.setText(result.getBaseResult());
                                secondary.setText(result.getSecondaryResult());
                        } catch (Exception err) {
-                               base.setText("Invalid Node " + err);
-                               secondary.setText("Invalid Node " + err);
+                
base.setText(JMeterUtils.getResString("comparison_invalid_node") + err); 
//$NON-NLS-1$
+                
secondary.setText(JMeterUtils.getResString("comparison_invalid_node") + err); 
//$NON-NLS-1$
                        }
                        base.setCaretPosition(0);
                        secondary.setCaretPosition(0);
@@ -155,8 +159,8 @@
                        // the child to be removed will always be 0 'cos as the 
nodes are
                        // removed the nth node will become (n-1)th
                        treeModel.removeNodeFromParent((DefaultMutableTreeNode) 
root.getChildAt(0));
-                       base.setText("");
-                       secondary.setText("");
+            base.setText(""); //$NON-NLS-1$
+            secondary.setText(""); //$NON-NLS-1$
                }
        }
 

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/TreeNodeRenderer.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/TreeNodeRenderer.java?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/TreeNodeRenderer.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/TreeNodeRenderer.java
 Sat Nov 14 21:52:31 2009
@@ -21,17 +21,30 @@
 import java.awt.Color;
 import java.awt.Component;
 
+import javax.swing.ImageIcon;
 import javax.swing.JTree;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeCellRenderer;
 
 import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
 
 /**
  * Tree cell renderer used by ComparisonVisualizer.
  */
 public class TreeNodeRenderer extends DefaultTreeCellRenderer {
 
+    private static final long serialVersionUID = 240L;
+
+    // Same ViewResultsTree
+    private static final ImageIcon imageSuccess = JMeterUtils.getImage(
+            JMeterUtils.getPropDefault("viewResultsTree.success",  
//$NON-NLS-1$
+                    "icon_success_sml.gif")); //$NON-NLS-1$
+
+    private static final ImageIcon imageFailure = JMeterUtils.getImage(
+            JMeterUtils.getPropDefault("viewResultsTree.failure",  
//$NON-NLS-1$
+                    "icon_warning_sml.gif")); //$NON-NLS-1$
+    
        public TreeNodeRenderer() {
                super();
        }
@@ -45,6 +58,9 @@
                {
                        if (!((SampleResult) obj).isSuccessful()) {
                                this.setForeground(Color.red);
+                this.setIcon(imageFailure);
+            } else {
+                this.setIcon(imageSuccess);
                        }
                }
                return this;

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/CompareAssertionResult.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/CompareAssertionResult.java?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/CompareAssertionResult.java
 (original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/CompareAssertionResult.java
 Sat Nov 14 21:52:31 2009
@@ -75,7 +75,7 @@
                        }
                        else
                        {
-                               baseResult = baseResult + "\n\n" + r;
+                               baseResult = baseResult + "\n\n" + r; 
//$NON-NLS-1$
                        }
                }
                
@@ -87,7 +87,7 @@
                        }
                        else
                        {
-                               secondaryResult = secondaryResult + "\n\n" + r;
+                               secondaryResult = secondaryResult + "\n\n" + r; 
//$NON-NLS-1$
                        }
                }
        }

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties 
(original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties 
Sat Nov 14 21:52:31 2009
@@ -127,6 +127,13 @@
 column_number=Column number of CSV file | next | *alias
 compare=Compare
 comparefilt=Compare filter
+comparison_differ_content=Responses differ in content
+comparison_differ_time=Responses differ in response time by more than 
+comparison_invalid_node=Invalid Node 
+comparison_regex_string=Regex String
+comparison_regex_substitution=Substitution
+comparison_response_time=Response Time: 
+comparison_unit=\ ms
 comparison_visualizer_title=Comparison Assertion Visualizer
 config_element=Config Element
 config_save_settings=Configure

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Nov 14 21:52:31 2009
@@ -133,8 +133,9 @@
 <li>Bug 47398 - SampleEvents are sent twice over RMI in distributed testing 
and non gui mode</li>
 <li>Added DataStrippingSample sender - supports "Stripped" and "StrippedBatch" 
modes.</li>
 <li>Added Comparison Assertion Visualizer</li>
+<li>Bug 47907 - Improvements (enhancements and I18N) Comparison Assertion and 
Comparison Visualizer</li>
 <li>Bug 36726 - add search function to Tree View Listener</li>
-<li>Bug 47869 -  Ability to cleanup fields of SampleResult</li>
+<li>Bug 47869 - Ability to cleanup fields of SampleResult</li>
 <li>Bug 47952 - Added JSR223 Listener</li>
 </ul>
 

Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=836270&r1=836269&r2=836270&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Sat Nov 14 
21:52:31 2009
@@ -3440,8 +3440,8 @@
 <properties>
     <property name="Name" required="No">Descriptive name for this element that 
is shown in the tree.</property>
     <property name="Compare Content" required="Yes">Whether or not to compare 
the content (response data)</property>
-    <property name="Compare Time" required="Yes">If the value is >=0, then 
check if the time difference is no greater than the value. 
-    I.e. if the value is 0, then the times must be exactly equal.</property>
+    <property name="Compare Time" required="Yes">If the value is >=0, then 
check if the response time difference is no greater than the value. 
+    I.e. if the value is 0, then the response times must be exactly 
equal.</property>
     <property name="Comparison Filters" required="No">Filters can be used to 
remove strings from the content comparison.
     For example, if the page has a time-stamp, it might be matched with: 
"Time: \d\d:\d\d:\d\d" and replaced with a dummy fixed time "Time: HH:MM:SS".
     </property>



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscr...@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-h...@jakarta.apache.org

Reply via email to