Posts

Showing posts with the label Spring Boot

Spring Boot WireMock - Testing HTTP clients

Image
In this section, we'll develop a Spring Boot application that connects with a jsonplaceholder client with the help of RestClient and at the end  we will perform integration testing with WireMock  and   JUnit 5 . jsonplaceholder JSONPlaceholder is a free online REST API that we can use whenever we need some fake data. RestClient RestClient is a synchronous client to perform HTTP requests. It is a higher-order API since it performs HTTP requests by using an HTTP client library like the JDK HttpClient, Apache HttpComponents, and others. More Info - click here WireMock WireMock is a popular open-source library for API mock testing. More Info - click here Advantages :      > No load on the remote server.      > Full control over the response.      > Works offline.           JUnit 5 For writing and running unit tests and integration tests for any Java application, the JUnit framework is a great option. It is already included in the spring-boot-starter-test module of Spring Boo

Spring Boot htmx Thymeleaf - CRUD Todo App

Image
In this section, we will create a Todo CRUD app with Spring Boot , htmx , Thymeleaf ,  Bootstrap , and PostgreSQL . About htmx HTMX can be used for the API/server-side calls directly in the HTML. More Info:  click here We can use HTMX to create interactive templates in our Spring Boot application. We can dynamically call and fetch data from the server by using simple HTML attributes like hx-get, hx-put, etc. We'll cover those in this article. We will be exploring the basis of HTMX by creating a basic CRUD application. Technologies Used Java 17 Spring Boot 3.3.0 Spring Data JPA PostgreSQL Thymeleaf  htmx Bootstrap Creating a spring boot application First, open the Spring initializr  https://start.spring.io Then, Provide the Group and Artifact name. We have provided Group name  com.knf.dev.demo  and Artifact  spring-boot-htmx-crud . Here I selected the Maven project - language  Java 17  -  Spring Boot 3.3.0 ,   Spring Web, Spring Data JPA , Lombok , PostgreSQL Driver , and  Thymeleaf