ASF Bugzilla – Attachment 29611 Details for
Bug 54160
Add support for xpath assertion to apply to a JMeter variable.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add support to xpath assertion in order to apply to
Add support to xpath assertion in order to apply to.txt (text/plain), 4.21 KB, created by
Germán Bisogno
on 2012-11-19 23:00:51 UTC
(
hide
)
Description:
Add support to xpath assertion in order to apply to
Filename:
MIME Type:
Creator:
Germán Bisogno
Created:
2012-11-19 23:00:51 UTC
Size:
4.21 KB
patch
obsolete
>Index: src/components/org/apache/jmeter/assertions/XPathAssertion.java >=================================================================== >--- src/components/org/apache/jmeter/assertions/XPathAssertion.java (revision 1410725) >+++ src/components/org/apache/jmeter/assertions/XPathAssertion.java (working copy) >@@ -25,7 +25,7 @@ > import javax.xml.parsers.ParserConfigurationException; > > import org.apache.jmeter.samplers.SampleResult; >-import org.apache.jmeter.testelement.AbstractTestElement; >+import org.apache.jmeter.testelement.AbstractScopedAssertion; > import org.apache.jmeter.testelement.property.BooleanProperty; > import org.apache.jmeter.testelement.property.StringProperty; > import org.apache.jmeter.util.TidyException; >@@ -41,7 +41,7 @@ > * XPath > * > */ >-public class XPathAssertion extends AbstractTestElement implements Serializable, Assertion { >+public class XPathAssertion extends AbstractScopedAssertion implements Serializable, Assertion { > private static final Logger log = LoggingManager.getLoggerForClass(); > > private static final long serialVersionUID = 240L; >@@ -66,16 +66,25 @@ > * XML, and that the XPath expression is matched (or not, as the case may > * be) > */ >+ > public AssertionResult getResult(SampleResult response) { > // no error as default > AssertionResult result = new AssertionResult(getName()); >- byte[] responseData = response.getResponseData(); >+ byte[] responseData = null; >+ result.setFailure(false); >+ result.setFailureMessage(""); >+ >+ // Ask if it is ScopeVariable >+ if (isScopeVariable()){ >+ responseData = getThreadContext().getVariables().get(getVariableName()).getBytes(); >+ } else { >+ responseData = response.getResponseData(); >+ } >+ > if (responseData.length == 0) { > return result.setResultForNull(); > } >- result.setFailure(false); >- result.setFailureMessage(""); >- >+ > if (log.isDebugEnabled()) { > log.debug(new StringBuilder("Validation is set to ").append(isValidating()).toString()); > log.debug(new StringBuilder("Whitespace is set to ").append(isWhitespace()).toString()); >@@ -120,7 +129,7 @@ > XPathUtil.computeAssertionResult(result, doc, getXPathString(), isNegated()); > return result; > } >- >+ > /** > * Get The XPath String that will be used in matching the document > * >@@ -257,5 +266,4 @@ > public boolean isDownloadDTDs() { > return getPropertyAsBoolean(DOWNLOAD_DTDS, false); > } >- > } >Index: src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java >=================================================================== >--- src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java (revision 1410725) >+++ src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java (working copy) >@@ -21,6 +21,7 @@ > import java.awt.BorderLayout; > > import javax.swing.BorderFactory; >+import javax.swing.Box; > import javax.swing.JPanel; > > import org.apache.jmeter.assertions.XPathAssertion; >@@ -64,6 +65,9 @@ > public void configure(TestElement el) { > super.configure(el); > XPathAssertion assertion = (XPathAssertion) el; >+ >+ showScopeSettings(assertion, true); >+ > xpath.setXPath(assertion.getXPathString()); > xpath.setNegated(assertion.isNegated()); > >@@ -75,7 +79,10 @@ > setBorder(makeBorder()); > > add(makeTitlePanel()); >- >+ Box box = Box.createVerticalBox(); >+ box.add(createScopePanel(true)); >+ add(box, BorderLayout.NORTH); >+ > // USER_INPUT > JPanel sizePanel = new JPanel(new BorderLayout()); > sizePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); >@@ -100,7 +107,10 @@ > public void modifyTestElement(TestElement el) { > super.configureTestElement(el); > if (el instanceof XPathAssertion) { >+ > XPathAssertion assertion = (XPathAssertion) el; >+ saveScopeSettings(assertion); >+ > assertion.setNegated(xpath.isNegated()); > assertion.setXPathString(xpath.getXPath()); > xml.modifyTestElement(assertion);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 54160
: 29611