DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Beyond Extensions: Architectural Deep-Dives into File Upload Security
  • Dynamic File Upload Component in Salesforce LWC
  • How To Protect Node.js Form Uploads With a Deterministic Threat Detection API
  • How To Scan and Validate Image Uploads in Java

Trending

  • Closing the Drift Loop: An AI Agent That Drafts Terraform Fixes
  • Applying Microservices Lessons to Multi-Agent AI Systems
  • Genkit Flows as senro Steps: Extremely Powerful AI Pipelines in Go
  • When RabbitMQ Accepts a Message but Does Not Route It to a Queue

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

Recording File Uploads With JMeter

A hands-on tutorial of how to simulate a file upload in your Java application using JMeter.

By 
Dmitri Tikhanski
·
Jun. 21, 16 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
14.7K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

if you need to simulate uploading a file to an application under test, the fastest way of creating a jmeter test plan is recording the corresponding request via the http(s) test script recorder . jmeter comes with a proxy server which captures all traffic between the browser and the application under test, and converts it into the relevant http request samplers.

the easiest way to set up jmeter for recording is by using the templates feature, by performing the following steps:

  1. from jmeter’s main menu, choose file -> templates -> recording
  2. click the “create” button
  3. configure your browser to use the jmeter proxy providing:
  • the hostname or the ip address of the machine where jmeter is running as the proxy host
  • 8888 as the proxy port

now let’s try to record the file upload. i’ll use the readme file which lives in the root of the jmeter installation for this exercise.

so we’re getting the following error:

java.io.filenotfoundexception: readme (the system cannot find the file specified)

let’s take a look at the recorded request in the test plan:

as you can see from the image above, jmeter correctly resolved the file name which is readme , but didn’t capture the full path to the file. this is a result of browser behavior, as some browsers don’t send the full path of the file which is being uploaded. that is why jmeter wasn’t able to locate the file and send it along with the request.

the solution is to copy the file to jmeter’s “bin” folder . this way jmeter will pick up the file using the relative path, and therefore cause the recording to be successful.

the same applies to the recorded scenario replay. here you have 2 options:

  1. provide the full path to any file which you want to upload
  2. use the relative path (just filename), but in this case the file has to be in jmeter’s “bin” folder


remember that if jmeter’s proxy doesn’t work for you for some reason, there are the following alternative options of recording a jmeter test:

  • using the blazemeter chrome extension - this way you don’t need to worry about proxy configuration, ssl certificates, copying files to jmeter’s “bin” folder, etc.
  • using the blazemeter recorder - your personal cloud proxy which has “smart” jmx mode of exporting captured requests - automatic correlation of dynamic parameters so you won’t have to develop and debug regular expressions in order to make your test work.
Upload

Published at DZone with permission of Dmitri Tikhanski. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Beyond Extensions: Architectural Deep-Dives into File Upload Security
  • Dynamic File Upload Component in Salesforce LWC
  • How To Protect Node.js Form Uploads With a Deterministic Threat Detection API
  • How To Scan and Validate Image Uploads in Java

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook