Load Testing with SOAPUI

For testing web service performance, I used SOAPUI tool, though its name is SOAP, but it also supports the REST service calls. Most of the time I use JMeter to test the performance of particular functionality, and we used SOAPUI for calling SOAP based services, I was always thinking to use it for performance test and this time, I used SOAPUI to test REST services, SOAPUI is simple to configure and to run.

Download it from http://www.soapui.org/Downloads/latest-release.html

Step 1) Create a new REST Project and provide the base URL, I used Node.js to expose one simple rest service for this blog.


Step 2) Under the project, create the New Test Suite (Ctrl + T)


Step 3) Under the Test Suite add new Load Test case (Ctrl + N)

Step 4) Click on the REST Request button, it will prompt for the new Rest Request name, and once you provide the name, it will ask for the URL, provide the complete URL and click OK,


Step 5) it will create a simple REST Request and using UI you can provide the details, like parameters, header details etc.


Step 6) Now, for running the load test, select the Strategy as “Thread”, you can also explore other options like, Simple, Burst and Variance. When you select strategy as thread you can see, option to provide details for, number of virtual users, start threads, end threads and total runs. Total runs has two different parameters to set, one is time and another is number of requests.


If I choose number of requests then Load test will stop once the specifed number of test are ran, if you specify the time, test will continue for that perticular time, so if you want to figure out what is the average resposne time of your request when at a time 10 users are active and 60 requests are made, you can use the thread option

But if you want to figure out how many requests you can serve in 60 seconds if 10 users are active at a time i.e. virtual users,then you can use time option.

The feature I liked most of SOAP UI is, you can define the start treads and end thread parameter, say if you have implemented the caching and you want to have initial load of lesser number and subsequent threads should have more number of users, then you can specify Start Threads to 3 or any minimum number you can think of.

In SOAP UI you can try above example, just import the below XML project file in SOAP UI, and start your any REST server.

Download SOAP UI Project File

Load Testing with SOAPUI

Playing YouTube Video from specific postion

So if you want to play “Now That’s what I call a performance” from one of the youtube video, copy following link and paste in your favorite browser


DECLAIMER : If video has advertisement you need to wait for the advertisement’s timeout, and try again 🙂

OK how it work? YouTube use Fragment Identifier to jump to specific location, so if you want to play a video @ 2.2 i.e. after 2 minutes and 2 seconds, convert it to seconds, so it will be 122 and at the end of your URL add #t=122, and easiest way is you can right click on video and select “Get Video URL at current time” which will give you the link.

That may be intresting for you, but what is more interesting is why Fragment Identifier is used?
Fragment identifier points to the subordinate resource of the URL, so if you remember we used fragment identifiers to navigate to TOP, END or to specific “topic” within a HTML document. So fragment identifier can be used to navigate to specific location of the PDF, Audio files, Videos, HTML document or any specific media you are rendering on your page.

Hmmm so I can achieve the same thing by adding URL parameter, so what is the difference between url parameter and fragment identifier?

One difference I can see is with fragment identifier request is not made again, e.g. API document is already loaded but fragment identifie link will help you to navigate to specific location of the document. This is true for HTML docs, not sure about videos, audios and other media.

Any thoughts on how we can use it?

Playing YouTube Video from specific postion

Cross-site request and Sever configuration

While developing REST web service, we came across an error “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” with Http Status code 403, after exploring more on it, found the details of CORS and how browser supports it. Obviously as a user (mostly developer) I can disable the security and can make the request, but lets understand the ideal way of handling it.

What is CORS?

This document defines a mechanism to enable client-side cross-origin requests. Specifications that enable an API to make cross-origin requests to resources can use the algorithms defined by this specification. If such an API is used on http://example.org resources, a resource on http://hello-world.example can opt in using the mechanism described by this specification (e.g., specifying Access-Control-Allow-Origin: http://example.org as response header), which would allow that resource to be fetched cross-origin from http://example.org.

You can find more details on : http://www.w3.org/TR/cors/

So if you are making request to same server but the URL is different, the request will be treated as the cross-domain, e.g. http://localhost and will be treated as the cross-domain. Specification is implemented by the browser to support same-origin policy and security. When browser makes a request, it check for the origin and the URL of the request made to, if it wont match (protocol+domain+port number should be same) then a pre-flight request is made to the server, which is nothing but a same request with HTTP method OPTION. e.g. if you are making a call from localhost:8080/app/index.html to then request is made to with OPTION http method.

Pre-flight Request 

OPTIONS /app/home HTTP/1.1 
Connection: keep-alive 
Cache-Control: max-age=0 
Access-Control-Request-Method: GET 
Origin: http://localhost:8080 
Access-Control-Request-Headers: accept, content-type 
Accept: */* 
Referer: http://localhost:8080/app/index.html 


HTTP/1.1 200 OK 
Access-Control-Allow-Origin: http://localhost:8080 
Access-Control-Allow-Credentials: true 
Access-Control-Max-Age: 1800 
Access-Control-Allow-Methods: GET 
Access-Control-Allow-Headers: content-type,access-control-request-headers,access-control-request-method,accept,origin,x-requested-with 
Content-Length: 0


If your server returns the Access-Control-Allow-Origin headers then only client can access the targeted site content, when the preflight request is successful then browser makes the original request. Once the request is successful, browser cache the details of the origin, url (request made to), max-age and header details, so for subsequent requests to same URL will be served directly and in that case preflight request will be not sent.

On Server Side, How I can support the cross-site request

We do use Tomcat, from Tomact version 7.0.40 by default CorsFilter is included, you just need to enable it for your application, the minimal configuration is


you can specify the optional parameters by adding init parameters, follow this link for more details.



If you have Apache or any other HTTP server between client and you application server, then make sure you have implemented cross-site support on those servers.
if your application is used or open for limited applications, it is recommended to use specific domain names list for “Allowed Origin”, if you have a global web API then you can use *.
More on OPTION method

This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval. Mostly option do not have the body, but specification is open and in future option body may be supported to make detailed query on server.

BTW : WebSocket won’t fall under same-origin or cross-site policy, so if you create a WebSocket to different URL it will work.

Download code from GIT

Cross-site request and Sever configuration

Running Sonar Analysis Using Maven

In last post I have covered how to configure SonarQube. Let’s see how you can run a Sonar code analysis using Maven.

You need to enable sonar profile, for that you need to add following profile configuration to your settings.xml.


you can add above code in global settings.xml, which is kept in c:\users\\.m2 folder. Or you can create a file in your parent project and while running maven command use mvn –settings settings.xml command, maven –settings option is used to provide custom setting file.

In your parent pom.xml, you can specify sonar specific properties.


To run the SonarQube analysis run

mvn sonar:sonar

Maven will connect to the MySQL server and will run the code analysis on your code using configured rules, once the instrumentation us done, data will be persisted to MySQL server. once build is sucessfull you can access the report on your SonarQube application.

Running Sonar Analysis Using Maven

Configuring SonarQube

SonarQube is all in one code quality tool, it covers following main aspects of code quality
1) Complexity
2) Code coverage
3) Potential bugs
4) Architecture and Design

It is easy to use and configurable as per your need, SonarQube reuses the tools like FindBug, PMD, Cobertura, JUnits etc. Sonar also supports multiple languages. You can configure your own rules, rules can be configured project specific. You can integrate Sonar with Jenkins, so once your project is built all required rules will be analysed and published on SonarQube.

Shopizer Project On SonarQube

This is a quick start tutorial to setup a SonarQube.
You need JRE 6 or above to run the 4.5 SonarQube distribution.

Download the SonarQube distribution from the site, I used 4.5 version. Download from SonarQube 4.5

Extract the content of the file to a folder.

I used MySQL as backend to store the analysis data. to configure MySQL, run following queries on MySQL


GRANT ALL ON SonarDBName.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON SonarDBName.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

Change the SonarDBName to whatever you prefer, if you have your mySQL running on different server, change the value of ‘localhost’ to the specific host.

Configure Sonar to use MySQL as your default DB,Open the file conf/sonar.properties to edit, search for “sonar.jdbc.url”


In above snippet sonarQube is the Sonar DB name.

Now start your SonarQube /bin/windows-x86-32 (if you are running it on different platform, choose appropriate directory), in initial start up Sonar will download two plugins by default java and FindBug. if you need additional plugins you can download it from Sonar plugin site and copy it to /extensions/plugins. This is manual method.

I have used following plugins

Your default password for admin user is admin, login to the SonarQube instance by hitting localhost:9000 and change the default admin password, if required you can add more users and user groups. plugins also available to synch with Active Directory.

Configuring SonarQube

Running Embedded Tomcat

While searching for Tomcat 8, I came across a term called “Embedded Tomcat”, so I was wondering what it’s all about. With Embedded Tomcat, one can write a standalone application which can have a embedded web server, so when you run the standalone java application, tomcat embedded server will also start with it. I was surprised to see it has all the features which are available with Tomcat, including WebSocket. Spring Boot is using this API for starting the Spring Boot application. Even you can start your Spring web application by registering Springs DispatcherServlet in below example (but why need to reinvent the wheel, Spring Boot has done that for us).

Maven :



Java Code :

		Tomcat tomcat = new Tomcat();
		File base = new File(&amp;amp;quot;./staticContent&amp;amp;quot;);
		Context rootCtx = tomcat.addWebapp(&amp;amp;quot;/app&amp;amp;quot;, base.getAbsolutePath());
		Tomcat.addServlet(rootCtx, &amp;amp;quot;home&amp;amp;quot;, new SimpleServlet());
		rootCtx.addServletMapping(&amp;amp;quot;/home&amp;amp;quot;, &amp;amp;quot;home&amp;amp;quot;);

In above code, setPort sets the port to listen on for embedded Tomcat, I have added a folder “staticContent”, which has my html and to simplify the tomcat configuration I have added simpleWEB-INF/ web.xml in same folder. you can call it from main method.

tomcat.addWebApp method is called with two arguments, first is the context root, and second is the folder path.

if you observer addServlet is Static method of Tomcat class, which registers the servlet class. SimpleServlet is a simple servlet class.

tomcat.start will start the server. That’s all and your embedded Tomcat server is started. you can access your resources by hitting http://localhost:8080/app/home

One of the possible use (Other than running it as tomcat server) I can see is, if you have a web based tool or utility and you want user to quick start and try your product, with minimal setup i.e. just unzipping the package to folder, user can start exploring functionality.

Download Code

Running Embedded Tomcat