How to automate API testing with SoapUi and Spring boot - java

We are building a test automation framework in spring boot. I have both Rest and Soap service which need to be mocked and load test the whole application.
For mocking some services i know that i can use SoapUi GUI and see the response same to the API test. but i want to automated and integrated SoapUi through spring boot and automate those functionalities through code base.
Did anyone has any experience on this?
Resource materials to refer?
Thanks.

Related

Where can I find a minimal spring boot boilerplate web app with backend and frontend?

I want a barebone template project for a webapp implemented using spring boot (frontend + backend APIs - DB)
I referred this VS Code's doc for working with Java. It worked fine but it is not a complete webapp.
Thanks in advance!
Vaadin Flow is a GUI framework for web apps driven through Spring Boot. (Alternatively, you can base your Vaadin app on Jakarta EE or plain Jakarta Servlet.)
A customized project template can be generated from their "Start building" web page.
You can manage your Vaadin project with either Maven or Gradle.
If you want to generate an app with spring boot + angular/reactjs/vuejs I think that the best solution by far at this moment is JHipster.

Build a test that consumes a Spring based REST API URL running on localhost for testing

I have build a REST API Based SMS gateway on Spring boot, along with an extensive testing suite comprising of unit and integration tests for testing the business logic and various layers of the API's architecture. I am now required to create a test which consumes the API call that runs from my localhost under various conditions. My queries are as follows:
Do I need to separately run the Spring Boot application on localhost before I can run the tests that directly consume the API from localhost?
I need to integrate my tests with Travis for Continuous integration. Is it possible to build an integration test which, on being run, starts the Spring application on localhost and directly calls the API URL from localhost for testing its response when different parameters are passed to the URL?
Following from Yogi's comment above, I used RestAssured to build a test suite that directly consumed the API end point running on my localhost.
The following bookmarks helped me understand RestAssured:
For getting a general understanding of how Rest Assured can be used:
https://semaphoreci.com/community/tutorials/testing-rest-endpoints-using-rest-assured
The official RestAssured wiki for understanding the API: https://github.com/rest-assured/rest-assured/wiki/Usage#getting-response-data
An example of using RestAssured via Gradle in a Spring project: https://www.blazemeter.com/blog/how-to-extract-values-when-api-testing-with-rest-assured
Using Basic Authentication with Rest Assured: https://www.youtube.com/watch?v=PAyGma2OMFo

Advice needed - Jersy or Spring for google cloud technologies?

We have few services on Google App Engine(GAE) and few on Google Container Engine (GKE).
The one on GKE is a sort of indexing service RESTful API and runs in background once triggered. It is an RESTful endpoint developed using Jersy.
my confusion and question is, Is migrating this to spring boot beneficial ? I see advantages of spring as DI, aop, exception handling etc. plus I have worked on it before inclines me more towards choosing spring :p
In contrast , if continue using jesrsy, we have to adopt guice for DI and I don't have much idea if we can do anything sort of aop and security (maybe using filters etc)
Please let me know your views/experiences on this.
Thanks In advance!
You don't necessarily have to use Guice if you keep using Jersey, Spring integrates very well with Jersey even before Spring Boot was released.
Spring Boot provides a Jersey starter that makes integration easier: spring-boot-starter-jersey
And if you are curious, I published a while back a post about Spring Boot, Jersey, Swagger and Docker

how to build a spring boot jar exposing both rest and soap service

I have been contemplating on building a test jar for a community of developers in order to expose a preview of a next release of an API (having stubs returning expected response with exact format etc). We do have both REST and SOAP API. I guess it won't be any problem building the REST Service as the net is flooded with example. It was quite surprising there isn't much of concrete example of how to build SOAP service (JAXWS) with spring boot with embedded jetty.
What I expect to achieve is one single jar with both APIs. I am rather comfortable developing a java first services. I have seen a post in stackoverflow but it doesn't clearly outline steps to achieve that. I know it's possible because dropwizard guys have similar project.
I will be grateful if there is any resource with example on how to handle SOAP web services in spring boot.
Thanks you in advance
Spring already supports JAXWS through *JaxWsServiceExporter and SpringBeanAutowiringSupport (in spring-web). The *Exporter approach doesn't quite mesh with the REST stuff because it isn't in the embedded container. You'd end up with an app listening on 2 ports (one for XML and one for JSON). If either of those works then you have a solution. If you don't really care that much about SOAP and just want XML representations, you can use normal content negotiation features (e.g. #ResponseBody or #RestController for everything).

Integrate Groovy in an existent Web app

I have an existent web application, I'd like to add Groovy to this web app so that I can develop web service providers easily if possible.
Is there a way to write a service class (like Grails service classes) and expose this class as ws without much pain ?
Grails uses the same thing : after adding one line to the service class, that class will be exposed automatically as a web service.
Regards
GroovyWS is a SOAP based implementation of Apache CXF.
After some quick searching I found two tutorials that may be of help.
One using Jersey and the other using Restlet. The Jersey one seems simpler.
Creating RESTful services with Jersey and Groovy
Building RESTful Web Apps with Groovy and Restlet, Part 1: Up and Running

Categories

Resources