diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..4f81299
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.configuration.updateBuildConfiguration": "automatic"
+}
diff --git a/pom.xml b/pom.xml
index f1464ae..9e9cca1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,6 +18,13 @@
1.7
+
+
+ com.gitlesson.demolibrary
+ http://192.168.1.5:8087/repository/Alten-examples/
+
+
+
junit
@@ -25,6 +32,11 @@
4.11
test
+
+ com.gitlesson.demolibrary
+ demolibrary
+ 1.0
+
diff --git a/src/main/java/com/gitlesson/App.java b/src/main/java/com/gitlesson/App.java
index 8400336..7c58ac1 100644
--- a/src/main/java/com/gitlesson/App.java
+++ b/src/main/java/com/gitlesson/App.java
@@ -1,13 +1,14 @@
package com.gitlesson;
+import com.gitlesson.demolibrary.TestLibrary;
+
/**
- * Hello world!
+ * Prints the string that gets from TestLibrary!
*
*/
-public class App
-{
- public static void main( String[] args )
- {
- System.out.println( "Hello World!" );
+public class App {
+ public static void main(String[] args) {
+ String test = TestLibrary.getText();
+ System.out.println(test);
}
}
diff --git a/src/test/java/com/gitlesson/AppTest.java b/src/test/java/com/gitlesson/AppTest.java
index a748244..48677e3 100644
--- a/src/test/java/com/gitlesson/AppTest.java
+++ b/src/test/java/com/gitlesson/AppTest.java
@@ -1,20 +1,49 @@
package com.gitlesson;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
+import com.gitlesson.demolibrary.TestLibrary;
/**
* Unit test for simple App.
*/
-public class AppTest
-{
+public class AppTest {
+ private final PrintStream stardardOut = System.out;
+ private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
+
+ /**
+ * substitute the standard output with
+ * a new object because we need to check
+ * if the method Main writes the correct string
+ */
+ @Before
+ public void setup() {
+ System.setOut(new PrintStream(outputStreamCaptor));
+ }
+
+ /**
+ * Reset the standard out to the system one
+ */
+ @After
+ public void restore() {
+ System.setOut(stardardOut);
+ }
+
/**
* Rigorous Test :-)
*/
@Test
- public void shouldAnswerWithTrue()
- {
- assertTrue( true );
+ public void shouldAnswerWithTrue() {
+ String[] args = new String[0];
+ App.main(args);
+ String result = outputStreamCaptor.toString();
+ String expected = TestLibrary.getText();
+ assertEquals("This strings should match", expected, result);
}
}