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:
CompoentA
andComponentB
-
ComponentB
can say hi to a given name by returning"Hello " + name
-
ComponentA
usesComponentB
to return a greeting (e.g.return sayHi("World")
) -
Each component has an interface and an implementation
-
Implementation is annotated with
@Named
-
ComponentAImpl
usesComponentB
and gets it via@Inject
annotation. -
Write a JUnit test
ComponentATest
that verifies the expected result ofgreet()