Table of Contents
We want to play around with spring and test dependency-injection. Therefore we create packages, interfaces, and classes as in the following diagram:
So the idea is as followin:
-
We create two components:
CompoentAandComponentB -
ComponentBcan say hi to a given name by returning"Hello " + name -
ComponentAusesComponentBto return a greeting (e.g.return sayHi("World")) -
Each component has an interface and an implementation
-
Implementation is annotated with
@Named -
ComponentAImplusesComponentBand gets it via@Injectannotation. -
Write a JUnit test
ComponentATestthat verifies the expected result ofgreet()
