This is an automated email from the ASF dual-hosted git repository.

pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 6907711  Bug 64150 - View Results Tree: Allow editing of response data 
in testers
6907711 is described below

commit 6907711f77404bebedd98a0b9b71f8a92833613d
Author: pmouawad <p.moua...@ubik-ingenierie.com>
AuthorDate: Mon Feb 17 21:13:22 2020 +0100

    Bug 64150 - View Results Tree: Allow editing of response data in testers
---
 .../json/render/AbstractRenderAsJsonRenderer.java  |  2 +-
 .../visualizers/RenderAsBoundaryExtractor.java     | 17 ++++++---------
 .../jmeter/visualizers/RenderAsCssJQuery.java      | 18 ++++++----------
 .../apache/jmeter/visualizers/RenderAsRegexp.java  | 17 ++++++---------
 .../apache/jmeter/visualizers/RenderAsXPath.java   | 17 ++++++---------
 .../apache/jmeter/visualizers/RenderAsXPath2.java  | 25 +++++++++++-----------
 xdocs/changes.xml                                  |  1 +
 7 files changed, 42 insertions(+), 55 deletions(-)

diff --git 
a/src/components/src/main/java/org/apache/jmeter/extractor/json/render/AbstractRenderAsJsonRenderer.java
 
b/src/components/src/main/java/org/apache/jmeter/extractor/json/render/AbstractRenderAsJsonRenderer.java
index 8aa34c1..73a3d77 100644
--- 
a/src/components/src/main/java/org/apache/jmeter/extractor/json/render/AbstractRenderAsJsonRenderer.java
+++ 
b/src/components/src/main/java/org/apache/jmeter/extractor/json/render/AbstractRenderAsJsonRenderer.java
@@ -140,7 +140,7 @@ abstract class AbstractRenderAsJsonRenderer implements 
ResultRenderer, ActionLis
     private JPanel createExtractorPanel() {
         jsonDataField = JSyntaxTextArea.getInstance(50, 80, true);
         jsonDataField.setCodeFoldingEnabled(true);
-        jsonDataField.setEditable(false);
+        jsonDataField.setEditable(true);
         jsonDataField.setBracketMatchingEnabled(false);
         jsonDataField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
         jsonDataField.setLanguage(SyntaxConstants.SYNTAX_STYLE_JSON);
diff --git 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsBoundaryExtractor.java
 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsBoundaryExtractor.java
index 22733bd..0af0cda 100644
--- 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsBoundaryExtractor.java
+++ 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsBoundaryExtractor.java
@@ -34,6 +34,7 @@ import javax.swing.JTextArea;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.extractor.BoundaryExtractor;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.util.JMeterUtils;
@@ -59,8 +60,6 @@ public class RenderAsBoundaryExtractor implements 
ResultRenderer, ActionListener
 
     private JTabbedPane rightSide;
 
-    private SampleResult sampleResult = null;
-
     /**
      * Display the response as text or as rendered HTML. Change the text on the
      * button appropriate to the current display.
@@ -70,9 +69,9 @@ public class RenderAsBoundaryExtractor implements 
ResultRenderer, ActionListener
     @Override
     public void actionPerformed(ActionEvent e) {
         String command = e.getActionCommand();
-        if ((sampleResult != null) && 
(BOUNDARY_EXTRACTOR_TESTER_COMMAND.equals(command))) {
-            String response = 
ViewResultsFullVisualizer.getResponseAsString(sampleResult);
-            executeAndShowBoundaryExtractorTester(response);
+        String boundaryExtractorDataFieldText = 
boundaryExtractorDataField.getText();
+        if (StringUtils.isNotEmpty(boundaryExtractorDataFieldText) && 
BOUNDARY_EXTRACTOR_TESTER_COMMAND.equals(command)) {
+            
executeAndShowBoundaryExtractorTester(boundaryExtractorDataFieldText);
         }
     }
 
@@ -132,7 +131,7 @@ public class RenderAsBoundaryExtractor implements 
ResultRenderer, ActionListener
      */
     private JPanel createBoundaryExtractorPanel() {
         boundaryExtractorDataField = new JTextArea();
-        boundaryExtractorDataField.setEditable(false);
+        boundaryExtractorDataField.setEditable(true);
         boundaryExtractorDataField.setLineWrap(true);
         boundaryExtractorDataField.setWrapStyleWord(true);
 
@@ -204,10 +203,8 @@ public class RenderAsBoundaryExtractor implements 
ResultRenderer, ActionListener
 
     /** {@inheritDoc} */
     @Override
-    public synchronized void setSamplerResult(Object userObject) {
-        if (userObject instanceof SampleResult) {
-            sampleResult = (SampleResult) userObject;
-        }
+    public void setSamplerResult(Object userObject) {
+        // NOOP
     }
 
     /** {@inheritDoc} */
diff --git 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsCssJQuery.java
 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsCssJQuery.java
index a528063..eff86a9 100644
--- 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsCssJQuery.java
+++ 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsCssJQuery.java
@@ -37,6 +37,7 @@ import javax.swing.JTextArea;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.extractor.Extractor;
 import org.apache.jmeter.extractor.HtmlExtractor;
 import org.apache.jmeter.gui.util.JSyntaxTextArea;
@@ -70,8 +71,6 @@ public class RenderAsCssJQuery implements ResultRenderer, 
ActionListener {
 
     private JLabeledChoice cssJqueryLabeledChoice;
 
-    private SampleResult sampleResult = null;
-
     /** {@inheritDoc} */
     @Override
     public void clearData() {
@@ -98,9 +97,9 @@ public class RenderAsCssJQuery implements ResultRenderer, 
ActionListener {
     @Override
     public void actionPerformed(ActionEvent e) {
         String command = e.getActionCommand();
-        if ((sampleResult != null) && 
(CSSJQUEY_TESTER_COMMAND.equals(command))) {
-            String response = 
ViewResultsFullVisualizer.getResponseAsString(sampleResult);
-            executeAndShowCssJqueryTester(response);
+        String cssJqueryDataFieldText = cssJqueryDataField.getText();
+        if (StringUtils.isNotEmpty(cssJqueryDataFieldText) && 
CSSJQUEY_TESTER_COMMAND.equals(command)) {
+            executeAndShowCssJqueryTester(cssJqueryDataFieldText);
         }
     }
 
@@ -166,7 +165,7 @@ public class RenderAsCssJQuery implements ResultRenderer, 
ActionListener {
     private JPanel createCssJqueryPanel() {
         cssJqueryDataField = JSyntaxTextArea.getInstance(50, 80, true);
         cssJqueryDataField.setCodeFoldingEnabled(true);
-        cssJqueryDataField.setEditable(false);
+        cssJqueryDataField.setEditable(true);
         cssJqueryDataField.setBracketMatchingEnabled(false);
         
cssJqueryDataField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HTML);
         cssJqueryDataField.setLanguage(SyntaxConstants.SYNTAX_STYLE_HTML);
@@ -234,7 +233,6 @@ public class RenderAsCssJQuery implements ResultRenderer, 
ActionListener {
         c.gridy=1;
         cssJqueryActionPanel.add(cssJqueryTester, c);
 
-
         cssJqueryResultField = new JTextArea();
         cssJqueryResultField.setEditable(false);
         cssJqueryResultField.setLineWrap(true);
@@ -255,10 +253,8 @@ public class RenderAsCssJQuery implements ResultRenderer, 
ActionListener {
 
     /** {@inheritDoc} */
     @Override
-    public synchronized void setSamplerResult(Object userObject) {
-        if (userObject instanceof SampleResult) {
-            sampleResult = (SampleResult) userObject;
-        }
+    public void setSamplerResult(Object userObject) {
+        // NOOP
     }
 
     /** {@inheritDoc} */
diff --git 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsRegexp.java
 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsRegexp.java
index c9c3c73..eaeb9db 100644
--- 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsRegexp.java
+++ 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsRegexp.java
@@ -35,6 +35,7 @@ import javax.swing.JTextArea;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.GuiUtils;
@@ -64,8 +65,6 @@ public class RenderAsRegexp implements ResultRenderer, 
ActionListener {
 
     private JTabbedPane rightSide;
 
-    private SampleResult sampleResult = null;
-
     /** {@inheritDoc} */
     @Override
     public void clearData() {
@@ -90,9 +89,9 @@ public class RenderAsRegexp implements ResultRenderer, 
ActionListener {
     @Override
     public void actionPerformed(ActionEvent e) {
         String command = e.getActionCommand();
-        if ((sampleResult != null) && (REGEXP_TESTER_COMMAND.equals(command))) 
{
-            String response = 
ViewResultsFullVisualizer.getResponseAsString(sampleResult);
-            executeAndShowRegexpTester(response);
+        String xmlDataFieldText = regexpDataField.getText();
+        if (StringUtils.isNotEmpty(xmlDataFieldText) && 
REGEXP_TESTER_COMMAND.equals(command)) {
+            executeAndShowRegexpTester(xmlDataFieldText);
         }
     }
 
@@ -163,7 +162,7 @@ public class RenderAsRegexp implements ResultRenderer, 
ActionListener {
      */
     private JPanel createRegexpPanel() {
         regexpDataField = new JTextArea();
-        regexpDataField.setEditable(false);
+        regexpDataField.setEditable(true);
         regexpDataField.setLineWrap(true);
         regexpDataField.setWrapStyleWord(true);
 
@@ -218,10 +217,8 @@ public class RenderAsRegexp implements ResultRenderer, 
ActionListener {
 
     /** {@inheritDoc} */
     @Override
-    public synchronized void setSamplerResult(Object userObject) {
-        if (userObject instanceof SampleResult) {
-            sampleResult = (SampleResult) userObject;
-        }
+    public void setSamplerResult(Object userObject) {
+        // NOOP
     }
 
     /** {@inheritDoc} */
diff --git 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath.java 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath.java
index c75de99..2399f56 100644
--- 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath.java
+++ 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath.java
@@ -40,6 +40,7 @@ import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.jmeter.assertions.gui.XMLConfPanel;
 import org.apache.jmeter.extractor.XPathExtractor;
@@ -78,8 +79,6 @@ public class RenderAsXPath implements ResultRenderer, 
ActionListener {
 
     private JTabbedPane rightSide;
 
-    private SampleResult sampleResult = null;
-
     // Should we return fragment as text, rather than text of fragment?
     private final JCheckBox getFragment =
         new 
JCheckBox(JMeterUtils.getResString("xpath_tester_fragment"));//$NON-NLS-1$
@@ -110,12 +109,12 @@ public class RenderAsXPath implements ResultRenderer, 
ActionListener {
     @Override
     public void actionPerformed(ActionEvent e) {
         String command = e.getActionCommand();
-        if ((sampleResult != null) && (XPATH_TESTER_COMMAND.equals(command))) {
-            String response = xmlDataField.getText();
+        String xmlDataFieldText = xmlDataField.getText();
+        if (StringUtils.isNotEmpty(xmlDataFieldText) && 
XPATH_TESTER_COMMAND.equals(command)) {
             XPathExtractor extractor = new XPathExtractor();
             xmlConfPanel.modifyTestElement(extractor);
             extractor.setFragment(getFragment.isSelected());
-            executeAndShowXPathTester(response, extractor);
+            executeAndShowXPathTester(xmlDataFieldText, extractor);
         }
     }
 
@@ -214,7 +213,7 @@ public class RenderAsXPath implements ResultRenderer, 
ActionListener {
     private JPanel createXpathExtractorPanel() {
         xmlDataField = JSyntaxTextArea.getInstance(50, 80, true);
         xmlDataField.setCodeFoldingEnabled(true);
-        xmlDataField.setEditable(false);
+        xmlDataField.setEditable(true);
         xmlDataField.setBracketMatchingEnabled(false);
         xmlDataField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
         xmlDataField.setLanguage(SyntaxConstants.SYNTAX_STYLE_XML);
@@ -279,10 +278,8 @@ public class RenderAsXPath implements ResultRenderer, 
ActionListener {
 
     /** {@inheritDoc} */
     @Override
-    public synchronized void setSamplerResult(Object userObject) {
-        if (userObject instanceof SampleResult) {
-            sampleResult = (SampleResult) userObject;
-        }
+    public void setSamplerResult(Object userObject) {
+        // NOOP
     }
 
     /** {@inheritDoc} */
diff --git 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath2.java
 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath2.java
index f9a2ba4..b55ffcb 100644
--- 
a/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath2.java
+++ 
b/src/components/src/main/java/org/apache/jmeter/visualizers/RenderAsXPath2.java
@@ -36,6 +36,7 @@ import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
 import javax.swing.JTextField;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.jmeter.extractor.XPath2Extractor;
 import org.apache.jmeter.gui.util.JSyntaxTextArea;
@@ -68,8 +69,6 @@ public class RenderAsXPath2 implements ResultRenderer, 
ActionListener {
 
     private JTabbedPane rightSide;
 
-    private SampleResult sampleResult = null;
-
     // Should we return fragment as text, rather than text of fragment?
     private final JCheckBox getFragment =
         new 
JCheckBox(JMeterUtils.getResString("xpath_tester_fragment"));//$NON-NLS-1$
@@ -100,15 +99,17 @@ public class RenderAsXPath2 implements ResultRenderer, 
ActionListener {
     @Override
     public void actionPerformed(ActionEvent e) {
         String command = e.getActionCommand();
-        if ((sampleResult != null) && (XPATH_TESTER_COMMAND.equals(command))) {
-            String response = xmlDataField.getText();
+        String xmlDataFieldText = xmlDataField.getText();
+        if (StringUtils.isEmpty(xmlDataFieldText)) {
+            return;
+        }
+        if (XPATH_TESTER_COMMAND.equals(command)) {
             XPath2Extractor extractor = new XPath2Extractor();
             extractor.setFragment(getFragment.isSelected());
-            executeAndShowXPathTester(response, extractor);
+            executeAndShowXPathTester(xmlDataFieldText, extractor);
         }
-        else if ((sampleResult != null) && 
(XPATH_NAMESPACES_COMMAND.equals(command))) {
-            String response = xmlDataField.getText();
-            this.xpathResultField.setText(getDocumentNamespaces(response));
+        else if (XPATH_NAMESPACES_COMMAND.equals(command)) {
+            
this.xpathResultField.setText(getDocumentNamespaces(xmlDataFieldText));
         }
     }
 
@@ -196,7 +197,7 @@ public class RenderAsXPath2 implements ResultRenderer, 
ActionListener {
     private JPanel createXpathExtractorPanel() {
         xmlDataField = JSyntaxTextArea.getInstance(50, 80, true);
         xmlDataField.setCodeFoldingEnabled(true);
-        xmlDataField.setEditable(false);
+        xmlDataField.setEditable(true);
         xmlDataField.setBracketMatchingEnabled(false);
         xmlDataField.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
         xmlDataField.setLanguage(SyntaxConstants.SYNTAX_STYLE_XML);
@@ -296,10 +297,8 @@ public class RenderAsXPath2 implements ResultRenderer, 
ActionListener {
 
     /** {@inheritDoc} */
     @Override
-    public synchronized void setSamplerResult(Object userObject) {
-        if (userObject instanceof SampleResult) {
-            sampleResult = (SampleResult) userObject;
-        }
+    public void setSamplerResult(Object userObject) {
+        // NOOP
     }
 
     /** {@inheritDoc} */
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 798fb62..e59be07 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -95,6 +95,7 @@ to view the last release notes of version 5.2.1.
 
 <h3>Listeners</h3>
 <ul>
+    <li><bug>64150</bug>View Results Tree: Allow editing of response data in 
testers</li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>

Reply via email to