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

(-)src/components/org/apache/jmeter/assertions/XPathAssertion.java (-8 / +16 lines)
Lines 25-31 Link Here
25
import javax.xml.parsers.ParserConfigurationException;
25
import javax.xml.parsers.ParserConfigurationException;
26
26
27
import org.apache.jmeter.samplers.SampleResult;
27
import org.apache.jmeter.samplers.SampleResult;
28
import org.apache.jmeter.testelement.AbstractTestElement;
28
import org.apache.jmeter.testelement.AbstractScopedAssertion;
29
import org.apache.jmeter.testelement.property.BooleanProperty;
29
import org.apache.jmeter.testelement.property.BooleanProperty;
30
import org.apache.jmeter.testelement.property.StringProperty;
30
import org.apache.jmeter.testelement.property.StringProperty;
31
import org.apache.jmeter.util.TidyException;
31
import org.apache.jmeter.util.TidyException;
Lines 41-47 Link Here
41
 * XPath
41
 * XPath
42
 *
42
 *
43
 */
43
 */
44
public class XPathAssertion extends AbstractTestElement implements Serializable, Assertion {
44
public class XPathAssertion extends AbstractScopedAssertion implements Serializable, Assertion {
45
    private static final Logger log = LoggingManager.getLoggerForClass();
45
    private static final Logger log = LoggingManager.getLoggerForClass();
46
46
47
    private static final long serialVersionUID = 240L;
47
    private static final long serialVersionUID = 240L;
Lines 66-81 Link Here
66
     * XML, and that the XPath expression is matched (or not, as the case may
66
     * XML, and that the XPath expression is matched (or not, as the case may
67
     * be)
67
     * be)
68
     */
68
     */
69
    
69
    public AssertionResult getResult(SampleResult response) {
70
    public AssertionResult getResult(SampleResult response) {
70
        // no error as default
71
        // no error as default
71
        AssertionResult result = new AssertionResult(getName());
72
        AssertionResult result = new AssertionResult(getName());
72
        byte[] responseData = response.getResponseData();
73
        byte[] responseData = null;
74
        result.setFailure(false);
75
        result.setFailureMessage("");
76
        
77
        // Ask if it is ScopeVariable        
78
        if (isScopeVariable()){
79
        	responseData = getThreadContext().getVariables().get(getVariableName()).getBytes();
80
        } else {
81
            responseData = response.getResponseData();
82
        }                
83
73
        if (responseData.length == 0) {
84
        if (responseData.length == 0) {
74
            return result.setResultForNull();
85
            return result.setResultForNull();
75
        }
86
        }
76
        result.setFailure(false);
87
        
77
        result.setFailureMessage("");
78
79
        if (log.isDebugEnabled()) {
88
        if (log.isDebugEnabled()) {
80
            log.debug(new StringBuilder("Validation is set to ").append(isValidating()).toString());
89
            log.debug(new StringBuilder("Validation is set to ").append(isValidating()).toString());
81
            log.debug(new StringBuilder("Whitespace is set to ").append(isWhitespace()).toString());
90
            log.debug(new StringBuilder("Whitespace is set to ").append(isWhitespace()).toString());
Lines 120-126 Link Here
120
        XPathUtil.computeAssertionResult(result, doc, getXPathString(), isNegated());
129
        XPathUtil.computeAssertionResult(result, doc, getXPathString(), isNegated());
121
        return result;
130
        return result;
122
    }
131
    }
123
132
    
124
    /**
133
    /**
125
     * Get The XPath String that will be used in matching the document
134
     * Get The XPath String that will be used in matching the document
126
     *
135
     *
Lines 257-261 Link Here
257
    public boolean isDownloadDTDs() {
266
    public boolean isDownloadDTDs() {
258
        return getPropertyAsBoolean(DOWNLOAD_DTDS, false);
267
        return getPropertyAsBoolean(DOWNLOAD_DTDS, false);
259
    }
268
    }
260
261
}
269
}
(-)src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java (-1 / +11 lines)
Lines 21-26 Link Here
21
import java.awt.BorderLayout;
21
import java.awt.BorderLayout;
22
22
23
import javax.swing.BorderFactory;
23
import javax.swing.BorderFactory;
24
import javax.swing.Box;
24
import javax.swing.JPanel;
25
import javax.swing.JPanel;
25
26
26
import org.apache.jmeter.assertions.XPathAssertion;
27
import org.apache.jmeter.assertions.XPathAssertion;
Lines 64-69 Link Here
64
    public void configure(TestElement el) {
65
    public void configure(TestElement el) {
65
        super.configure(el);
66
        super.configure(el);
66
        XPathAssertion assertion = (XPathAssertion) el;
67
        XPathAssertion assertion = (XPathAssertion) el;
68
        
69
        showScopeSettings(assertion, true);
70
        
67
        xpath.setXPath(assertion.getXPathString());
71
        xpath.setXPath(assertion.getXPathString());
68
        xpath.setNegated(assertion.isNegated());
72
        xpath.setNegated(assertion.isNegated());
69
73
Lines 75-81 Link Here
75
        setBorder(makeBorder());
79
        setBorder(makeBorder());
76
80
77
        add(makeTitlePanel());
81
        add(makeTitlePanel());
78
82
        Box box = Box.createVerticalBox();
83
        box.add(createScopePanel(true));
84
        add(box, BorderLayout.NORTH);
85
        
79
        // USER_INPUT
86
        // USER_INPUT
80
        JPanel sizePanel = new JPanel(new BorderLayout());
87
        JPanel sizePanel = new JPanel(new BorderLayout());
81
        sizePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
88
        sizePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
Lines 100-106 Link Here
100
    public void modifyTestElement(TestElement el) {
107
    public void modifyTestElement(TestElement el) {
101
        super.configureTestElement(el);
108
        super.configureTestElement(el);
102
        if (el instanceof XPathAssertion) {
109
        if (el instanceof XPathAssertion) {
110
        	
103
            XPathAssertion assertion = (XPathAssertion) el;
111
            XPathAssertion assertion = (XPathAssertion) el;
112
            saveScopeSettings(assertion);
113
104
            assertion.setNegated(xpath.isNegated());
114
            assertion.setNegated(xpath.isNegated());
105
            assertion.setXPathString(xpath.getXPath());
115
            assertion.setXPathString(xpath.getXPath());
106
            xml.modifyTestElement(assertion);
116
            xml.modifyTestElement(assertion);

Return to bug 54160