Author: sebb
Date: Sat May  9 02:23:04 2009
New Revision: 773154

URL: http://svn.apache.org/viewvc?rev=773154&view=rev
Log:
Add option to skip suffix generation in Save Responses to a File

Modified:
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultSaver.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/gui/ResultSaverGui.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/images/screenshots/savetofile.png
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultSaver.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultSaver.java?rev=773154&r1=773153&r2=773154&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultSaver.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultSaver.java 
Sat May  9 02:23:04 2009
@@ -59,6 +59,8 @@
 
     public static final String SKIP_AUTO_NUMBER = "FileSaver.skipautonumber"; 
// $NON-NLS-1$
 
+    public static final String SKIP_SUFFIX = "FileSaver.skipsuffix"; // 
$NON-NLS-1$
+
     private synchronized long nextNumber() {
         return ++sequenceNumber;
     }
@@ -136,7 +138,7 @@
             }
         }
 
-        String fileName = makeFileName(s.getContentType(), 
getSkipAutoNumber());
+        String fileName = makeFileName(s.getContentType(), 
getSkipAutoNumber(), getSkipSuffix());
         log.debug("Saving " + s.getSampleLabel() + " in " + fileName);
         s.setResultFileName(fileName);// Associate sample with file name
         String variable = getVariableName();
@@ -167,25 +169,30 @@
      *         from the contentType e.g. Content-Type:
      *         text/html;charset=ISO-8859-1
      */
-    private String makeFileName(String contentType, boolean skipAutoNumber) {
-        String suffix = "unknown";
-        if (contentType != null) {
-            int i = contentType.indexOf("/"); // $NON-NLS-1$
-            if (i != -1) {
-                int j = contentType.indexOf(";"); // $NON-NLS-1$
-                if (j != -1) {
-                    suffix = contentType.substring(i + 1, j);
+    private String makeFileName(String contentType, boolean skipAutoNumber, 
boolean skipSuffix) {
+        StrBuilder sb = new StrBuilder(getFilename());
+        if (!skipAutoNumber){
+            sb.append(nextNumber());
+        }
+        if (!skipSuffix){
+            sb.append('.');
+            if (contentType != null) {
+                int i = contentType.indexOf("/"); // $NON-NLS-1$
+                if (i != -1) {
+                    int j = contentType.indexOf(";"); // $NON-NLS-1$
+                    if (j != -1) {
+                        sb.append(contentType.substring(i + 1, j));
+                    } else {
+                        sb.append(contentType.substring(i + 1));
+                    }
                 } else {
-                    suffix = contentType.substring(i + 1);
+                    sb.append("unknown");                    
                 }
+            } else {
+                sb.append("unknown");
             }
         }
-        if (skipAutoNumber) {
-            return getFilename() + "." + suffix; // $NON-NLS-1$
-        }
-        else {
-            return getFilename() + nextNumber() + "." + suffix; // $NON-NLS-1$
-        }
+        return sb.toString();
     }
 
     /*
@@ -222,6 +229,10 @@
         return getPropertyAsBoolean(SKIP_AUTO_NUMBER);
     }
 
+    private boolean getSkipSuffix() {
+        return getPropertyAsBoolean(SKIP_SUFFIX);
+    }
+
     private boolean getSuccessOnly() {
         return getPropertyAsBoolean(SUCCESS_ONLY);
     }

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/gui/ResultSaverGui.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/gui/ResultSaverGui.java?rev=773154&r1=773153&r2=773154&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/gui/ResultSaverGui.java
 (original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/gui/ResultSaverGui.java
 Sat May  9 02:23:04 2009
@@ -50,6 +50,8 @@
 
     private JCheckBox skipAutoNumber;
 
+    private JCheckBox skipSuffix;
+
     public ResultSaverGui() {
         super();
         init();
@@ -71,6 +73,7 @@
         
errorsOnly.setSelected(el.getPropertyAsBoolean(ResultSaver.ERRORS_ONLY));
         
successOnly.setSelected(el.getPropertyAsBoolean(ResultSaver.SUCCESS_ONLY));
         
skipAutoNumber.setSelected(el.getPropertyAsBoolean(ResultSaver.SKIP_AUTO_NUMBER));
+        
skipSuffix.setSelected(el.getPropertyAsBoolean(ResultSaver.SKIP_SUFFIX));
         
variableName.setText(el.getPropertyAsString(ResultSaver.VARIABLE_NAME,""));
     }
 
@@ -93,6 +96,7 @@
         te.setProperty(ResultSaver.FILENAME, filename.getText());
         te.setProperty(ResultSaver.ERRORS_ONLY, errorsOnly.isSelected());
         te.setProperty(ResultSaver.SKIP_AUTO_NUMBER, 
skipAutoNumber.isSelected());
+        te.setProperty(ResultSaver.SKIP_SUFFIX, skipSuffix.isSelected());
         te.setProperty(ResultSaver.SUCCESS_ONLY, successOnly.isSelected());
         AbstractTestElement at = (AbstractTestElement) te;
         at.setProperty(ResultSaver.VARIABLE_NAME, variableName.getText(),""); 
//$NON-NLS-1$
@@ -105,6 +109,7 @@
         super.clearGui();
 
         skipAutoNumber.setSelected(false);
+        skipSuffix.setSelected(false);
         filename.setText(""); //$NON-NLS-1$
         errorsOnly.setSelected(false);
         successOnly.setSelected(false);
@@ -124,6 +129,8 @@
         box.add(successOnly);
         skipAutoNumber = new 
JCheckBox(JMeterUtils.getResString("resultsaver_skipautonumber")); // 
$NON-NLS-1$
         box.add(skipAutoNumber);
+        skipSuffix = new 
JCheckBox(JMeterUtils.getResString("resultsaver_skipsuffix")); // $NON-NLS-1$
+        box.add(skipSuffix);
         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=773154&r1=773153&r2=773154&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 
Sat May  9 02:23:04 2009
@@ -657,6 +657,7 @@
 resultsaver_errors=Save Failed Responses only
 resultsaver_prefix=Filename prefix\:
 resultsaver_skipautonumber=Don't add number to prefix
+resultsaver_skipsuffix=Don't add suffix
 resultsaver_success=Save Successful Responses only
 resultsaver_title=Save Responses to a file
 resultsaver_variable=Variable Name:

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=773154&r1=773153&r2=773154&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat May  9 02:23:04 2009
@@ -259,7 +259,8 @@
 <li>HTTP Samplers now support connection and request timeouts (requires Java 
1.5 for Java Http sampler)</li>
 <li>Bug 47132 - Brazilian Portuguese translations</li>
 <li>Bug 46900 - Polish translations</li>
-<li> Bug 41209 -  JLabeled* and ToolTips</li>
+<li>Bug 41209 - JLabeled* and ToolTips</li>
+<li>Add option to skip suffix generation in Save Responses to a File</li>
 </ul>
 
 <h3>Non-functional changes</h3>

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/savetofile.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/savetofile.png?rev=773154&r1=773153&r2=773154&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=773154&r1=773153&r2=773154&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Sat May  9 
02:23:04 2009
@@ -2313,7 +2313,7 @@
 </div>
 </component>
 
-<component name="Save Responses to a file" index="&sect-num;.3.16"  
width="359" height="202" screenshot="savetofile.png">
+<component name="Save Responses to a file" index="&sect-num;.3.16"  
width="358" height="225" screenshot="savetofile.png">
     <description>
         <p>
         This test element can be placed anywhere in the test plan.
@@ -2324,6 +2324,8 @@
         The file name is created from the specified prefix, plus a number 
(unless this is disabled, see below).
         The file extension is created from the document type, if known.
         If not known, the file extension is set to 'unknown'.
+        If numbering is disabled, and adding a suffix is disabled, then the 
file prefix is
+        taken as the entire file name. This allows a fixed file name to be 
generated if required.
         The generated file name is stored in the sample response, and can be 
saved
         in the test log output file if required.
         </p>
@@ -2345,6 +2347,7 @@
  <property name="Save Failed Responses only" required="Yes">If selected, then 
only failed responses are saved</property>
  <property name="Save Successful Responses only" required="Yes">If selected, 
then only successful responses are saved</property>
  <property name="Don't add number to prefix" required="Yes">If selected, then 
no number is added to the prefix. If you select this option, make sure that the 
prefix is unique or the file may be overwritten.</property>
+ <property name="Don't add suffix" required="Yes">If selected, then no suffix 
is added. If you select this option, make sure that the prefix is unique or the 
file may be overwritten.</property>
  </properties>
 </component>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to