Author: sebb
Date: Thu Jan 21 18:02:20 2010
New Revision: 901805
URL: http://svn.apache.org/viewvc?rev=901805&view=rev
Log:
Better reporting of XPath errors
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java?rev=901805&r1=901804&r2=901805&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java Thu Jan 21 18:02:20 2010
@@ -128,18 +128,27 @@
previousResult.addAssertionResult(ass);
previousResult.setSuccessful(false);
} catch (ParserConfigurationException e) {// Should not happen
- final String errrorMessage = "error on ("+getXPathQuery()+")";
+ final String errrorMessage = "ParserConfigurationException while processing ("+getXPathQuery()+")";
log.error(errrorMessage,e);
throw new JMeterError(errrorMessage,e);
} catch (SAXException e) {// Can happen for bad input document
- log.warn("error on ("+getXPathQuery()+")"+e.getLocalizedMessage());
+ log.warn("SAXException while processing ("+getXPathQuery()+") "+e.getLocalizedMessage());
+ addAssertionFailure(previousResult, e, false); // Should this also fail the sample?
} catch (TransformerException e) {// Can happen for incorrect XPath expression
- log.warn("error on ("+getXPathQuery()+")"+e.getLocalizedMessage());
+ log.warn("TransformerException while processing ("+getXPathQuery()+") "+e.getLocalizedMessage());
+ addAssertionFailure(previousResult, e, false);
} catch (TidyException e) {
- AssertionResult ass = new AssertionResult("TidyException"); // $NON-NLS-1$
- ass.setFailure(true);
- ass.setFailureMessage(e.getLocalizedMessage());
- previousResult.addAssertionResult(ass);
+ addAssertionFailure(previousResult, e, true); // fail the sample
+ }
+ }
+
+ private void addAssertionFailure(final SampleResult previousResult,
+ final Throwable thrown, final boolean setFailed) {
+ AssertionResult ass = new AssertionResult(thrown.getClass().getSimpleName()); // $NON-NLS-1$
+ ass.setFailure(true);
+ ass.setFailureMessage(getXPathQuery()+" => "+thrown.getLocalizedMessage());
+ previousResult.addAssertionResult(ass);
+ if (setFailed){
previousResult.setSuccessful(false);
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.