Uploading a document from same source document with jMeter.

This is another script that you can use to upload the same document to your system using jMeter. This is another way of doing as I have mentioned here.

import java.text.*;
import java.io.*;
import java.lang.*;
import org.apache.commons.io.FileUtils;

//Take the fileLocation from the user defined variable
//fileLocation = “/Users/cthalayasingam/Documents/jmeterTest/PerformanceTests/”;
fileLocation = vars.get(“fileCreatedPath”);
// The string portrays the current location of the document (Source file)
mainFile = “images.png”;
//The string portrays the location of the document which is renamed.
start = System.currentTimeMillis();
fileName = start + “images.png”;
//Save the name of the document with the time so that can be DELETED later
vars.put(“fileName1”, fileName);
//Get current document location
File file = new File( fileLocation + mainFile);
//Create location for renamed location
File file2 = new File( fileLocation + fileName);
//Copy the file to the document to the new location
FileUtils.copyFile(file, file2);

After you have entered the above script in the Bean Shell pre processor. Then put the script in the delete script found below in a BeanShell Post Processor, that applies the delete for the document you have copied to the new destination.

import java.text.*;
import java.io.*;
import java.util.*;
import java.lang.*;

csvDir = vars.get(“fileCreatedPath”);
fileName2 = vars.get(“fileName1”);
File file1 = new File( csvDir + fileName2);
if (file1.exists()) {