You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/07/23 13:57:20 UTC
svn commit: r1802724 - in /jmeter/trunk: bin/jmeter.properties
src/core/org/apache/jmeter/gui/action/AbstractAction.java xdocs/changes.xml
xdocs/usermanual/properties_reference.xml
Author: pmouawad
Date: Sun Jul 23 13:57:20 2017
New Revision: 1802724
URL: http://svn.apache.org/viewvc?rev=1802724&view=rev
Log:
Bug 61068 - Introduce property "resultcollector.action_if_file_exists" to control the popup "File already exists" when starting a test
Bugzilla Id: 61068
Modified:
jmeter/trunk/bin/jmeter.properties
jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractAction.java
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/properties_reference.xml
Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1802724&r1=1802723&r2=1802724&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sun Jul 23 13:57:20 2017
@@ -924,6 +924,13 @@ beanshell.server.file=../extras/startup.
#---------------------------------------------------------------------------
# Miscellaneous configuration
#---------------------------------------------------------------------------
+# Used to control what happens when you start a test and
+# have listeners that could overwrite existing result files
+# Possible values:
+# ASK : Ask user
+# APPEND : Append results to existing file
+# DELETE : Delete existing file and start a new file
+#resultcollector.action_if_file_exists=ASK
# If defined, then start the mirror server on the port
#mirror.server.port=8081
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractAction.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractAction.java?rev=1802724&r1=1802723&r2=1802724&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractAction.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/AbstractAction.java Sun Jul 23 13:57:20 2017
@@ -38,6 +38,18 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractAction implements Command {
private static final Logger log = LoggerFactory.getLogger(AbstractAction.class);
+ private enum ActionOnFile {
+ APPEND,
+ DELETE,
+ ASK
+ }
+
+ private static final ActionOnFile actionOnFile =
+ ActionOnFile.valueOf(
+ JMeterUtils.getPropDefault(
+ "resultcollector.action_if_file_exists",
+ ActionOnFile.ASK.name()));
+
/**
* @see Command#doAction(ActionEvent)
*/
@@ -46,12 +58,6 @@ public abstract class AbstractAction imp
}
/**
- * @see Command#getActionNames()
- */
- @Override
- abstract public Set<String> getActionNames();
-
- /**
* @param e the event that led to the call of this method
*/
protected void popupShouldSave(ActionEvent e) {
@@ -80,33 +86,50 @@ public abstract class AbstractAction imp
ResultCollector rc = irc.next();
File f = new File(rc.getFilename());
if (f.exists()) {
- String[] option = new String[] { JMeterUtils.getResString("concat_result"),
- JMeterUtils.getResString("dont_start"), JMeterUtils.getResString("replace_file") };
- String question = MessageFormat.format(
- JMeterUtils.getResString("ask_existing_file"), // $NON-NLS-1$
- rc.getFilename());
- // Interactive question
- int response = JOptionPane.showOptionDialog(GuiPackage.getInstance().getMainFrame(),
- question, JMeterUtils.getResString("warning"),
- JOptionPane.YES_NO_CANCEL_OPTION,
- JOptionPane.WARNING_MESSAGE,
- null,
- option,
- option[0]);
-
- switch (response) {
- case JOptionPane.NO_OPTION:
- // Exit without start the test
- return false;
- case JOptionPane.CANCEL_OPTION:
- // replace_file so delete the existing one
- f.delete();
- break;
- case JOptionPane.YES_OPTION:
- // append is the default behaviour, so nothing to do
+ switch (actionOnFile) {
+ case APPEND:
break;
+ case DELETE:
+ if(f.delete()) {
+ break;
+ } else {
+ log.error("Could not delete existing file {}", f.getAbsolutePath());
+ return false;
+ }
+ case ASK:
default:
- return false;
+ String[] option = new String[] { JMeterUtils.getResString("concat_result"),
+ JMeterUtils.getResString("dont_start"), JMeterUtils.getResString("replace_file") };
+ String question = MessageFormat.format(
+ JMeterUtils.getResString("ask_existing_file"), // $NON-NLS-1$
+ rc.getFilename());
+ // Interactive question
+ int response = JOptionPane.showOptionDialog(GuiPackage.getInstance().getMainFrame(),
+ question, JMeterUtils.getResString("warning"),
+ JOptionPane.YES_NO_CANCEL_OPTION,
+ JOptionPane.WARNING_MESSAGE,
+ null,
+ option,
+ option[0]);
+
+ switch (response) {
+ case JOptionPane.CANCEL_OPTION:
+ // replace_file so delete the existing one
+ if(f.delete()) {
+ break;
+ } else {
+ log.error("Could not delete existing file {}", f.getAbsolutePath());
+ return false;
+ }
+ case JOptionPane.YES_OPTION:
+ // append is the default behaviour, so nothing to do
+ break;
+ case JOptionPane.NO_OPTION:
+ default:
+ // Exit without start the test
+ return false;
+ }
+ break;
}
}
}
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1802724&r1=1802723&r2=1802724&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sun Jul 23 13:57:20 2017
@@ -111,7 +111,8 @@ Incorporated feed back about unclear doc
<h3>Listeners</h3>
<ul>
- <li><bug>61167</bug>InfluxdbBackendListener : add number of errors by response code and message for each transaction</li>
+ <li><bug>61167</bug>InfluxdbBackendListener : add number of errors by response code and message for each transaction</li>
+ <li><bug>61068</bug>Introduce property <code>resultcollector.action_if_file_exists</code> to control the popup "File already exists" when starting a test</li>
</ul>
<h3>Timers, Assertions, Config, Pre- & Post-Processors</h3>
Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1802724&r1=1802723&r2=1802724&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Sun Jul 23 13:57:20 2017
@@ -1199,6 +1199,15 @@ JMETER-SERVER</source>
</section>
<section name="§-num;.35 Miscellaneous configuration" anchor="miscellaneous">
<properties>
+<property name="resultcollector.action_if_file_exists">
+ Used to control what happens when you start a test and have listeners that could overwrite existing result files.<br/>
+ Possible values:
+ <ul>
+ <li><code>ASK</code> : Ask user</li>
+ <li><code>APPEND</code> : Append results to existing file</li>
+ <li><code>DELETE</code> : Delete existing file and start a new file</li>
+ </ul>
+</property>
<property name="mirror.server.port">
If defined and greater then zero, then start the mirror server on the port.<br/>
Defaults to: <code>0</code>