Author: sebb
Date: Tue Nov 27 18:20:23 2007
New Revision: 598853
URL: http://svn.apache.org/viewvc?rev=598853&view=rev
Log:
Bug 43382 - configure Tidy output (warnings, errors) for XPath Assertion and
Post-Processor
Added:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/TidyException.java
(with props)
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java?rev=598853&r1=598852&r2=598853&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
Tue Nov 27 18:20:23 2007
@@ -29,6 +29,7 @@
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.testelement.property.StringProperty;
+import org.apache.jmeter.util.TidyException;
import org.apache.jmeter.util.XPathUtil;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@@ -49,17 +50,17 @@
// private static XPathAPI xpath = null;
- private static final String XPATH_KEY = "XPath.xpath";
-
- private static final String WHITESPACE_KEY = "XPath.whitespace";
-
- private static final String VALIDATE_KEY = "XPath.validate";
-
- private static final String TOLERANT_KEY = "XPath.tolerant";
-
- private static final String NEGATE_KEY = "XPath.negate";
-
- private static final String NAMESPACE_KEY = "XPath.namespace";
+ //+ JMX file attributes
+ private static final String XPATH_KEY = "XPath.xpath"; //
$NON-NLS-1$
+ private static final String WHITESPACE_KEY = "XPath.whitespace"; //
$NON-NLS-1$
+ private static final String VALIDATE_KEY = "XPath.validate"; //
$NON-NLS-1$
+ private static final String TOLERANT_KEY = "XPath.tolerant"; //
$NON-NLS-1$
+ private static final String NEGATE_KEY = "XPath.negate"; //
$NON-NLS-1$
+ private static final String NAMESPACE_KEY = "XPath.namespace"; //
$NON-NLS-1$
+ private static final String QUIET_KEY = "XPath.quiet"; //
$NON-NLS-1$
+ private static final String REPORT_ERRORS_KEY = "XPath.report_errors";
// $NON-NLS-1$
+ private static final String SHOW_WARNINGS_KEY = "XPath.show_warnings";
// $NON-NLS-1$
+ //- JMX file attributes
public static final String DEFAULT_XPATH = "/";
@@ -88,7 +89,7 @@
try {
doc = XPathUtil.makeDocument(new
ByteArrayInputStream(responseData), isValidating(),
- isWhitespace(), isNamespace(),
isTolerant());
+ isWhitespace(), isNamespace(),
isTolerant(), isQuiet(), showWarnings() , reportErrors());
} catch (SAXException e) {
log.debug("Caught sax exception: " + e);
result.setError(true);
@@ -105,6 +106,10 @@
result.setFailureMessage(new
StringBuffer("ParserConfigurationException: ").append(e.getMessage())
.toString());
return result;
+ } catch (TidyException e) {
+ result.setError(true);
+ result.setFailureMessage(e.getMessage());
+ return result;
}
if (doc == null || doc.getDocumentElement() == null) {
@@ -266,4 +271,27 @@
return getPropertyAsBoolean(NEGATE_KEY, false);
}
+ public void setReportErrors(boolean val) {
+ setProperty(REPORT_ERRORS_KEY, val, false);
+ }
+
+ public boolean reportErrors() {
+ return getPropertyAsBoolean(REPORT_ERRORS_KEY, false);
+ }
+
+ public void setShowWarnings(boolean val) {
+ setProperty(SHOW_WARNINGS_KEY, val, false);
+ }
+
+ public boolean showWarnings() {
+ return getPropertyAsBoolean(SHOW_WARNINGS_KEY, false);
+ }
+
+ public void setQuiet(boolean val) {
+ setProperty(QUIET_KEY, val, true);
+ }
+
+ public boolean isQuiet() {
+ return getPropertyAsBoolean(QUIET_KEY, true);
+ }
}
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java?rev=598853&r1=598852&r2=598853&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java
Tue Nov 27 18:20:23 2007
@@ -21,15 +21,23 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
import javax.swing.JCheckBox;
-import javax.swing.JFrame;
import javax.swing.JPanel;
+import org.apache.jmeter.assertions.XPathAssertion;
import org.apache.jmeter.util.JMeterUtils;
public class XMLConfPanel extends JPanel {
private JCheckBox validate, tolerant, whitespace, namespace;
+ private JCheckBox quiet; // Should Tidy be quiet?
+
+ private JCheckBox reportErrors; // Report Tidy errors as Assertion
failure?
+
+ private JCheckBox showWarnings; // Show Tidy warnings ?
+
/**
*
*/
@@ -47,7 +55,16 @@
}
private void init() {
- add(getTolerant());
+ Box tidyOptions = Box.createHorizontalBox();
+ tidyOptions.setBorder(BorderFactory.createEtchedBorder());
+ tidyOptions.add(getTolerant());
+ quiet = new
JCheckBox(JMeterUtils.getResString("xpath_tidy_quiet"),true);//$NON-NLS-1$
+ reportErrors = new
JCheckBox(JMeterUtils.getResString("xpath_tidy_report_errors"),true);//$NON-NLS-1$
+ showWarnings = new
JCheckBox(JMeterUtils.getResString("xpath_tidy_show_warnings"),true);//$NON-NLS-1$
+ tidyOptions.add(quiet);
+ tidyOptions.add(reportErrors);
+ tidyOptions.add(showWarnings);
+ add(tidyOptions);
add(getNamespace());
add(getValidate());
add(getWhitespace());
@@ -59,12 +76,16 @@
setValidate(false);
setTolerant(false);
setNamespace(false);
+ quiet.setSelected(true);
+ reportErrors.setSelected(false);
+ showWarnings.setSelected(false);
+ tolerant();
}
/**
* @return Returns the namespace.
*/
- public JCheckBox getNamespace() {
+ private JCheckBox getNamespace() {
if (namespace == null) {
namespace = new
JCheckBox(JMeterUtils.getResString("xml_namespace_button")); //$NON-NLS-1$
}
@@ -74,7 +95,7 @@
/**
* @return Returns the tolerant.
*/
- public JCheckBox getTolerant() {
+ private JCheckBox getTolerant() {
if (tolerant == null) {
tolerant = new
JCheckBox(JMeterUtils.getResString("xml_tolerant_button")); //$NON-NLS-1$
tolerant.addActionListener(new ActionListener() {
@@ -90,7 +111,7 @@
/**
* @return Returns the validate.
*/
- public JCheckBox getValidate() {
+ private JCheckBox getValidate() {
if (validate == null) {
validate = new
JCheckBox(JMeterUtils.getResString("xml_validate_button")); //$NON-NLS-1$
}
@@ -100,64 +121,74 @@
/**
* @return Returns the whitespace.
*/
- public JCheckBox getWhitespace() {
+ private JCheckBox getWhitespace() {
if (whitespace == null) {
whitespace = new
JCheckBox(JMeterUtils.getResString("xml_whitespace_button")); //$NON-NLS-1$
}
return whitespace;
}
- public boolean isNamespace() {
+ private boolean isNamespace() {
return getNamespace().isSelected();
}
- public void setNamespace(boolean namespace) {
+ private void setNamespace(boolean namespace) {
getNamespace().setSelected(namespace);
}
- public boolean isTolerant() {
+ private boolean isTolerant() {
return getTolerant().isSelected();
}
- public void setTolerant(boolean tolerant) {
+ private void setTolerant(boolean tolerant) {
getTolerant().setSelected(tolerant);
}
- public boolean isWhitespace() {
+ private boolean isWhitespace() {
return getWhitespace().isSelected();
}
- public void setWhitespace(boolean whitespace) {
+ private void setWhitespace(boolean whitespace) {
getWhitespace().setSelected(whitespace);
}
- public boolean isValidate() {
+ private boolean isValidate() {
return getValidate().isSelected();
}
- public void setValidate(boolean validating) {
+ private void setValidate(boolean validating) {
getValidate().setSelected(validating);
}
private void tolerant() {
- getValidate().setEnabled(!isTolerant());
- getWhitespace().setEnabled(!isTolerant());
- getNamespace().setEnabled(!isTolerant());
- }
-
- public static void main(String[] args) {
- JPanel comb = new JPanel();
-
- XMLConfPanel xml = new XMLConfPanel();
- XPathPanel xpath = new XPathPanel();
- JFrame frame = new JFrame(xml.getClass().getName());
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- comb.add(xpath);
- comb.add(xml);
- frame.add(comb);
-
- frame.pack();
- frame.setVisible(true);
-
+ final boolean isTolerant = isTolerant();
+ getValidate().setEnabled(!isTolerant);
+ getWhitespace().setEnabled(!isTolerant);
+ getNamespace().setEnabled(!isTolerant);
+ quiet.setEnabled(isTolerant);
+ reportErrors.setEnabled(isTolerant);
+ showWarnings.setEnabled(isTolerant);
+ }
+
+ // Called by XPathAssertionGui
+ public void modifyTestElement(XPathAssertion assertion) {
+ assertion.setValidating(isValidate());
+ assertion.setWhitespace(isWhitespace());
+ assertion.setTolerant(isTolerant());
+ assertion.setNamespace(isNamespace());
+ assertion.setShowWarnings(showWarnings.isSelected());
+ assertion.setReportErrors(reportErrors.isSelected());
+ assertion.setQuiet(quiet.isSelected());
+ }
+
+ // Called by XPathAssertionGui
+ public void configure(XPathAssertion assertion) {
+ setWhitespace(assertion.isWhitespace());
+ setValidate(assertion.isValidating());
+ setTolerant(assertion.isTolerant());
+ setNamespace(assertion.isNamespace());
+ quiet.setSelected(assertion.isQuiet());
+ showWarnings.setSelected(assertion.showWarnings());
+ reportErrors.setSelected(assertion.reportErrors());
}
}
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java?rev=598853&r1=598852&r2=598853&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathAssertionGui.java
Tue Nov 27 18:20:23 2007
@@ -64,11 +64,7 @@
xpath.setXPath(assertion.getXPathString());
xpath.setNegated(assertion.isNegated());
- xml.setWhitespace(assertion.isWhitespace());
- xml.setValidate(assertion.isValidating());
- xml.setTolerant(assertion.isTolerant());
- xml.setNamespace(assertion.isNamespace());
-
+ xml.configure(assertion);
}
private void init() {
@@ -102,12 +98,9 @@
super.configureTestElement(el);
if (el instanceof XPathAssertion) {
XPathAssertion assertion = (XPathAssertion) el;
- assertion.setValidating(xml.isValidate());
- assertion.setWhitespace(xml.isWhitespace());
- assertion.setTolerant(xml.isTolerant());
- assertion.setNamespace(xml.isNamespace());
assertion.setNegated(xpath.isNegated());
assertion.setXPathString(xpath.getXPath());
+ xml.modifyTestElement(assertion);
}
}
@@ -121,5 +114,6 @@
xpath.setNegated(false);
xml.setDefaultValues();
+
}
}
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=598853&r1=598852&r2=598853&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
Tue Nov 27 18:20:23 2007
@@ -25,12 +25,14 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
+import org.apache.jmeter.assertions.AssertionResult;
import org.apache.jmeter.processor.PostProcessor;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterVariables;
+import org.apache.jmeter.util.TidyException;
import org.apache.jmeter.util.XPathUtil;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.util.JMeterError;
@@ -67,12 +69,17 @@
PostProcessor, Serializable {
private static final Logger log = LoggingManager.getLoggerForClass();
private static final String MATCH_NR = "matchNr"; // $NON-NLS-1$
- protected static final String KEY_PREFIX = "XPathExtractor."; //
$NON-NLS-1$
- private static final String XPATH_QUERY = KEY_PREFIX +"xpathQuery"; //
$NON-NLS-1$
- private static final String REFNAME = KEY_PREFIX +"refname"; //
$NON-NLS-1$
- private static final String DEFAULT = KEY_PREFIX +"default"; //
$NON-NLS-1$
- private static final String TOLERANT = KEY_PREFIX +"tolerant"; //
$NON-NLS-1$
- private static final String NAMESPACE = KEY_PREFIX +"namespace"; //
$NON-NLS-1$
+
+ //+ JMX file attributes
+ private static final String XPATH_QUERY =
"XPathExtractor.xpathQuery"; // $NON-NLS-1$
+ private static final String REFNAME = "XPathExtractor.refname";
// $NON-NLS-1$
+ private static final String DEFAULT = "XPathExtractor.default";
// $NON-NLS-1$
+ private static final String TOLERANT =
"XPathExtractor.tolerant"; // $NON-NLS-1$
+ private static final String NAMESPACE =
"XPathExtractor.namespace"; // $NON-NLS-1$
+ private static final String QUIET = "XPathExtractor.quiet";
// $NON-NLS-1$
+ private static final String REPORT_ERRORS =
"XPathExtractor.report_errors"; // $NON-NLS-1$
+ private static final String SHOW_WARNINGS =
"XPathExtractor.show_warnings"; // $NON-NLS-1$
+ //- JMX file attributes
private String concat(String s1,String s2){
@@ -91,29 +98,33 @@
vars.put(refName, getDefaultValue());
vars.put(concat(refName,MATCH_NR), "0"); // In case parse fails //
$NON-NLS-1$
vars.remove(concat(refName,"1")); // In case parse fails // $NON-NLS-1$
+ final SampleResult previousResult = context.getPreviousResult();
try{
- Document d =
parseResponse(context.getPreviousResult());
+ Document d = parseResponse(previousResult);
getValuesForXPath(d,getXPathQuery(),vars, refName);
}catch(IOException e){// Should not happen
- final String errorMessage = "error on
"+XPATH_QUERY+"("+getXPathQuery()+")";
+ final String errorMessage = "error on
("+getXPathQuery()+")";
log.error(errorMessage,e);
throw new JMeterError(errorMessage,e);
} catch (ParserConfigurationException e) {// Should not happen
- final String errrorMessage = "error on
"+XPATH_QUERY+"("+getXPathQuery()+")";
+ final String errrorMessage = "error on
("+getXPathQuery()+")";
log.error(errrorMessage,e);
throw new JMeterError(errrorMessage,e);
} catch (SAXException e) {// Can happen for bad input document
- log.warn("error on
"+XPATH_QUERY+"("+getXPathQuery()+")"+e.getLocalizedMessage());
+ log.warn("error on
("+getXPathQuery()+")"+e.getLocalizedMessage());
} catch (TransformerException e) {// Can happen for incorrect
XPath expression
- log.warn("error on
"+XPATH_QUERY+"("+getXPathQuery()+")"+e.getLocalizedMessage());
+ log.warn("error on
("+getXPathQuery()+")"+e.getLocalizedMessage());
+ } catch (TidyException e) {
+ AssertionResult ass = new
AssertionResult("TidyException"); // $NON-NLS-1$
+ ass.setFailure(true);
+ ass.setFailureMessage(e.getMessage());
+ previousResult.addAssertionResult(ass);
+ previousResult.setSuccessful(false);
}
}
- /**
- * Clone?
- */
- public Object clone() {
+ public Object clone() {
XPathExtractor cloned = (XPathExtractor) super.clone();
return cloned;
}
@@ -159,6 +170,30 @@
return getPropertyAsBoolean(NAMESPACE);
}
+ public void setReportErrors(boolean val) {
+ setProperty(REPORT_ERRORS, val, false);
+ }
+
+ public boolean reportErrors() {
+ return getPropertyAsBoolean(REPORT_ERRORS, false);
+ }
+
+ public void setShowWarnings(boolean val) {
+ setProperty(SHOW_WARNINGS, val, false);
+ }
+
+ public boolean showWarnings() {
+ return getPropertyAsBoolean(SHOW_WARNINGS, false);
+ }
+
+ public void setQuiet(boolean val) {
+ setProperty(QUIET, val, true);
+ }
+
+ public boolean isQuiet() {
+ return getPropertyAsBoolean(QUIET, true);
+ }
+
/*================= internal business =================*/
/**
* Converts (X)HTML response to DOM object Tree.
@@ -168,7 +203,7 @@
*
*/
private Document parseResponse(SampleResult result)
- throws UnsupportedEncodingException, IOException,
ParserConfigurationException,SAXException
+ throws UnsupportedEncodingException, IOException,
ParserConfigurationException,SAXException,TidyException
{
//TODO: validate contentType for reasonable types?
@@ -181,7 +216,7 @@
byte[] utf8data = unicodeData.getBytes("UTF-8"); // $NON-NLS-1$
ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
// this method assumes UTF-8 input data
- return
XPathUtil.makeDocument(in,false,false,useNameSpace(),isTolerant());
+ return
XPathUtil.makeDocument(in,false,false,useNameSpace(),isTolerant(),isQuiet(),showWarnings(),reportErrors());
}
/**
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java?rev=598853&r1=598852&r2=598853&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/XPathExtractorGui.java
Tue Nov 27 18:20:23 2007
@@ -21,8 +21,11 @@
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.List;
+import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
@@ -50,6 +53,12 @@
private JCheckBox tolerant; // Should Tidy be run?
+ private JCheckBox quiet; // Should Tidy be quiet?
+
+ private JCheckBox reportErrors; // Report Tidy errors as Assertion
failure?
+
+ private JCheckBox showWarnings; // Show Tidy warnings ?
+
private JCheckBox nameSpace; // Should parser be namespace aware?
// We could perhaps add validate/whitespace options, but they're
probably not necessary for
@@ -71,6 +80,9 @@
defaultField.setText(xpe.getDefaultValue());
refNameField.setText(xpe.getRefName());
tolerant.setSelected(xpe.isTolerant());
+ quiet.setSelected(xpe.isQuiet());
+ showWarnings.setSelected(xpe.showWarnings());
+ reportErrors.setSelected(xpe.reportErrors());
nameSpace.setSelected(xpe.useNameSpace());
}
@@ -93,6 +105,9 @@
xpath.setXPathQuery(xpathQueryField.getText());
xpath.setTolerant(tolerant.isSelected());
xpath.setNameSpace(nameSpace.isSelected());
+ xpath.setShowWarnings(showWarnings.isSelected());
+ xpath.setReportErrors(reportErrors.isSelected());
+ xpath.setQuiet(quiet.isSelected());
}
}
@@ -107,6 +122,15 @@
refNameField.setText(""); // $NON-NLS-1$
tolerant.setSelected(false);
nameSpace.setSelected(true);
+ quiet.setSelected(true);
+ reportErrors.setSelected(false);
+ showWarnings.setSelected(false);
+ }
+
+ private void setTidyOptions(boolean selected){
+ quiet.setEnabled(selected);
+ reportErrors.setEnabled(selected);
+ showWarnings.setEnabled(selected);
}
private void init() {
@@ -117,8 +141,26 @@
box.add(makeTitlePanel());
Box options = Box.createHorizontalBox();
tolerant = new
JCheckBox(JMeterUtils.getResString("xpath_extractor_tolerant"));//$NON-NLS-1$
+ quiet = new
JCheckBox(JMeterUtils.getResString("xpath_tidy_quiet"),true);//$NON-NLS-1$
+ reportErrors = new
JCheckBox(JMeterUtils.getResString("xpath_tidy_report_errors"),true);//$NON-NLS-1$
+ showWarnings = new
JCheckBox(JMeterUtils.getResString("xpath_tidy_show_warnings"),true);//$NON-NLS-1$
nameSpace = new
JCheckBox(JMeterUtils.getResString("xpath_extractor_namespace"),true);//$NON-NLS-1$
- options.add(tolerant);
+
+ tolerant.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setTidyOptions(tolerant.isSelected());
+ }});
+
+ setTidyOptions(tolerant.isSelected());
+
+ Box tidyOptions = Box.createHorizontalBox();
+ tidyOptions.add(tolerant);
+ tidyOptions.add(quiet);
+ tidyOptions.add(reportErrors);
+ tidyOptions.add(showWarnings);
+ tidyOptions.setBorder(BorderFactory.createEtchedBorder());
+ options.add(tidyOptions);
options.add(nameSpace);
box.add(options);
add(box, BorderLayout.NORTH);
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=598853&r1=598852&r2=598853&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
Tue Nov 27 18:20:23 2007
@@ -862,6 +862,9 @@
xpath_extractor_title=XPath Extractor
xpath_extractor_tolerant=Use Tidy ?
xpath_file_file_name=XML file to get values from
+xpath_tidy_quiet=Quiet
+xpath_tidy_report_errors=Report errors
+xpath_tidy_show_warnings=Show warnings
you_must_enter_a_valid_number=You must enter a valid number
zh_cn=Chinese (Simplified)
zh_tw=Chinese (Traditional)
Added: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/TidyException.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/TidyException.java?rev=598853&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/TidyException.java
(added)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/TidyException.java Tue
Nov 27 18:20:23 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.util;
+
+/**
+ * Class for reporting errors when running Tidy.
+ */
+public class TidyException extends Exception {
+
+ TidyException() {
+ this(0,0);
+ }
+
+ public TidyException(int errors, int warnings){
+ super("tidy: " + errors + " errors, " + warnings + " warnings");
+ }
+}
Propchange:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/TidyException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/TidyException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java?rev=598853&r1=598852&r2=598853&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java Tue Nov
27 18:20:23 2007
@@ -20,6 +20,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -34,7 +36,6 @@
import org.xml.sax.SAXParseException;
/**
- * author Justin Spears [EMAIL PROTECTED]
*
* This class provides a few utility methods for dealing with XML/XPath. Might
* think about creating an interface for the setup, but, works fine now...
@@ -107,12 +108,36 @@
* @throws ParserConfigurationException
* @throws IOException
* @throws SAXException
+ * @throws TidyException
*/
public static Document makeDocument(InputStream stream, boolean
validate, boolean whitespace, boolean namespace,
- boolean tolerant) throws ParserConfigurationException,
SAXException, IOException {
+ boolean tolerant) throws ParserConfigurationException,
SAXException, IOException, TidyException {
+ return makeDocument(stream, validate, whitespace, namespace,
tolerant, true, false, false);
+
+ }
+
+ /**
+ *
+ * @param stream - Document Input stream
+ * @param validate - Validate Document
+ * @param whitespace - Element Whitespace
+ * @param namespace - Is Namespace aware.
+ * @param tolerant - Is tolerant - i.e. use the Tidy parser
+ * @param quiet -
+ * @param showWarnings -
+ * @param report_errors -
+ * @return document
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ * @throws TidyException
+ */
+ public static Document makeDocument(InputStream stream, boolean
validate, boolean whitespace, boolean namespace,
+ boolean tolerant, boolean quiet, boolean showWarnings,
boolean report_errors)
+ throws ParserConfigurationException, SAXException, IOException,
TidyException {
Document doc;
if (tolerant) {
- doc = tidyDoc(stream);
+ doc = tidyDoc(stream, quiet, showWarnings,
report_errors);
// doc=makeTolerantDocumentBuilder().parse(new
// InputStreamReader(stream));
} else {
@@ -129,24 +154,34 @@
// return builder;
// }
- private static Document tidyDoc(InputStream stream) {
- Document doc = null;
- doc = makeTidyParser().parseDOM(stream, null);
+ private static Document tidyDoc(InputStream stream, boolean quiet,
boolean showWarnings, boolean report_errors)
+ throws TidyException {
+ Tidy tidy = makeTidyParser(quiet, showWarnings);
+ StringWriter sw = null;
+ if (report_errors) {
+ sw = new StringWriter();
+ tidy.setErrout(new PrintWriter(sw));
+ }
+ Document doc = tidy.parseDOM(stream, null);
doc.normalize();
// remove the document declaration cause I think it causes
// issues this is only needed for JDOM, since I am not
// using it... But in case we change.
// Node name = doc.getDoctype();
// doc.removeChild(name);
+ if (sw != null && tidy.getParseErrors() > 0) {
+ log.error("Caught TidyException: " + sw.toString());
+ throw new
TidyException(tidy.getParseErrors(),tidy.getParseWarnings());
+ }
return doc;
}
- private static Tidy makeTidyParser() {
+ private static Tidy makeTidyParser(boolean quiet, boolean showWarnings)
{
Tidy tidy = new Tidy();
tidy.setCharEncoding(org.w3c.tidy.Configuration.UTF8);
- tidy.setQuiet(true);
- tidy.setShowWarnings(false);
+ tidy.setQuiet(quiet);
+ tidy.setShowWarnings(showWarnings);
tidy.setMakeClean(true);
tidy.setXmlTags(false); // Input is not valid XML
// tidy.setShowErrors(1);
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=598853&r1=598852&r2=598853&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Nov 27 18:20:23 2007
@@ -45,6 +45,7 @@
<ul>
<li>CSV files can now handle fields with embedded delimiters.</li>
<li>longSum() function added</li>
+<li>Bug 43382 - configure Tidy output (warnings, errors) for XPath Assertion
and Post-Processor</li>
</ul>
<h4>Non-functional changes</h4>
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=598853&r1=598852&r2=598853&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Nov 27
18:20:23 2007
@@ -2618,7 +2618,10 @@
<properties>
<property name="Name" required="No">Descriptive name for this element
that is shown in the tree.</property>
-<property name="Tolerant Parser" required="No">Be tolerant of XML/HTML
errors</property>
+<property name="Tolerant Parser" required="Yes">Be tolerant of XML/HTML
errors (i.e. use Tidy)</property>
+<property name="Quiet" required="If tolerant is selected">Sets the Tidy Quiet
flag</property>
+<property name="Report Errors" required="If tolerant is selected">If a Tidy
error occurs, then set the Assertion accordingly</property>
+<property name="Show warnings" required="If tolerant is selected">Sets the
Tidy showWarnings option</property>
<property name="Use Namespaces" required="No">Should namespaces be
honoured?</property>
<property name="Validate XML" required="No">Check the document against its
schema.</property>
<property name="XPath Assertion" required="Yes">XPath to match
in the document.</property>
@@ -3113,6 +3116,9 @@
<li>"Use Tidy" should be unchecked for both XHTML or XML
response (for example RSS)</li>
</ul>
</property>
+ <property name="Quiet" required="If Tidy is selected">Sets the Tidy
Quiet flag</property>
+ <property name="Report Errors" required="If Tidy is selected">If a
Tidy error occurs, then add an Assertion showing the details</property>
+ <property name="Show warnings" required="If Tidy is selected">Sets the
Tidy showWarnings option</property>
<property name="Use Namespace?" required="Yes">
If checked, then the XML parser will use namespace resolution.
Note that currently only namespaces declared on the root element will
be recognised.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]