Author: sebb
Date: Mon Jun 29 01:55:03 2009
New Revision: 789187
URL: http://svn.apache.org/viewvc?rev=789187&view=rev
Log:
Bug 47338 - XPath Extractor forces retrieval of document DTD
Modified:
jakarta/jmeter/trunk/docs/images/screenshots/xpath_assertion.png
jakarta/jmeter/trunk/docs/images/screenshots/xpath_extractor.png
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/XPathPanel.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/resources/messages_fr.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pl.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pt_BR.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_tr.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/images/screenshots/xpath_assertion.png
jakarta/jmeter/trunk/xdocs/images/screenshots/xpath_extractor.png
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jakarta/jmeter/trunk/docs/images/screenshots/xpath_assertion.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/xpath_assertion.png?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/docs/images/screenshots/xpath_extractor.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/xpath_extractor.png?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
Binary files - no diff available.
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=789187&r1=789186&r2=789187&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
Mon Jun 29 01:55:03 2009
@@ -60,6 +60,7 @@
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$
+ private static final String DOWNLOAD_DTDS = "XPath.download_dtds"; //
$NON-NLS-1$
//- JMX file attributes
public static final String DEFAULT_XPATH = "/";
@@ -91,7 +92,8 @@
try {
doc = XPathUtil.makeDocument(new
ByteArrayInputStream(responseData), isValidating(),
- isWhitespace(), isNamespace(), isTolerant(), isQuiet(),
showWarnings() , reportErrors(), isXML);
+ isWhitespace(), isNamespace(), isTolerant(), isQuiet(),
showWarnings() , reportErrors(), isXML
+ , isDownloadDTDs());
} catch (SAXException e) {
log.debug("Caught sax exception: " + e);
result.setError(true);
@@ -298,4 +300,13 @@
public boolean isQuiet() {
return getPropertyAsBoolean(QUIET_KEY, true);
}
+
+ public void setDownloadDTDs(boolean val) {
+ setProperty(DOWNLOAD_DTDS, val, false);
+ }
+
+ public boolean isDownloadDTDs() {
+ return getPropertyAsBoolean(DOWNLOAD_DTDS, false);
+ }
+
}
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=789187&r1=789186&r2=789187&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
Mon Jun 29 01:55:03 2009
@@ -27,6 +27,7 @@
import javax.swing.JPanel;
import org.apache.jmeter.assertions.XPathAssertion;
+import org.apache.jmeter.extractor.XPathExtractor;
import org.apache.jmeter.util.JMeterUtils;
public class XMLConfPanel extends JPanel {
@@ -37,6 +38,8 @@
private JCheckBox reportErrors; // Report Tidy errors as Assertion failure?
private JCheckBox showWarnings; // Show Tidy warnings ?
+
+ private JCheckBox downloadDTDs; // Should we download external DTDs?
/**
*
@@ -46,125 +49,62 @@
init();
}
- /**
- * @param isDoubleBuffered
- */
- public XMLConfPanel(boolean isDoubleBuffered) {
- super(isDoubleBuffered);
- init();
- }
-
private void init() {
- 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$
+ namespace = new
JCheckBox(JMeterUtils.getResString("xml_namespace_button")); //$NON-NLS-1$
+ whitespace = new
JCheckBox(JMeterUtils.getResString("xml_whitespace_button")); //$NON-NLS-1$
+ validate = new
JCheckBox(JMeterUtils.getResString("xml_validate_button")); //$NON-NLS-1$
+ validate.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ tolerant();
+ }
+ });
+ tolerant = new
JCheckBox(JMeterUtils.getResString("xml_tolerant_button")); //$NON-NLS-1$
+ downloadDTDs = new
JCheckBox(JMeterUtils.getResString("xml_download_dtds")); //$NON-NLS-1$
+ Box tidyOptions = Box.createHorizontalBox();
+ tidyOptions.setBorder(BorderFactory.createEtchedBorder());
+ tidyOptions.add(tolerant);
tidyOptions.add(quiet);
tidyOptions.add(reportErrors);
tidyOptions.add(showWarnings);
- add(tidyOptions);
- add(getNamespace());
- add(getValidate());
- add(getWhitespace());
+
+ Box untidyOptions = Box.createHorizontalBox();
+ untidyOptions.setBorder(BorderFactory.createEtchedBorder());
+ untidyOptions.add(namespace);
+ untidyOptions.add(validate);
+ untidyOptions.add(whitespace);
+ untidyOptions.add(downloadDTDs);
+
+ Box options = Box.createVerticalBox();
+ options.add(tidyOptions);
+ options.add(untidyOptions);
+ add(options);
setDefaultValues();
}
public void setDefaultValues() {
- setWhitespace(false);
- setValidate(false);
- setTolerant(false);
- setNamespace(false);
+ whitespace.setSelected(false);
+ validate.setSelected(false);
+ tolerant.setSelected(false);
+ namespace.setSelected(false);
quiet.setSelected(true);
reportErrors.setSelected(false);
showWarnings.setSelected(false);
+ downloadDTDs.setSelected(false);
tolerant();
}
- /**
- * @return Returns the namespace.
- */
- private JCheckBox getNamespace() {
- if (namespace == null) {
- namespace = new
JCheckBox(JMeterUtils.getResString("xml_namespace_button")); //$NON-NLS-1$
- }
- return namespace;
- }
-
- /**
- * @return Returns the tolerant.
- */
- private JCheckBox getTolerant() {
- if (tolerant == null) {
- tolerant = new
JCheckBox(JMeterUtils.getResString("xml_tolerant_button")); //$NON-NLS-1$
- tolerant.addActionListener(new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- tolerant();
- }
- });
- }
- return tolerant;
- }
-
- /**
- * @return Returns the validate.
- */
- private JCheckBox getValidate() {
- if (validate == null) {
- validate = new
JCheckBox(JMeterUtils.getResString("xml_validate_button")); //$NON-NLS-1$
- }
- return validate;
- }
-
- /**
- * @return Returns the whitespace.
- */
- private JCheckBox getWhitespace() {
- if (whitespace == null) {
- whitespace = new
JCheckBox(JMeterUtils.getResString("xml_whitespace_button")); //$NON-NLS-1$
- }
- return whitespace;
- }
-
- private boolean isNamespace() {
- return getNamespace().isSelected();
- }
-
- private void setNamespace(boolean namespace) {
- getNamespace().setSelected(namespace);
- }
-
- private boolean isTolerant() {
- return getTolerant().isSelected();
- }
-
- private void setTolerant(boolean tolerant) {
- getTolerant().setSelected(tolerant);
- }
-
- private boolean isWhitespace() {
- return getWhitespace().isSelected();
- }
-
- private void setWhitespace(boolean whitespace) {
- getWhitespace().setSelected(whitespace);
- }
-
- private boolean isValidate() {
- return getValidate().isSelected();
- }
-
- private void setValidate(boolean validating) {
- getValidate().setSelected(validating);
- }
-
+ // Process tolerant settings
private void tolerant() {
- final boolean isTolerant = isTolerant();
- getValidate().setEnabled(!isTolerant);
- getWhitespace().setEnabled(!isTolerant);
- getNamespace().setEnabled(!isTolerant);
+ final boolean isTolerant = tolerant.isSelected();
+ // Non-Tidy options
+ validate.setEnabled(!isTolerant);
+ whitespace.setEnabled(!isTolerant);
+ namespace.setEnabled(!isTolerant);
+ downloadDTDs.setEnabled(!isTolerant);
+ // Tidy options
quiet.setEnabled(isTolerant);
reportErrors.setEnabled(isTolerant);
showWarnings.setEnabled(isTolerant);
@@ -172,24 +112,51 @@
// Called by XPathAssertionGui
public void modifyTestElement(XPathAssertion assertion) {
- assertion.setValidating(isValidate());
- assertion.setWhitespace(isWhitespace());
- assertion.setTolerant(isTolerant());
- assertion.setNamespace(isNamespace());
+ assertion.setValidating(validate.isSelected());
+ assertion.setWhitespace(whitespace.isSelected());
+ assertion.setTolerant(tolerant.isSelected());
+ assertion.setNamespace(namespace.isSelected());
+ assertion.setShowWarnings(showWarnings.isSelected());
+ assertion.setReportErrors(reportErrors.isSelected());
+ assertion.setQuiet(quiet.isSelected());
+ assertion.setDownloadDTDs(downloadDTDs.isSelected());
+ }
+
+ // Called by XPathExtractorGui
+ public void modifyTestElement(XPathExtractor assertion) {
+ assertion.setValidating(validate.isSelected());
+ assertion.setWhitespace(whitespace.isSelected());
+ assertion.setTolerant(tolerant.isSelected());
+ assertion.setNameSpace(namespace.isSelected());
assertion.setShowWarnings(showWarnings.isSelected());
assertion.setReportErrors(reportErrors.isSelected());
- assertion.setQuiet(quiet.isSelected());
+ assertion.setQuiet(quiet.isSelected());
+ assertion.setDownloadDTDs(downloadDTDs.isSelected());
}
// Called by XPathAssertionGui
public void configure(XPathAssertion assertion) {
- setWhitespace(assertion.isWhitespace());
- setValidate(assertion.isValidating());
- setTolerant(assertion.isTolerant());
- setNamespace(assertion.isNamespace());
+ whitespace.setSelected(assertion.isWhitespace());
+ validate.setSelected(assertion.isValidating());
+ tolerant.setSelected(assertion.isTolerant());
+ namespace.setSelected(assertion.isNamespace());
+ quiet.setSelected(assertion.isQuiet());
+ showWarnings.setSelected(assertion.showWarnings());
+ reportErrors.setSelected(assertion.reportErrors());
+ downloadDTDs.setSelected(assertion.isDownloadDTDs());
+ tolerant();
+ }
+
+ // Called by XPathExtractorGui
+ public void configure(XPathExtractor assertion) {
+ whitespace.setSelected(assertion.isWhitespace());
+ validate.setSelected(assertion.isValidating());
+ tolerant.setSelected(assertion.isTolerant());
+ namespace.setSelected(assertion.useNameSpace());
quiet.setSelected(assertion.isQuiet());
showWarnings.setSelected(assertion.showWarnings());
reportErrors.setSelected(assertion.reportErrors());
+ downloadDTDs.setSelected(assertion.isDownloadDTDs());
tolerant();
}
}
Modified:
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
(original)
+++
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
Mon Jun 29 01:55:03 2009
@@ -18,7 +18,6 @@
package org.apache.jmeter.assertions.gui;
-import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -42,6 +41,7 @@
public class XPathPanel extends JPanel {
private static final Logger log = LoggingManager.getLoggerForClass();
+ // Lazily constructed. Does not matter if it is constructed more than once.
private static Document testDoc;
private JCheckBox negated;
@@ -58,31 +58,6 @@
init();
}
- /**
- * @param isDoubleBuffered
- */
- public XPathPanel(boolean isDoubleBuffered) {
- super(isDoubleBuffered);
- init();
- }
-
- /**
- * @param layout
- */
- public XPathPanel(LayoutManager layout) {
- super(layout);
- init();
- }
-
- /**
- * @param layout
- * @param isDoubleBuffered
- */
- public XPathPanel(LayoutManager layout, boolean isDoubleBuffered) {
- super(layout, isDoubleBuffered);
- init();
- }
-
private void init() {
Box hbox = Box.createHorizontalBox();
hbox.add(Box.createHorizontalGlue());
@@ -194,8 +169,8 @@
}
/**
- * Test weather an XPath is valid. It seems the Xalan has no easy way to
- * check, so this creates a test document, then tries to evaluate the
xpath.
+ * Test whether an XPath is valid. It seems the Xalan has no easy way to
+ * check, so this creates a dummy test document, then tries to evaluate
the xpath against it.
*
* @param xpathString
* XPath String to validate
@@ -208,7 +183,7 @@
boolean success = true;
try {
if (testDoc == null) {
- testDoc = XPathUtil.makeDocumentBuilder(false, false,
false).newDocument();
+ testDoc = XPathUtil.makeDocumentBuilder(false, false, false,
false).newDocument();
Element el = testDoc.createElement("root"); //$NON-NLS-1$
testDoc.appendChild(el);
@@ -218,8 +193,8 @@
// because eval will throw an exception
// if xpath is invalid, but whatever, better
// safe
- log.warn("xpath eval was null ");
ret = "xpath eval was null";
+ log.warn(ret+" "+xpathString);
success = false;
}
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=789187&r1=789186&r2=789187&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
Mon Jun 29 01:55:03 2009
@@ -80,6 +80,9 @@
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$
+ private static final String DOWNLOAD_DTDS =
"XPathExtractor.download_dtds"; // $NON-NLS-1$
+ private static final String WHITESPACE = "XPathExtractor.whitespace";
// $NON-NLS-1$
+ private static final String VALIDATE = "XPathExtractor.validate";
// $NON-NLS-1$
//- JMX file attributes
@@ -107,9 +110,9 @@
}catch(IOException e){// e.g. DTD not reachable
final String errorMessage = "IOException on ("+getXPathQuery()+")";
log.error(errorMessage,e);
- AssertionResult ass = new AssertionResult("IOException"); //
$NON-NLS-1$
- ass.setFailure(true);
- ass.setFailureMessage(e.getLocalizedMessage());
+ AssertionResult ass = new AssertionResult(getName());
+ ass.setError(true);
+ ass.setFailureMessage(new StringBuffer("IOException:
").append(e.getLocalizedMessage()).toString());
previousResult.addAssertionResult(ass);
previousResult.setSuccessful(false);
} catch (ParserConfigurationException e) {// Should not happen
@@ -222,7 +225,8 @@
ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
boolean isXML = JOrphanUtils.isXML(utf8data);
// this method assumes UTF-8 input data
- return
XPathUtil.makeDocument(in,false,false,useNameSpace(),isTolerant(),isQuiet(),showWarnings(),reportErrors(),isXML);
+ return
XPathUtil.makeDocument(in,false,false,useNameSpace(),isTolerant(),isQuiet(),showWarnings(),reportErrors()
+ ,isXML, isDownloadDTDs());
}
/**
@@ -274,4 +278,28 @@
vars.remove(concat(refName, "2"));
}
}
+
+ public void setWhitespace(boolean selected) {
+ setProperty(WHITESPACE, selected, false);
+ }
+
+ public boolean isWhitespace() {
+ return getPropertyAsBoolean(WHITESPACE, false);
+ }
+
+ public void setValidating(boolean selected) {
+ setProperty(VALIDATE, selected);
+ }
+
+ public boolean isValidating() {
+ return getPropertyAsBoolean(VALIDATE, false);
+ }
+
+ public void setDownloadDTDs(boolean selected) {
+ setProperty(DOWNLOAD_DTDS, selected, false);
+ }
+
+ public boolean isDownloadDTDs() {
+ return getPropertyAsBoolean(DOWNLOAD_DTDS, false);
+ }
}
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=789187&r1=789186&r2=789187&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
Mon Jun 29 01:55:03 2009
@@ -21,15 +21,13 @@
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;
+import org.apache.jmeter.assertions.gui.XMLConfPanel;
import org.apache.jmeter.extractor.XPathExtractor;
import org.apache.jmeter.processor.gui.AbstractPostProcessorGui;
import org.apache.jmeter.testelement.TestElement;
@@ -39,8 +37,6 @@
* GUI for XPathExtractor class.
*/
/* This file is inspired by RegexExtractor.
- * author <a href="mailto:[email protected]">Henryk Paluch</a>
- * of <a href="http://www.gitus.com">Gitus a.s.</a>
* See Bugzilla: 37183
*/
public class XPathExtractorGui extends AbstractPostProcessorGui {
@@ -51,19 +47,8 @@
private JLabeledTextField refNameField;
- 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
- // the XPathExtractor
-
+ private XMLConfPanel xml;
+
public String getLabelResource() {
return "xpath_extractor_title"; //$NON-NLS-1$
}
@@ -79,12 +64,7 @@
xpathQueryField.setText(xpe.getXPathQuery());
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());
- setTidyOptions(tolerant.isSelected());
+ xml.configure(xpe);
}
@@ -94,9 +74,6 @@
return extractor;
}
- /* (non-Javadoc)
- * @see
org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(org.apache.jmeter.testelement.TestElement)
- */
public void modifyTestElement(TestElement extractor) {
super.configureTestElement(extractor);
if ( extractor instanceof XPathExtractor){
@@ -104,11 +81,7 @@
xpath.setDefaultValue(defaultField.getText());
xpath.setRefName(refNameField.getText());
xpath.setXPathQuery(xpathQueryField.getText());
- xpath.setTolerant(tolerant.isSelected());
- xpath.setNameSpace(nameSpace.isSelected());
- xpath.setShowWarnings(showWarnings.isSelected());
- xpath.setReportErrors(reportErrors.isSelected());
- xpath.setQuiet(quiet.isSelected());
+ xml.modifyTestElement(xpath);
}
}
@@ -121,18 +94,7 @@
xpathQueryField.setText(""); // $NON-NLS-1$
defaultField.setText(""); // $NON-NLS-1$
refNameField.setText(""); // $NON-NLS-1$
- tolerant.setSelected(false);
- nameSpace.setSelected(true);
- quiet.setSelected(true);
- reportErrors.setSelected(false);
- showWarnings.setSelected(false);
- }
-
- private void setTidyOptions(boolean tidySelected){
- quiet.setEnabled(tidySelected);
- reportErrors.setEnabled(tidySelected);
- showWarnings.setEnabled(tidySelected);
- nameSpace.setEnabled(!tidySelected);
+ xml.setDefaultValues();
}
private void init() {
@@ -141,30 +103,10 @@
Box box = Box.createVerticalBox();
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$
-
- 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);
+ xml = new XMLConfPanel();
+
xml.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils
+ .getResString("xpath_assertion_option"))); //$NON-NLS-1$
+ box.add(xml);
add(box, BorderLayout.NORTH);
add(makeParameterPanel(), BorderLayout.CENTER);
}
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=789187&r1=789186&r2=789187&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
Mon Jun 29 01:55:03 2009
@@ -921,8 +921,9 @@
wsdl_url=WSDL URL
wsdl_url_error=The WSDL was emtpy.
xml_assertion_title=XML Assertion
+xml_download_dtds=Fetch external DTDs
xml_namespace_button=Use Namespaces
-xml_tolerant_button=Tolerant XML/HTML Parser
+xml_tolerant_button=Use Tidy (tolerant parser)
xml_validate_button=Validate XML
xml_whitespace_button=Ignore Whitespace
xmlschema_assertion_label=File Name:
@@ -941,10 +942,8 @@
xpath_assertion_validation=Validate the XML against the DTD
xpath_assertion_whitespace=Ignore whitespace
xpath_expression=XPath expression to match against
-xpath_extractor_namespace=Use Namespaces?
xpath_extractor_query=XPath query:
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
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
Mon Jun 29 01:55:03 2009
@@ -786,10 +786,8 @@
xpath_assertion_valid=Expression XPath valide
xpath_assertion_validation=Valider le code XML \u00E0 travers le fichier DTD
xpath_assertion_whitespace=Ignorer les espaces
-xpath_extractor_namespace=Utiliser les espaces de noms ?
xpath_extractor_query=Requ\u00EAte XPath \:
xpath_extractor_title=Extracteur XPath
-xpath_extractor_tolerant=Utiliser Tidy ?
xpath_tidy_quiet=Silencieux
xpath_tidy_report_errors=Rapporter les erreurs
xpath_tidy_show_warnings=Afficher les alertes
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pl.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pl.properties?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pl.properties
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pl.properties
Mon Jun 29 01:55:03 2009
@@ -894,10 +894,8 @@
xpath_assertion_validation=Validate the XML against the DTD
xpath_assertion_whitespace=Ignore whitespace
xpath_expression=XPath expression to match against
-xpath_extractor_namespace=Use Namespaces?
xpath_extractor_query=XPath query:
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
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pt_BR.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pt_BR.properties?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pt_BR.properties
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pt_BR.properties
Mon Jun 29 01:55:03 2009
@@ -940,10 +940,8 @@
xpath_assertion_validation=Validar XML de acordo com DTD
xpath_assertion_whitespace=Ignorar espa\u00E7os em branco
xpath_expression=Express\u00F5es XPath que ser\u00E3o combinadas
-xpath_extractor_namespace=Usar espa\u00E7o de nomes (Namespaces)?
xpath_extractor_query=Consulta XPath
xpath_extractor_title=Extractor XPath
-xpath_extractor_tolerant=Usar Tidy?
xpath_file_file_name=Arquivo XML de onde os valores ser\u00E3o extra\u00EDdos
xpath_tidy_quiet=Quieto
xpath_tidy_report_errors=Reportar erros
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_tr.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_tr.properties?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_tr.properties
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_tr.properties
Mon Jun 29 01:55:03 2009
@@ -875,10 +875,8 @@
xpath_assertion_validation=XML'i DTD'ye g\u00F6re kontrol et
xpath_assertion_whitespace=G\u00F6r\u00FCnmeyen Karakterleri Yoksay
xpath_expression=Kar\u015F\u0131la\u015Ft\u0131r\u0131lacak XPath ifadesi
-xpath_extractor_namespace=Namespace kullan?
xpath_extractor_query=XPath sorgusu\:
xpath_extractor_title=XPath \u00C7\u0131kar\u0131c\u0131
-xpath_extractor_tolerant=D\u00FCzenli kullan ?
xpath_file_file_name=De\u011Ferlerin okunaca\u011F\u0131 XML dosyas\u0131
xpath_tidy_quiet=Sessiz
xpath_tidy_report_errors=Hatalar\u0131 raporla
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=789187&r1=789186&r2=789187&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 Mon Jun
29 01:55:03 2009
@@ -18,6 +18,7 @@
package org.apache.jmeter.util;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
@@ -31,7 +32,9 @@
import org.apache.log.Logger;
import org.w3c.dom.Document;
import org.w3c.tidy.Tidy;
+import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -45,6 +48,7 @@
super();
}
+ //@GuardedBy("this")
private static DocumentBuilderFactory documentBuilderFactory;
/**
@@ -77,71 +81,29 @@
* @param validate should the parser validate documents?
* @param whitespace should the parser eliminate whitespace in element
content?
* @param namespace should the parser be namespace aware?
+ * @param downloadDTDs if true, parser should attempt to resolve external
entities
* @return document builder
* @throws ParserConfigurationException
*/
- public static synchronized DocumentBuilder makeDocumentBuilder(boolean
validate, boolean whitespace, boolean namespace)
+ public static DocumentBuilder makeDocumentBuilder(boolean validate,
boolean whitespace, boolean namespace, boolean downloadDTDs)
throws ParserConfigurationException {
- // N.B. the factory is re-usable, but not necessarily thread-safe, so
- // the method is synchronized to protect the creation of the builder
DocumentBuilder builder = makeDocumentBuilderFactory(validate,
whitespace, namespace).newDocumentBuilder();
builder.setErrorHandler(new MyErrorHandler(validate, false));
+ if (!downloadDTDs){
+ EntityResolver er = new EntityResolver(){
+ public InputSource resolveEntity(String publicId, String
systemId)
+ throws SAXException, IOException {
+ return new InputSource(new ByteArrayInputStream(new
byte[]{}));
+ }
+ };
+ builder.setEntityResolver(er);
+ }
return builder;
}
/**
* Utility function to get new Document
*
- * @param stream
- * Document Input stream
- * @param validate
- * Validate Document (not Tidy)
- * @param whitespace
- * Element Whitespace (not Tidy)
- * @param namespace
- * Is Namespace aware.
- * @param tolerant
- * Is tolerant - i.e. use the Tidy parser
- *
- * @return document
- * @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, TidyException {
- return makeDocument(stream, validate, whitespace, namespace, tolerant,
true, false, false, false);
-
- }
-
- /**
- * Utility function to get new Document
- *
- * @param stream - Document Input stream
- * @param validate - Validate Document (not Tidy)
- * @param whitespace - Element Whitespace (not Tidy)
- * @param namespace - Is Namespace aware. (not Tidy)
- * @param tolerant - Is tolerant - i.e. use the Tidy parser
- * @param quiet - set Tidy quiet
- * @param showWarnings - set Tidy warnings
- * @param report_errors - throw TidyException if Tidy detects an error
- * @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 {
- return makeDocument(stream, validate, whitespace, namespace,
- tolerant, quiet, showWarnings, report_errors, false);
- }
-
- /**
- * Utility function to get new Document
- *
* @param stream - Document Input stream
* @param validate - Validate Document (not Tidy)
* @param whitespace - Element Whitespace (not Tidy)
@@ -151,6 +113,7 @@
* @param showWarnings - set Tidy warnings
* @param report_errors - throw TidyException if Tidy detects an error
* @param isXml - is document already XML (Tidy only)
+ * @param downloadDTDs - if true, try to download external DTDs
* @return document
* @throws ParserConfigurationException
* @throws SAXException
@@ -158,13 +121,13 @@
* @throws TidyException
*/
public static Document makeDocument(InputStream stream, boolean validate,
boolean whitespace, boolean namespace,
- boolean tolerant, boolean quiet, boolean showWarnings, boolean
report_errors, boolean isXml)
+ boolean tolerant, boolean quiet, boolean showWarnings, boolean
report_errors, boolean isXml, boolean downloadDTDs)
throws ParserConfigurationException, SAXException, IOException,
TidyException {
Document doc;
if (tolerant) {
doc = tidyDoc(stream, quiet, showWarnings, report_errors, isXml);
} else {
- doc = makeDocumentBuilder(validate, whitespace,
namespace).parse(stream);
+ doc = makeDocumentBuilder(validate, whitespace, namespace,
downloadDTDs).parse(stream);
}
return doc;
}
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Mon Jun 29 01:55:03 2009
@@ -60,6 +60,7 @@
<h2>Incompatible changes</h2>
<p>
+The XPath Assertion and XPath Extractor elements no longer fetch external DTDs
by default; this can be changed in the GUI.
</p>
<h2>Bug fixes</h2>
@@ -119,6 +120,7 @@
<h3>Assertions, Config, Pre- & Post-Processors</h3>
<ul>
+<li>Bug 47338 - XPath Extractor forces retrieval of document DTD</li>
</ul>
<h3>Functions</h3>
Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/xpath_assertion.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/xpath_assertion.png?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/xpath_extractor.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/xpath_extractor.png?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=789187&r1=789186&r2=789187&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Mon Jun 29
01:55:03 2009
@@ -3326,14 +3326,15 @@
<properties>
<property name="Name" required="No">Descriptive name for this element
that is shown in the tree.</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>
-<property name="Ignore Whitespace" required="No">Ignore Element
Whitespace.</property>
+<property name="Use Tidy (tolerant parser)" required="Yes">Use Tidy, i.e.
be tolerant of XML/HTML errors</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 set the Assertion accordingly</property>
+<property name="Show warnings" required="If Tidy is selected">Sets the Tidy
showWarnings option</property>
+<property name="Use Namespaces" required="If Tidy is not
selected">Should namespaces be honoured?</property>
+<property name="Validate XML" required="If Tidy is not selected">Check the
document against its schema.</property>
+<property name="Ignore Whitespace" required="If Tidy is not selected">Ignore
Element Whitespace.</property>
+<property name="Fetch External DTDs" required="If Tidy is not selected">If
selected, external DTDs are fetched.</property>
+<property name="XPath Assertion" required="Yes">XPath to match in the
document.</property>
<property name="True if nothing matches" required="No">True if a XPath
expression is not matched</property>
</properties>
<note>
@@ -3915,16 +3916,16 @@
</description>
<properties>
<property name="Name" required="No">Descriptive name for this element
that is shown in the tree.</property>
- <property name="Use Tidy" required="Yes">If checked use Tidy to
parse HTML response into XHTML.
+ <property name="Use Tidy (tolerant parser)" required="Yes">If
checked use Tidy to parse HTML response into XHTML.
<ul>
<li>"Use Tidy" should be checked on for HTML response. Such
response is converted to valid XHTML (XML compatible HTML) using Tidy</li>
<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">
+<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 set the Assertion accordingly</property>
+<property name="Show warnings" required="If Tidy is selected">Sets the Tidy
showWarnings option</property>
+<property name="Use Namespaces" required="If Tidy is not selected">
If checked, then the XML parser will use namespace resolution.
Note that currently only namespaces declared on the root element will
be recognised.
A later version of JMeter may support user-definition of additional
workspace names.
@@ -3939,8 +3940,11 @@
where "uri-for-namespace" is the uri for the "mynamespace" namespace.
(not applicable if Tidy is selected)
- </property>
- <property name="Reference Name" required="Yes">The name of the JMeter
variable in which to store the result.</property>
+</property>
+ <property name="Validate XML" required="If Tidy is not selected">Check
the document against its schema.</property>
+ <property name="Ignore Whitespace" required="If Tidy is not
selected">Ignore Element Whitespace.</property>
+ <property name="Fetch External DTDs" required="If Tidy is not
selected">If selected, external DTDs are fetched.</property>
+ <property name="Reference Name" required="Yes">The name of the JMeter
variable in which to store the result.</property>
<property name="XPath Query" required="Yes">Element query in XPath
language. Can return more than one match. </property>
<property name="Default Value" required="">Default value returned when
no match found</property>
</properties>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]