• Spring: Bean qualification

    In this post I present how you can control a situation in which there are multiple beans that qualifies for an injection point in Spring. The material here has been tested with Spring Framework 4.3. The problem Let’s first take a look at the problem. Imagine you have this interface: And two different implementations of this. First this: And then this:… Continue Reading

  • Spring Boot and Gradle: Separating tests

    In this post I will present 4 different approaches to separating unit tests from integration tests, so that they can be run independently of each other. Here’s the 4 different approaches: Separation based on name patterns Separation based on JUnit categories Separation based on Spring’s @IfProfileValue Separation based on different source directories These approaches can easily be extended to apply… Continue Reading

  • Spring Boot 1.4: Gherkin tests

    In this post I show how you can implement Gherkin tests for Spring Boot 1.4.1. Here is an example of a Gherkin based test script: The Feature, Scenario, Scenario Outline, Given, When, Then and And constructs are part of the Gherkin test language [1]. Such tests are popular in Behavior-driven development (BDD) and is meant as a common tool between… Continue Reading

  • Spring 4.3: Custom annotations

    In this post I will show you how to bend the Spring Framework a little bit. In particular I will show you how you can make code like this: @BusinessService declares a perfectly valid Spring bean. It comes with the support for @NotNull parameter checks. @NotNull is from the bean validation API – no need to exercise too many keystrokes. @LocalizedMessage is a perfectly valid injection capable annotation.… Continue Reading

  • Spring 4.3: Introducing the InjectionPoint class

    Did you know that Spring Framework 4.3 comes with a “hidden” gem: the InjectionPoint class ? At the time of writing this post, InjectionPoint is nowhere to be found in the Spring Framework Reference Documentation [2]. About the InjectionPoint class The InjectionPoint class [1] is a new feature that you can use in @Bean producer methods. It is specifically useful in @Bean methods that produces prototype scoped beans.… Continue Reading