WireMock for Java Developers

Video Description

Learn to effectively integrate and build RESTful API clients into Java and Spring Boot applications using WireMock.

About This Video

  • This course will help students to learn about how to write unit tests involving RESTful API integrations
  • Write unit tests that cover all possible scenarios in a REST-based interaction

In Detail

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.

Publisher Resources

Download Example Code

Table of Contents

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

Product Information

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