diff --git a/dependency-injection/pom.xml b/dependency-injection/pom.xml
index 40970e130..4746d5835 100644
--- a/dependency-injection/pom.xml
+++ b/dependency-injection/pom.xml
@@ -13,6 +13,11 @@
junit
junit
test
+
+
+ org.mockito
+ mockito-core
+ test
com.google.inject
diff --git a/dependency-injection/src/test/java/com/iluwatar/dependency/injection/AdvancedWizardTest.java b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/AdvancedWizardTest.java
new file mode 100644
index 000000000..5f7733a99
--- /dev/null
+++ b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/AdvancedWizardTest.java
@@ -0,0 +1,40 @@
+package com.iluwatar.dependency.injection;
+
+import org.junit.Test;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+/**
+ * Date: 12/10/15 - 8:40 PM
+ *
+ * @author Jeroen Meulemeester
+ */
+public class AdvancedWizardTest extends StdOutTest {
+
+ /**
+ * Test if the {@link AdvancedWizard} smokes whatever instance of {@link Tobacco} is passed to him
+ * through the constructor parameter
+ */
+ @Test
+ public void testSmokeEveryThing() throws Exception {
+
+ final Tobacco[] tobaccos = {
+ new OldTobyTobacco(), new RivendellTobacco(), new SecondBreakfastTobacco()
+ };
+
+ for (final Tobacco tobacco : tobaccos) {
+ final AdvancedWizard advancedWizard = new AdvancedWizard(tobacco);
+ advancedWizard.smoke();
+
+ // Verify if the wizard is smoking the correct tobacco ...
+ verify(getStdOutMock(), times(1)).println("AdvancedWizard smoking " + tobacco.getClass().getSimpleName());
+
+ // ... and nothing else is happening.
+ verifyNoMoreInteractions(getStdOutMock());
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/dependency-injection/src/test/java/com/iluwatar/dependency/injection/GuiceWizardTest.java b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/GuiceWizardTest.java
new file mode 100644
index 000000000..d84ffad84
--- /dev/null
+++ b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/GuiceWizardTest.java
@@ -0,0 +1,78 @@
+package com.iluwatar.dependency.injection;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+import org.junit.Test;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+/**
+ * Date: 12/10/15 - 8:57 PM
+ *
+ * @author Jeroen Meulemeester
+ */
+public class GuiceWizardTest extends StdOutTest {
+
+ /**
+ * Test if the {@link GuiceWizard} smokes whatever instance of {@link Tobacco} is passed to him
+ * through the constructor parameter
+ */
+ @Test
+ public void testSmokeEveryThingThroughConstructor() throws Exception {
+
+ final Tobacco[] tobaccos = {
+ new OldTobyTobacco(), new RivendellTobacco(), new SecondBreakfastTobacco()
+ };
+
+ for (final Tobacco tobacco : tobaccos) {
+ final GuiceWizard guiceWizard = new GuiceWizard(tobacco);
+ guiceWizard.smoke();
+
+ // Verify if the wizard is smoking the correct tobacco ...
+ verify(getStdOutMock(), times(1)).println("GuiceWizard smoking " + tobacco.getClass().getSimpleName());
+
+ // ... and nothing else is happening.
+ verifyNoMoreInteractions(getStdOutMock());
+ }
+
+ }
+
+ /**
+ * Test if the {@link GuiceWizard} smokes whatever instance of {@link Tobacco} is passed to him
+ * through the Guice google inject framework
+ */
+ @Test
+ public void testSmokeEveryThingThroughInjectionFramework() throws Exception {
+
+ @SuppressWarnings("unchecked")
+ final Class extends Tobacco>[] tobaccos = new Class[]{
+ OldTobyTobacco.class, RivendellTobacco.class, SecondBreakfastTobacco.class
+ };
+
+ for (final Class extends Tobacco> tobaccoClass : tobaccos) {
+ // Configure the tobacco in the injection framework ...
+ final Injector injector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(Tobacco.class).to(tobaccoClass);
+ }
+ });
+
+ // ... and create a new wizard with it
+ final GuiceWizard guiceWizard = injector.getInstance(GuiceWizard.class);
+ guiceWizard.smoke();
+
+ // Verify if the wizard is smoking the correct tobacco ...
+ verify(getStdOutMock(), times(1)).println("GuiceWizard smoking " + tobaccoClass.getSimpleName());
+
+ // ... and nothing else is happening.
+ verifyNoMoreInteractions(getStdOutMock());
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/dependency-injection/src/test/java/com/iluwatar/dependency/injection/SimpleWizardTest.java b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/SimpleWizardTest.java
new file mode 100644
index 000000000..69895a493
--- /dev/null
+++ b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/SimpleWizardTest.java
@@ -0,0 +1,33 @@
+package com.iluwatar.dependency.injection;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.PrintStream;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+/**
+ * Date: 12/10/15 - 8:26 PM
+ *
+ * @author Jeroen Meulemeester
+ */
+public class SimpleWizardTest extends StdOutTest {
+
+ /**
+ * Test if the {@link SimpleWizard} does the only thing it can do: Smoke it's {@link
+ * OldTobyTobacco}
+ */
+ @Test
+ public void testSmoke() {
+ final SimpleWizard simpleWizard = new SimpleWizard();
+ simpleWizard.smoke();
+ verify(getStdOutMock(), times(1)).println("SimpleWizard smoking OldTobyTobacco");
+ verifyNoMoreInteractions(getStdOutMock());
+ }
+
+}
\ No newline at end of file
diff --git a/dependency-injection/src/test/java/com/iluwatar/dependency/injection/StdOutTest.java b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/StdOutTest.java
new file mode 100644
index 000000000..13c18fcd1
--- /dev/null
+++ b/dependency-injection/src/test/java/com/iluwatar/dependency/injection/StdOutTest.java
@@ -0,0 +1,53 @@
+package com.iluwatar.dependency.injection;
+
+import org.junit.After;
+import org.junit.Before;
+
+import java.io.PrintStream;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Date: 12/10/15 - 8:37 PM
+ *
+ * @author Jeroen Meulemeester
+ */
+public abstract class StdOutTest {
+
+ /**
+ * The mocked standard out {@link PrintStream}, required since the actions of the wizard don't
+ * have any influence on any other accessible objects, except for writing to std-out using {@link
+ * System#out}
+ */
+ private final PrintStream stdOutMock = mock(PrintStream.class);
+
+ /**
+ * Keep the original std-out so it can be restored after the test
+ */
+ private final PrintStream stdOutOrig = System.out;
+
+ /**
+ * Inject the mocked std-out {@link PrintStream} into the {@link System} class before each test
+ */
+ @Before
+ public void setUp() {
+ System.setOut(this.stdOutMock);
+ }
+
+ /**
+ * Removed the mocked std-out {@link PrintStream} again from the {@link System} class
+ */
+ @After
+ public void tearDown() {
+ System.setOut(this.stdOutOrig);
+ }
+
+ /**
+ * Get the mocked stdOut {@link PrintStream}
+ *
+ * @return The stdOut print stream mock, renewed before each test
+ */
+ final PrintStream getStdOutMock() {
+ return this.stdOutMock;
+ }
+}