View | Details | Raw Unified | Return to bug 47907
Collapse All | Expand All

(-)/src/components/org/apache/jmeter/assertions/CompareAssertion.java (-7 / +8 lines)
Lines 40-46 Link Here
40
    
40
    
41
	private transient List<SampleResult> responses;
41
	private transient List<SampleResult> responses;
42
42
43
	private transient final StringSubstitution emptySub = new StringSubstitution("");
43
	private transient final StringSubstitution emptySub = new StringSubstitution(""); //$NON-NLS-1$
44
44
45
	private boolean compareContent = true;
45
	private boolean compareContent = true;
46
46
Lines 80-92 Link Here
80
					result.setFailure(true);
80
					result.setFailure(true);
81
                    StringBuffer buf = new StringBuffer();
81
                    StringBuffer buf = new StringBuffer();
82
                    appendResultDetails(buf, prevResult);
82
                    appendResultDetails(buf, prevResult);
83
                    buf.append("Response Time: ").append(prevTime);
83
                    buf.append(JMeterUtils.getResString("comparison_response_time")).append(prevTime); //$NON-NLS-1$
84
					result.addToBaseResult(buf.toString());
84
					result.addToBaseResult(buf.toString());
85
					buf = new StringBuffer();
85
					buf = new StringBuffer();
86
                    appendResultDetails(buf, sResult);
86
                    appendResultDetails(buf, sResult);
87
					buf.append("Response Time: ").append(currentTime);
87
					buf.append(JMeterUtils.getResString("comparison_response_time")).append(currentTime); //$NON-NLS-1$
88
					result.addToSecondaryResult(buf.toString());
88
					result.addToSecondaryResult(buf.toString());
89
					result.setFailureMessage("Responses differ in response time by more than "+compareTime+" ms");
89
					result.setFailureMessage(JMeterUtils.getResString("comparison_differ_time") //$NON-NLS-1$
90
					        +compareTime+JMeterUtils.getResString("comparison_unit")); //$NON-NLS-1$
90
					break;
91
					break;
91
				}
92
				}
92
				prevResult = sResult;
93
				prevResult = sResult;
Lines 118-124 Link Here
118
					appendResultDetails(buf, sResult);
119
					appendResultDetails(buf, sResult);
119
					buf.append(currentContent);
120
					buf.append(currentContent);
120
					result.addToSecondaryResult(buf.toString());
121
					result.addToSecondaryResult(buf.toString());
121
					result.setFailureMessage("Responses differ in content");
122
					result.setFailureMessage(JMeterUtils.getResString("comparison_differ_content")); //$NON-NLS-1$
122
					break;
123
					break;
123
				}
124
				}
124
				prevResult = sResult;
125
				prevResult = sResult;
Lines 132-138 Link Here
132
        if (samplerData != null){
133
        if (samplerData != null){
133
            buf.append(samplerData.trim());
134
            buf.append(samplerData.trim());
134
        }
135
        }
135
        buf.append("\n");
136
        buf.append("\n"); //$NON-NLS-1$
136
        final String requestHeaders = result.getRequestHeaders();
137
        final String requestHeaders = result.getRequestHeaders();
137
        if (requestHeaders != null){
138
        if (requestHeaders != null){
138
            buf.append(requestHeaders);
139
            buf.append(requestHeaders);
Lines 137-143 Link Here
137
        if (requestHeaders != null){
138
        if (requestHeaders != null){
138
            buf.append(requestHeaders);
139
            buf.append(requestHeaders);
139
        }
140
        }
140
        buf.append("\n\n");        
141
        buf.append("\n\n"); //$NON-NLS-1$
141
    }
142
    }
142
143
143
	private String filterString(String content) {
144
	private String filterString(String content) {
(-)/src/components/org/apache/jmeter/assertions/CompareAssertionBeanInfo.java (-6 / +9 lines)
Lines 23-28 Link Here
23
23
24
import org.apache.jmeter.testbeans.BeanInfoSupport;
24
import org.apache.jmeter.testbeans.BeanInfoSupport;
25
import org.apache.jmeter.testbeans.gui.TableEditor;
25
import org.apache.jmeter.testbeans.gui.TableEditor;
26
import org.apache.jmeter.util.JMeterUtils;
26
27
27
public class CompareAssertionBeanInfo extends BeanInfoSupport {
28
public class CompareAssertionBeanInfo extends BeanInfoSupport {
28
29
Lines 28-47 Link Here
28
29
29
	public CompareAssertionBeanInfo() {
30
	public CompareAssertionBeanInfo() {
30
		super(CompareAssertion.class);
31
		super(CompareAssertion.class);
31
		createPropertyGroup("compareChoices", new String[] { "compareContent", "compareTime" });
32
		createPropertyGroup("compareChoices", new String[] { "compareContent", "compareTime" }); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
32
		createPropertyGroup("comparison_filters", new String[]{"stringsToSkip"});
33
		createPropertyGroup("comparison_filters", new String[]{"stringsToSkip"}); //$NON-NLS-1$ $NON-NLS-2$
33
		PropertyDescriptor p = property("compareContent");
34
		PropertyDescriptor p = property("compareContent"); //$NON-NLS-1$
34
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
35
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
35
		p.setValue(DEFAULT, Boolean.TRUE);
36
		p.setValue(DEFAULT, Boolean.TRUE);
36
		p.setValue(NOT_EXPRESSION, Boolean.TRUE);
37
		p.setValue(NOT_EXPRESSION, Boolean.TRUE);
37
		p = property("compareTime");
38
		p = property("compareTime"); //$NON-NLS-1$
38
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
39
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
39
		p.setValue(DEFAULT, new Long(-1));
40
		p.setValue(DEFAULT, new Long(-1));
40
		p.setValue(NOT_EXPRESSION, Boolean.FALSE);	
41
		p.setValue(NOT_EXPRESSION, Boolean.FALSE);	
41
		p = property("stringsToSkip");
42
		p = property("stringsToSkip"); //$NON-NLS-1$
42
		p.setPropertyEditorClass(TableEditor.class);
43
		p.setPropertyEditorClass(TableEditor.class);
43
		p.setValue(TableEditor.CLASSNAME,SubstitutionElement.class.getName());
44
		p.setValue(TableEditor.CLASSNAME,SubstitutionElement.class.getName());
44
		p.setValue(TableEditor.HEADERS,new String[]{"Regex String","Substitution"}); // TODO I18n
45
		p.setValue(TableEditor.HEADERS,new String[]{
46
		        JMeterUtils.getResString("comparison_regex_string"), //$NON-NLS-1$
47
		        JMeterUtils.getResString("comparison_regex_substitution")}); //$NON-NLS-1$
45
		p.setValue(TableEditor.OBJECT_PROPERTIES, // These are the names of the get/set methods
48
		p.setValue(TableEditor.OBJECT_PROPERTIES, // These are the names of the get/set methods
46
		        new String[]{SubstitutionElement.REGEX, SubstitutionElement.SUBSTITUTE});
49
		        new String[]{SubstitutionElement.REGEX, SubstitutionElement.SUBSTITUTE});
47
		p.setValue(NOT_UNDEFINED,Boolean.TRUE);
50
		p.setValue(NOT_UNDEFINED,Boolean.TRUE);
(-)/src/components/org/apache/jmeter/visualizers/ComparisonVisualizer.java (-6 / +10 lines)
Lines 39-44 Link Here
39
import org.apache.jmeter.assertions.CompareAssertionResult;
39
import org.apache.jmeter.assertions.CompareAssertionResult;
40
import org.apache.jmeter.samplers.Clearable;
40
import org.apache.jmeter.samplers.Clearable;
41
import org.apache.jmeter.samplers.SampleResult;
41
import org.apache.jmeter.samplers.SampleResult;
42
import org.apache.jmeter.util.JMeterUtils;
42
import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
43
import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
43
44
44
public class ComparisonVisualizer extends AbstractVisualizer implements Clearable {
45
public class ComparisonVisualizer extends AbstractVisualizer implements Clearable {
Lines 65-71 Link Here
65
	}
66
	}
66
67
67
	public String getLabelResource() {
68
	public String getLabelResource() {
68
		return "comparison_visualizer_title";
69
		return "comparison_visualizer_title"; //$NON-NLS-1$
69
	}
70
	}
70
71
71
	private void init() {
72
	private void init() {
Lines 92-97 Link Here
92
93
93
	private JTextPane getBaseTextPane() {
94
	private JTextPane getBaseTextPane() {
94
		base = new JTextPane();
95
		base = new JTextPane();
96
		base.setEditable(false);
97
		base.setBackground(getBackground());
95
		return base;
98
		return base;
96
	}
99
	}
97
100
Lines 97-102 Link Here
97
100
98
	private JTextPane getSecondaryTextPane() {
101
	private JTextPane getSecondaryTextPane() {
99
		secondary = new JTextPane();
102
		secondary = new JTextPane();
103
		secondary.setEditable(false);
100
		return secondary;
104
		return secondary;
101
	}
105
	}
102
106
Lines 101-107 Link Here
101
	}
105
	}
102
106
103
	private JComponent getTreePanel() {
107
	private JComponent getTreePanel() {
104
		root = new DefaultMutableTreeNode("Root");
108
		root = new DefaultMutableTreeNode("Root"); //$NON-NLS-1$
105
		treeModel = new DefaultTreeModel(root);
109
		treeModel = new DefaultTreeModel(root);
106
		resultsTree = new JTree(treeModel);
110
		resultsTree = new JTree(treeModel);
107
		resultsTree.setCellRenderer(new TreeNodeRenderer());
111
		resultsTree.setCellRenderer(new TreeNodeRenderer());
Lines 141-148 Link Here
141
				base.setText(result.getBaseResult());
145
				base.setText(result.getBaseResult());
142
				secondary.setText(result.getSecondaryResult());
146
				secondary.setText(result.getSecondaryResult());
143
			} catch (Exception err) {
147
			} catch (Exception err) {
144
				base.setText("Invalid Node " + err);
148
				base.setText(JMeterUtils.getResString("comparison_invalid_node") + err); //$NON-NLS-1$
145
				secondary.setText("Invalid Node " + err);
149
				secondary.setText(JMeterUtils.getResString("comparison_invalid_node") + err); //$NON-NLS-1$
146
			}
150
			}
147
			base.setCaretPosition(0);
151
			base.setCaretPosition(0);
148
			secondary.setCaretPosition(0);
152
			secondary.setCaretPosition(0);
Lines 155-162 Link Here
155
			// the child to be removed will always be 0 'cos as the nodes are
159
			// the child to be removed will always be 0 'cos as the nodes are
156
			// removed the nth node will become (n-1)th
160
			// removed the nth node will become (n-1)th
157
			treeModel.removeNodeFromParent((DefaultMutableTreeNode) root.getChildAt(0));
161
			treeModel.removeNodeFromParent((DefaultMutableTreeNode) root.getChildAt(0));
158
			base.setText("");
162
			base.setText(""); //$NON-NLS-1$
159
			secondary.setText("");
163
			secondary.setText(""); //$NON-NLS-1$
160
		}
164
		}
161
	}
165
	}
162
166
(-)/src/components/org/apache/jmeter/visualizers/TreeNodeRenderer.java (+16 lines)
Lines 21-26 Link Here
21
import java.awt.Color;
21
import java.awt.Color;
22
import java.awt.Component;
22
import java.awt.Component;
23
23
24
import javax.swing.ImageIcon;
24
import javax.swing.JTree;
25
import javax.swing.JTree;
25
import javax.swing.tree.DefaultMutableTreeNode;
26
import javax.swing.tree.DefaultMutableTreeNode;
26
import javax.swing.tree.DefaultTreeCellRenderer;
27
import javax.swing.tree.DefaultTreeCellRenderer;
Lines 26-31 Link Here
26
import javax.swing.tree.DefaultTreeCellRenderer;
27
import javax.swing.tree.DefaultTreeCellRenderer;
27
28
28
import org.apache.jmeter.samplers.SampleResult;
29
import org.apache.jmeter.samplers.SampleResult;
30
import org.apache.jmeter.util.JMeterUtils;
29
31
30
/**
32
/**
31
 * Tree cell renderer used by ComparisonVisualizer.
33
 * Tree cell renderer used by ComparisonVisualizer.
Lines 32-37 Link Here
32
 */
34
 */
33
public class TreeNodeRenderer extends DefaultTreeCellRenderer {
35
public class TreeNodeRenderer extends DefaultTreeCellRenderer {
34
36
37
    private static final long serialVersionUID = 240L;
38
39
    // Same ViewResultsTree
40
    private static final ImageIcon imageSuccess = JMeterUtils.getImage(
41
            JMeterUtils.getPropDefault("viewResultsTree.success",  //$NON-NLS-1$
42
                    "icon_success_sml.gif")); //$NON-NLS-1$
43
44
    private static final ImageIcon imageFailure = JMeterUtils.getImage(
45
            JMeterUtils.getPropDefault("viewResultsTree.failure",  //$NON-NLS-1$
46
                    "icon_warning_sml.gif")); //$NON-NLS-1$
47
    
35
	public TreeNodeRenderer() {
48
	public TreeNodeRenderer() {
36
		super();
49
		super();
37
	}
50
	}
Lines 45-50 Link Here
45
		{
58
		{
46
			if (!((SampleResult) obj).isSuccessful()) {
59
			if (!((SampleResult) obj).isSuccessful()) {
47
				this.setForeground(Color.red);
60
				this.setForeground(Color.red);
61
                this.setIcon(imageFailure);
62
            } else {
63
                this.setIcon(imageSuccess);
48
			}
64
			}
49
		}
65
		}
50
		return this;
66
		return this;
(-)/src/core/org/apache/jmeter/assertions/CompareAssertionResult.java (-2 / +2 lines)
Lines 75-81 Link Here
75
			}
75
			}
76
			else
76
			else
77
			{
77
			{
78
				baseResult = baseResult + "\n\n" + r;
78
				baseResult = baseResult + "\n\n" + r; //$NON-NLS-1$
79
			}
79
			}
80
		}
80
		}
81
		
81
		
Lines 87-93 Link Here
87
			}
87
			}
88
			else
88
			else
89
			{
89
			{
90
				secondaryResult = secondaryResult + "\n\n" + r;
90
				secondaryResult = secondaryResult + "\n\n" + r; //$NON-NLS-1$
91
			}
91
			}
92
		}
92
		}
93
	}
93
	}
(-)/src/core/org/apache/jmeter/resources/messages.properties (+7 lines)
Lines 127-132 Link Here
127
column_number=Column number of CSV file | next | *alias
127
column_number=Column number of CSV file | next | *alias
128
compare=Compare
128
compare=Compare
129
comparefilt=Compare filter
129
comparefilt=Compare filter
130
comparison_differ_content=Responses differ in content
131
comparison_differ_time=Responses differ in response time by more than 
132
comparison_invalid_node=Invalid Node 
133
comparison_regex_string=Regex String
134
comparison_regex_substitution=Substitution
135
comparison_response_time=Response Time: 
136
comparison_unit=\ ms
130
comparison_visualizer_title=Comparison Assertion Visualizer
137
comparison_visualizer_title=Comparison Assertion Visualizer
131
config_element=Config Element
138
config_element=Config Element
132
config_save_settings=Configure
139
config_save_settings=Configure
(-)/xdocs/usermanual/component_reference.xml (-2 / +2 lines)
Lines 3413-3420 Link Here
3413
<properties>
3413
<properties>
3414
    <property name="Name" required="No">Descriptive name for this element that is shown in the tree.</property>
3414
    <property name="Name" required="No">Descriptive name for this element that is shown in the tree.</property>
3415
    <property name="Compare Content" required="Yes">Whether or not to compare the content (response data)</property>
3415
    <property name="Compare Content" required="Yes">Whether or not to compare the content (response data)</property>
3416
    <property name="Compare Time" required="Yes">If the value is >=0, then check if the time difference is no greater than the value. 
3416
    <property name="Compare Time" required="Yes">If the value is >=0, then check if the response time difference is no greater than the value. 
3417
    I.e. if the value is 0, then the times must be exactly equal.</property>
3417
    I.e. if the value is 0, then the response times must be exactly equal.</property>
3418
    <property name="Comparison Filters" required="No">Filters can be used to remove strings from the content comparison.
3418
    <property name="Comparison Filters" required="No">Filters can be used to remove strings from the content comparison.
3419
    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".
3419
    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".
3420
    </property>
3420
    </property>

Return to bug 47907