Mutual SSL authentication

In deze blog laat ik zien wat de stappen zijn om certificaten te maken voor server en client applicaties.

Voor testen kun je de key- en trust stores maken zonder CA. Op productie zal er altijd een CA tussen zitten. Beide manieren worden hieronder besproken.

Een demo project met een server en client die ssl gebruiken (ook als authenticatie) is hier te vinden:

Lees meer »

Going springless: no more magic!

Working with Spring Boot (but also working with JEE/Jakarta EE) can be a joyful experience. Within minutes you can create a  new RESTfull webservice  to which you can quickly and easily add circuit breakers, distributed tracing, security, database access, accessing other microservices, fallbacks, retries, service discovery, configuration management, many other things and of course you can use the great Spring DI framework.

Lees meer »

List of Spring Boot Starter Dependencies

[Index of Spring blogs]


Lees meer »

Testing the Spring MVC layer

[Index of Spring blogs]

Use “spring-boot-starter-test” to add all dependencies:


You can annotate the test class with :

  • (nothing)
  • @SpringBootTest(webEnvironment = MOCK / RANDOM_PORT / DEFINED_PORT)
  • @AutoConfigureMockMvc
  • @WebMvcTest

To make rest call’s to the controllers, you can use one of the following:

  • RestTemplate
  • TestRestTemplate
  • RestAssuredMockMvc
  • MockMvc
  • WebTestClient (only when using webflux)

@SpringBootTest will load your complete Spring application, but without the Servlet container when specifying (webEnvironment = MOCK).
When using webEnvironment = RANDOM_PORT, a random port is used (which you can find in the test using @LocalServerPort).
It is also possible to autowire a TestRestTemplate, RestAssuredMockMvc or MockMvc which you can use to test the application using relative url’s.

@MockBean can be used to mock any bean in the application environment.

To test the serialization and deserialization of a JSON object, you can use @JsonTest

To test a web client, you can use @RestClientTest

Examples of using the different annotations and rest clients can be found below:

Lees meer »

Spring WebFlux samples and links

[Index of Spring blogs]


Spring5 documentation about webFlux:

Spring Boot documentation about webFlux:

Spring testing documentation about Spring Web Reactive:


Spring WebMVC samples and links

[Index of Spring blogs]


Spring5 documentation about webMVC:

Spring Boot documentation about webMVC:

Spring testing documentation about MVC Test Framework:


Unittesting: using AssertJ’s assertThat

JUnit4 provides a standard dependency to the Hamcrest Assertion Frameworks which makes the following assertions possible:


Many matchers beside equalTo are available, but the problem to me is that I always have search for the appropriate one that I want to use, and static import that matcher.

An alternative to Hamcrest, is AssertJ which provides a fluent interface for the assertions, so you can use your IDE’s code completion for searching the matchers.

AssertJ uses the following syntax:


With AssertJ, it is also possible to use soft assertions which makes is possible to do multiple checks, and test all of them instead of stopping the test on the first failure.

SoftAssertions softly = new SoftAssertions();

This results in the following error:

The following 2 assertions failed:
1) expected:<"Rob[b]ert"> but was:<"Rob[]ert">
at MyTest.test( expected:<"Rob[b]ert"> but was:<"Rob[]ert">
2) expected:<"[S]on"> but was:<"[Z]on">
at MyTest.test( expected:<"[S]on"> but was:<"[Z]on">

More about AssertJ can be found here:

To add a dependency to AssertJ, use the following: