baeldung

How to Mock HttpServletRequest

1. Overview In this quick tutorial, we'll look at a few ways to mock a HttpServletRequest object. First, we'll start with a fully functional mock type – MockHttpServletRequest from the Spring Test library. Then, we'll see how to test using two popular mocking libraries – Mockito and JMockit. Finally, we'll see how to test using an anonymous subclass. 2. Testing HttpServletRequest Testing Servlets can be tricky when we want to...

baeldung

Starting Spring Boot Application in Docker With Profile

1. Introduction We all know how popular Docker is and how fashionable for Java developers it is to containerize their Spring Boot applications. However, how we set profiles in a dockerized Spring Boot application can be a question for some developers. In this tutorial, we will explain how to start a Spring Boot application with profiles when it's in a Docker container. 2. Basic Dockerfile Generally, to dockerize a Spring Boot...