2020 * <p>
2121 * By default, it will generate one file for each response using the given (which might include the
2222 * directory location) prefix to create the files and adding an incremental number to each response
23- * and an extension according to the response mime type.
23+ * and an extension according to the response mime type. Both the incremental number and the
24+ * extension can be set manually if skipAutoNumber and skipSuffix are set to true respectively.
2425 *
2526 * @since 0.13
2627 */
2728public class ResponseFileSaver extends BaseListener {
2829
2930 protected String fileNamePrefix ;
31+ protected boolean skipAutoNumber = false ;
32+ protected boolean skipSuffix = false ;
3033
3134 public ResponseFileSaver (String fileNamePrefix ) {
3235 super ("Save Responses to a file" , ResultSaverGui .class );
@@ -37,9 +40,41 @@ public ResponseFileSaver(String fileNamePrefix) {
3740 protected TestElement buildTestElement () {
3841 ResultSaver ret = new ResultSaver ();
3942 ret .setFilename (fileNamePrefix );
43+ ret .setSkipAutoNumber (skipAutoNumber );
44+ ret .setSkipSuffix (skipSuffix );
4045 return ret ;
4146 }
4247
48+
49+ /**
50+ * Allows specifying whether the ResponseFileSaver appends a number to the end of the generated file.
51+ * <p>
52+ * By default, the ResponseFileSaver will add a number based on the samplers in the scope of the
53+ * ResponseFileSaver test element. If set to true then no number will be appended.
54+ *
55+ * @param skipAutoNumber Boolean determining whether the number is added.
56+ * @return the ResponseFileSaver for further configuration or usage.
57+ */
58+ public ResponseFileSaver setSkipAutoNumber (boolean skipAutoNumber ) {
59+ this .skipAutoNumber = skipAutoNumber ;
60+ return this ;
61+ }
62+
63+
64+ /**
65+ * Allows specifying whether the ResponseFileSaver will append the file type to the file name.
66+ * <p>
67+ * By default, the ResponseFileSaver will use the MIME type to append the file type to the end of the
68+ * generated file. If this is set to true then no file type will be appended.
69+ *
70+ * @param skipSuffix Boolean determining whether a file type is added.
71+ * @return the ResponseFileSaver for further configuration or usage.
72+ */
73+ public ResponseFileSaver setSkipSuffix (boolean skipSuffix ) {
74+ this .skipSuffix = skipSuffix ;
75+ return this ;
76+ }
77+
4378 public static class CodeBuilder extends SingleTestElementCallBuilder <ResultSaver > {
4479
4580 public CodeBuilder (List <Method > builderMethods ) {
@@ -49,7 +84,7 @@ public CodeBuilder(List<Method> builderMethods) {
4984 @ Override
5085 protected MethodCall buildMethodCall (ResultSaver testElement , MethodCallContext context ) {
5186 return buildMethodCall (
52- new TestElementParamBuilder (testElement ).stringParam (ResultSaver .FILENAME ));
87+ new TestElementParamBuilder (testElement ).stringParam (ResultSaver .FILENAME ));
5388 }
5489
5590 }
0 commit comments