WireMock for Java Developers

Video description

WireMock is a simulator for HTTP-based APIs or MockServer. REST APIs are everywhere today as they're the modern and easiest way to build functionality and expose them to the real world. When it comes to writing unit test cases that involve REST-based interactions, there is always a challenge in testing error responses, network faults, latency, and timeouts. WireMock will solve the problem of application code that depends on an external service by mocking the actual service.

In the microservices architecture, It is pretty common for services to depend on one another and it's always a challenge to write test cases for code that depends on other external services. WireMock provides the necessary tools to simulate an external service so that code that depends on the external service can be tested; this helps to build a robust REST client.

This course covers the following techniques using WireMock:

· Service virtualization

· Simulating an external service

· Simulating latency

· Simulating error responses

· Simulating network errors

Learn to integrate the most powerful HTTP Mock library, WireMock, into your applications to build a resilient and robust REST API client.

What You Will Learn

  • Complete knowledge of how to build resilient RESTful API clients
  • Write automated tests which involve RESTful API clients using JUnit
  • Using WireMock as a powerful tool to simulate HTTP interactions
  • Mock an external service using WireMock
  • Build a robust REST client by simulating network errors, network latency
  • Learn to mock a RESTful Service
  • Learn to write unit tests that involve RESTful API interactions

Audience

This course is for developers who would like to learn to build RESTful API clients using Spring WebClient, Java developers who would like to learn to build resilient RESTful API clients and developers who are working in the microservice architecture and would like to learn how to simulate other services involving REST API invocations. Developers who would like to write unit tests that cover latency, timeouts, and network faults and also who would like to write unit tests that depend on other services.

About The Author

Dilip Sundarraj: Dilip Sundarraj is a software engineer who has experience with building software since 2008. He is passionate about learning modern technologies and staying up to date with all the modern technologies, tools, frameworks, and more. He loves to share his knowledge with the world and that is one of the key reasons for him to be in the online teaching industry.

He loves interacting with other software developers and believes that this helps him share knowledge and learn from them. During his leisure time, he loves to play cricket, watch movies, and work out in the gym to have a balance between physical and mental strength.

Dilip has a YouTube channel named Code with Dilip, where he has been sharing a lot of technical content related to languages, frameworks, best practices, and more.

Table of contents

  1. Chapter 1 : Getting Started with Course
    1. Course Introduction Objectives
    2. Pre-Requisites
  2. Chapter 2 : Introduction to WireMock
    1. Why WireMock?
    2. What is WireMock?
    3. WireMock vs Mocking Libraries
  3. Chapter 3 : Setting up the WorkSpace for the course
    1. Overview of the application
    2. Set up the Movies RESTFUL Service
    3. Exploring the Movies RESTFUL Service
  4. Chapter 4 : Build REST Clients using Spring WebClient - Hands On
    1. Setting up the Movies App
    2. RestTemplate vs Spring WebClient
    3. Setting up the Movies Domain
    4. Build Movies REST Client using Spring WebClient
    5. Build Movies REST Client test using JUnit5
    6. WebClient - Retrieve Movie by Movie-ID
    7. WebClient - Retrieve Movie by Movie-Name
    8. WebClient - Retrieve Movie by Year
    9. WebClient - Add a new Movie -HTTP POST
    10. WebClient - Update a Movie - HTTP PUT
    11. WebClient - Delete a Movie - HTTP DELETE
  5. Chapter 5 : Setting Up WireMock
    1. Configuring WireMock
  6. Chapter 6 : Build Stubs Using WireMock - Hands On
    1. Overview
    2. Create the very first Stub
    3. How WireMock works Behind the scenes and Matches the Stub?
    4. URL Matching Stub - urlPathEqualTo()
    5. URL Matching Stub using urlPathMatching()
    6. Generate Dynamic Http Response using ResponseTemplateTransformer
    7. Stub with 400 HttpStatus as Response
    8. Stub matches a Query Param using urlEqualTo()
    9. Generate Dynamic Response Stub by reading Query Param from the request
    10. Stub with RequestBody - HTTP POST
    11. Dynamic Response Stub - HTTP POST
    12. Stub with 400 Bad Request Response - HTTP POST
    13. Stub for HTTP PUT
    14. Stub for HTTP Delete
  7. Chapter 7 : Verifying the Stubs - Hands On
    1. Why Verify the Stubs?
    2. Explore the verify DSL
  8. Chapter 8 : Simulating Server/Fault Responses - Hands On
    1. Introduction to Server/Fault Responses
    2. Simulating 5xx Response
    3. Simulating Fault Responses - Network Errors
  9. Chapter 9 : Simulating Latency - Hands On
    1. Configuring read/write Timeout - Spring Webclient
    2. Simulating Latency
  10. Chapter 10 : Selective Proxying - Hands On
    1. What is Selective Proxying?
    2. Simulating Selective Proxying
  11. Chapter 11 : Running WireMock on Junit 4
    1. WireMock on JUnit4
    2. Run WireMock on JUnit4
  12. Chapter 12 : Running WireMock on Spring Boot - Hands On
    1. Overview and Project SetUp
    2. Building the Client Code
    3. Run WireMock on Spring Boot using @AutoConfigureWireMock - Approach 1
    4. Run WireMock on Spring Boot using WireMockRule- Approach 2
  13. Chapter 13 : Running WireMock with Spring Boot and JUnit5
    1. Configuring Spring Boot for JUnit5
    2. Run WireMock with Spring Boot and JUnit5
    3. Run WireMock with Spring Boot/JUnit5 using WireMockExtension

Product information

  • Title: WireMock for Java Developers
  • Author(s): Dilip Sundarraj
  • Release date: October 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781839210747