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
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Recording File Uploads With JMeter

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

Dmitri Tikhanski user avatar by
Dmitri Tikhanski
·
Jun. 21, 16 · Tutorial
Like (3)
Save
Tweet
Share
12.90K Views

Join the DZone community and get the full member experience.

Join For Free

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, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Cloud-Based Transportation Management System
  • Integration: Data, Security, Challenges, and Best Solutions
  • Using JSON Web Encryption (JWE)
  • How To Validate Three Common Document Types in Python

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: