Environment and Project setup for Rest Assured and Sprint Boot Application - java

I have a spring boot microservice which connects to MySQL Database on production. This project also exposes REST endpoints and also consumes a REST endpoint from another microservice. It also connects to Kafka.
Now what I want to understand if I write REST Assured test cases using cucumber then where does this test cases will be kept. In the same spring boot microservice or code or it should be independent of that. If it should be kept independent and then how to achieve that. What is best practices ?
I am thinking of using WireMock to mock the endpoint which this microservice consumes. I am thinking of using EmbeddedKafka to connect it to Kafka.
How all of this thing will happen in CICD ?

Related

Integration Tests for AWS Kinesis consumer built using Spring Boot

We are working on Micro service developed using spring boot which consumes data from Kinesis stream process it and then stores it in DB. We have good JUnit Mockito test coverage .Now we need Integration test on this . Can you please suggest a good framework or set of frameworks which can be used to test the entire application end to end . We have checked so far Citrus, and spring-integration-aws but no luck
Generally you can use localstack to run AWS services like Kinesis locally, and start them up from your integration tests using Docker commands or something like Testcontainers.
Depending on how you have everything setup, you will need to inject a different Amazon Kinesis Client when the tests are running so that they connect to the local AWS services.

Is it possible to integrate existing SOAP endpoints within Spring Webflux?

I have an existing Spring Boot application (on Tomcat 7) which exposes certain REST endpoints using Spring-MVC and SOAP endpoints using CXF.
I am planning to migrate the application to Spring-Webflux to make the REST endpoints reactive, but have not been able to figure out a way to integrate SOAP endpoints to Spring Webflux ServletHttpHandlerAdapter class.
Does Spring Web Flux provide any way to do such a thing ?

How to verify that a spring-boot web server is running

I am writing an integration test for a spring-boot web server
I want to use junit-jupiter (junit5) to check if the server is running using Assumptions.assumeTrue so that the test do not fail if the server is not running...
There seems not to be any API support for such operation, but can it be achieved in some other way? Pinging the server?
You could make use of the actuator module in spring boot. It will provide you with a health check URL and you could make a call to this URL and verify that it returns healthy.
Now that that is out of the way, if you need the server to be running while running your tests, you should probably be using the spring boot test runner, instead of using the JUnit runner. In this case you could still mock some of your spring beans and achieve the same kind of test, but with a spring context running alongside your tests. The downside of this is the overhead of needing to spin up the spring context before running tests, but if you need to use the actual web server, then this is what you should be doing.

Spring Batch without Spring Cloud Data Flow

I have a Spring Boot application that uses Spring Batch. I want now to implement an admin panel to see all job statuses. For this, Spring has "spring-batch-admin" But I see that is deprecated long time ago:
The functionality of Spring Batch Admin has been mostly duplicated
and
expanded upon via Spring Cloud Data Flow and we encourage all users to
migrate to that going forward.
But then Spring Cloud Data Flow says:
Pipelines consist of Spring Boot apps, built using the Spring Cloud
Stream or Spring Cloud Task microservice frameworks
So in order to use this functionality do I really need to convert my spring boot app to a microservice? Isn't this an overkill just to see some batch statuses? Also I can not install docker on my production server(for various reasons) Can I still use Spring Cloud Data Flow without docker?
Yes, spring boot batch should be wrapped as spring cloud task, which should not be too complicated.
If Docker does not suit your needs - https://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#getting-started-local-deploying-spring-cloud-dataflow

Monitor Endpoint using Spring Framework

I'm trying to find an out-of-the-box health check for my spring app. However, I can only find support for Spring Actuator. I'm not able to use Spring Actuator because my application is a Spring application and not a Spring boot app. Is there another library that I could make use of without having to write my own? I would ideally want an endpoint that could possibly give me data about whether my DB is up and possibly some of the java opts passed into that particular node

Categories