load testing using multithreading for a spring rest ful webservice - spring

I had implemented a restful service. I want to do a load testing for spring rest ful service. In this i want to check how many users can access a service. How to do that..Please provide me some information.

There are a variety of tools out there you can use for load testing. I've found JMeter to be a pretty robust open source option. Specifically for REST requests you can use the HTTP Request component.
That said, I'd be curious to hear what others are using.

Related

Testing REST API provider response without mock

Currently, I am working on a project on Spring Boot where we are integrating with external REST API. As part of our integration suite test, we are doing the mock test of the actual external API which executes as part of the CI/CD.
My question is in production it calls the actual API so, how we can do that in the test environment. I don't think we need to make the actual external provider call during multiple integration test which will load the external API, also at the same time would like to test with actual REST response from the service.
Any suggestions?
If the public API has a swagger description, you could use the Atlassian Pact Swagger Validator. I describe the workflow in this talk: https://www.youtube.com/watch?v=79GKBYSqMIo#t=39m10s
Another alternative would be to create a mock API for the external service. There are some free services like https://mockfirst.com, https://www.mockable.io/, etc. where you can do that.

Spring Integration Webservice vs. RestTemplate

I'm trying to learn SI (Spring Integration) but i'm a bit confused on the real usage of this.
As first example i would like to interact with a WebService but i dont understand what could be the difference from
Invoke a WebService Using SI
Invoke a Webservice using RestTemplate
So, what is the benefit of using SI (in Webservice context, or in other context)?
Looking the web, i havent find an article that explain:
Usually you will do in this way....
With SI you can do better - in this another way - and the benefit are....
To be more explicit on what i have to realize, this is an example:
1) I have to write an application (Standalone application) that have to collect some data in the system periodically and then invoke a Web Service that will store it.
2) The Web Service receive the call from the "clients" and store in the database.
My webservice will use REST.
The reason because i've think to use SI is that the Standalone Application should interact with different system
Webservice in first instance
A Web Mail, if the webservice is not achievable
File system if Web mail is not achievable too
If you only need to pull some data in a simple way and push it onwards to a REST service this does not "justify" the use of Spring Integration. A simple Spring (Boot) application combined with a scheduler will be sufficient.
But if you want to use a more complex data source for which an endpoint is available, you need transformations, complex and flexible routing is a high priority or even Enterprise Integration Patterns (EIP) then Spring Integration is for you. Have a look at the Overview and decide if it mentions something you consider as valuable to you.
Perhaps you will create additional value by mixing in Spring Batch if you need to process a lot of data.
But as I understand your current demand starting with just a RESTTemplate should do for the moment. Starting small will not prevent you from switching to Spring Integration later on.
Have a look at the various tutorials and guides provided by the Spring Boot project. There is even an example for Spring Integration.

Spring MVC and Web Application separated

I have been Googling a lot lately, but I find myself coming up short on answers.
I have a complete Spring MVC application secured by Spring Security and with services exposing logic to controllers (controllers -> service -> repository -> POJO's).
Currently all my controllers, except the login controller, serve nothing but JSON/XML and I want it to stay this way. I do not want to render different views on each controller.
However, what I want to be able to, is to separate the web application from the backend because in time I want to be able to integration with my service using more platforms than just a web browser.
Currently I have the regular Spring MVC application:
Configuration
Domain(POJO's)
Repository
Service
Controller
Login is done using a Thymeleaf rendered view and Spring Security which does nothing more than filtering all urls under the application root. After this, it is just a bunch of static files being served as resources:
Spring Controllers send a "{ontrollerName}/layout" to serve the AngularJS HTML partial used for all data under that given Spring Controller.
What I want, is a way to separate everything in the /webapp directory from the rest of my project. I have looked into a few different solutions here such as using Apache Proxy where my Apache Http server hosts the client code which communicate with the backend using Ajax to rest controllers, and Tomcat hosting the backend. However, I hear that proxying like this is not safe. I could however be dead wrong here.
So, the questions I hope to receive answers to are:
1. Is it fine to just write a client that uses Apache http server's Proxy to provide access to Ajax on the server?
If not; How should I proceed? Is it any point in trying to extract the client side from the /webapp directory or is this just some stupid idea I created because it seemed cool to be able to deploy them without having to relay on each others?
Is there any best practices in regards to how I structure a project with separate modules? Think Gradle build scripts for multi modules.
Should I think in different terms and use an approach not based on Spring MVC at all? If so, please advice me.
I hope this was clear enough to make sense for you guys.
The solution was to use the simpler approach of a restful API that did authentication over OAuth 2.
Basically the two best alternatives are a hybrid solution (part restful API and part server side rendering of pages) or a full blown restful API where you implement all functionality in a static web client. This way there is no need for multi-module projects and packing things together in one package.

Tool to report rest interfaces

We have a web application using Jersey and Spring's rest template. Does anyone know of a tool that can scan a code base and produce a report that lists all exposed endpoints and also internal references to those endpoints?
You may also take a look at Swagger, a framework for describing, producing, consuming, and visualizing RESTful web services.
Swagger supports multiple REST frameworks and also JAX-RS based on Jersey.
From their GitHub Wiki:
The Swagger framework simultaneously addresses server, client, and documentation/sandbox needs for REST APIs. As a specification, it is language-agnostic. It also provides a long runway into new technologies and protocols beyond HTTP.
With Swagger's declarative resource specification, clients can understand and consume services without knowledge of server implementation or access to the server code. The Swagger UI framework allows both developers and non-developers to interact with the API in a sandbox UI that gives clear insight into how the API responds to parameters and options. Swagger happily speaks both JSON and XML, with additional formats in the works.
Jersey can provide a WADL report at the /application.wadl URI. It doesn't document complex types but at least gives you a list of endpoints.
See https://wikis.oracle.com/display/Jersey/WADL

SOAP JAX-WS client in Ruby

I want to write a ruby web service client for a SOAP (JAX-WS) web service. I looked into soap4r and handsoap but couldn't find useful resources to write a (JAX-WS) client
Can you help me to find some resources and some way of doing it. Because as I can see, my web service is developed using oracle JDeveloper and looks little different than examples find in web.
I'm a beginner for SOAP, WSDL web services and finding it hard.
Has anyone done something like this before, or can you turn me to the correct direction?
JAX-WS is an API for the development of web services in Java. Know then that, in order to consume a SOAP/WSDL based web service, it is not necessary to know how that web service was implemented. It could be Java, .NET or any other number of languages. All that is required to create a SOAP based web service client is the WSDL for the service. It is self contained and self descriptive, including all operations and data types supported by the web service.
In order to familiarize yourself with web services, I would recommend trying to exercise some web services directly, for example using SoapUI. This will allow you to import a WSDL for an active web service, try out some of the operations, and see what the corresponding SOAP messages look like. Then, I would look at "What's the best way to use soap with ruby?" for more ruby specific approaches.

Resources