Learn to write spring boot async rest controller using SseEmitter which is a specialization of ResponseBodyEmitter for sending Server-Sent Events.
Learn to write spring boot async rest controller using ResponseBodyEmitter to call multiple services and collect the results to the response to the client.
Learn to test spring boot async rest controller using MockMVC which support async request processing and return the response asynchronously. 1. spring boot async controller Given is a async controller which returns a simple string output after the delay of 5 seconds. We will write the unit test for this controller. 2. How to test […]
Learn to write spring boot async rest controller which support async request processing and returning the response using Callable interface.
Learn to write unit tests for service layer of Spring application using JUnit and Mockito testing frameworks. This tutorial demonstrate spring boot test service layer example. 1. Maven Dependencies The spring-boot-starter-test dependency includes all required dependencies to create and execute tests. If not using spring boot then include following dependencies. 2. Setup In this example, […]
In this Spring boot MockMVC example, learn to use Spring MockMVC to perform integration testing of Spring webmvc controller, rest apis and verify responses.
Learn to create spring boot project having multiple modules. The parent project will work as container for base maven configurations. The child modules will be actual spring boot projects – inheriting the maven properties from parent project. 1. Spring boot maven parent project The parent project is single point to trigger build process for all […]
Learn to add basic authentication to http requests invoked by Spring RestTemplate while accessing rest apis over the network. 1. Maven dependency To work with Spring RestTemplate and HttpClient API, we must include spring-boot-starter-web and httpclient dependencies in pom.xml file. In this RestTemplate basic authentication tutorial, we are using dependencies. 2. Enable BasicAuth in RestTemplate […]
Learn to use basic authentication to secure rest apis created inside a Spring boot application. The secured rest api will ask for authentication details before giving access the data it secure. 1. Maven dependency To secure rest apis, we must include spring security related jar files in project runtime. Simplest way to add all required […]
In this spring boot2 RestTemplate timeout example, learn to configure connection timeout and read timeout in Spring RestTemplate with example. 1. RestTemplate default timeout By default, RestTemplate uses SimpleClientHttpRequestFactory which depends on default configuration of HttpURLConnection. Look inside the class source and you will find this. By default, resttemplate uses timeout property from JDK installed […]
In this Spring Boot RestTemplate POST request test example, we will create a POST API and then test it by sending request body along with request headers using postForEntity() method. 1. Maven dependencies Make sure to have spring-boot-starter-test dependency in the project to enable loading of spring text context, bean initialization and dependency management. 2. […]
In this, Spring Boot RestTemplate GET request example, learn to use RestTemplate to invoke REST GET API verify api response status code and response entity body. To create the rest apis, use the sourcecode provided in spring boot 2 rest api example. 1. Maven dependencies Make sure to have spring-boot-starter-test dependency in the project to […]
Learn to write Junit tests in spring boot applications. Also learn to use RestTemplate to invoke REST APIs and verify test results in success and error scenarios in this spring boot junit tutorial. To create the rest apis, use the sourcecode provided in spring boot 2 rest api example. 1. Maven dependencies Make sure to […]
Learn to consume HTTP POST REST API with Spring TestRestTemplate. In this post request test example, we will be sending request body along with request headers. 1. Maven dependencies Make sure, you have spring-boot-starter-test dependency in your project to get access to TestRestTemplate class in runtime. If you are using the @SpringBootTest annotation, a TestRestTemplate […]
Learn to create HTTP POST REST APIs using Spring boot 2 framework which accept JSON request and return JSON response to client. In this Spring Boot 2 REST POST API tutorial, we will create a REST API which returns list of employees after adding a new employee to collection. 1. Maven dependencies At first, create […]
In this spring rest tutorial, learn to create REST APIs using Spring boot 2 framework which return JSON responses to client. In this Spring Boot 2 REST API tutorial, we will create two simple GET and POST APIs step by step and test them. 1. Maven dependencies At first, create a simple maven web project […]
In this Spring boot tutorial, learn how we can build applications using spring retry module facility where we have to retry the request few times.
Spring boot log4j2 properties configuration example. This enables log4j logging into any spring boot application and start logging into console or file.
Learn to easily manage application cache from Spring boot caching support. Spring has some nice features around caching with help of cache annotations.
Spring boot @Async rest controller example. Learn to use spring async behavior with @EnableAsync annotation. Spring async completablefuture example.