Scala App first draft

Project: DemoAccountApp
Task: T101
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..66b68f8
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,88 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>com.demo.account</groupId>
+  <artifactId>demoaccountapp</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>${project.artifactId}</name>
+  <description>demo scala account app</description>
+  <inceptionYear>2016</inceptionYear>
+
+  <properties>
+    <maven.compiler.source>1.6</maven.compiler.source>
+    <maven.compiler.target>1.6</maven.compiler.target>
+    <encoding>UTF-8</encoding>
+    <scala.version>2.11.5</scala.version>
+    <scala.compat.version>2.11</scala.compat.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-library</artifactId>
+      <version>${scala.version}</version>
+    </dependency>
+
+    <!-- Test -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.specs2</groupId>
+      <artifactId>specs2-core_${scala.compat.version}</artifactId>
+      <version>2.4.16</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.scalatest</groupId>
+      <artifactId>scalatest_${scala.compat.version}</artifactId>
+      <version>2.2.4</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <sourceDirectory>src/main/scala</sourceDirectory>
+    <testSourceDirectory>src/test/scala</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <!-- see http://davidb.github.com/scala-maven-plugin -->
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>scala-maven-plugin</artifactId>
+        <version>3.2.0</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compile</goal>
+              <goal>testCompile</goal>
+            </goals>
+            <configuration>
+              <args>
+                <arg>-make:transitive</arg>
+                <arg>-dependencyfile</arg>
+                <arg>${project.build.directory}/.scala_dependencies</arg>
+              </args>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.18.1</version>
+        <configuration>
+          <useFile>false</useFile>
+          <disableXmlReport>true</disableXmlReport>
+          <!-- If you have classpath issue like NoDefClassError,... -->
+          <!-- useManifestOnlyJar>false</useManifestOnlyJar -->
+          <includes>
+            <include>**/*Test.*</include>
+            <include>**/*Suite.*</include>
+          </includes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/main/scala/com/demo/account/App.scala b/src/main/scala/com/demo/account/App.scala
new file mode 100644
index 0000000..693ac82
--- /dev/null
+++ b/src/main/scala/com/demo/account/App.scala
@@ -0,0 +1,15 @@
+package com.demo.account
+
+/**
+ * @author ${user.name}
+ */
+object App {
+  
+  def foo(x : Array[String]) = x.foldLeft("")((a,b) => a + b)
+  
+  def main(args : Array[String]) {
+    println( "Hello World!" )
+    println("concat arguments = " + foo(args))
+  }
+
+}
diff --git a/src/test/scala/samples/junit.scala b/src/test/scala/samples/junit.scala
new file mode 100644
index 0000000..89513d5
--- /dev/null
+++ b/src/test/scala/samples/junit.scala
@@ -0,0 +1,17 @@
+package samples
+
+import org.junit._
+import Assert._
+
+@Test
+class AppTest {
+
+    @Test
+    def testOK() = assertTrue(true)
+
+//    @Test
+//    def testKO() = assertTrue(false)
+
+}
+
+
diff --git a/src/test/scala/samples/scalatest.scala b/src/test/scala/samples/scalatest.scala
new file mode 100644
index 0000000..319409b
--- /dev/null
+++ b/src/test/scala/samples/scalatest.scala
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2001-2009 Artima, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package samples
+
+/*
+ScalaTest facilitates different styles of testing by providing traits you can mix
+together to get the behavior and syntax you prefer.  A few examples are
+included here.  For more information, visit:
+
+http://www.scalatest.org/
+
+One way to use ScalaTest is to help make JUnit or TestNG tests more
+clear and concise. Here's an example:
+*/
+import scala.collection.mutable.Stack
+import org.scalatest.Assertions
+import org.junit.Test
+
+class StackSuite extends Assertions {
+
+  @Test def stackShouldPopValuesIinLastInFirstOutOrder() {
+    val stack = new Stack[Int]
+    stack.push(1)
+    stack.push(2)
+    assert(stack.pop() === 2)
+    assert(stack.pop() === 1)
+  }
+
+  @Test def stackShouldThrowNoSuchElementExceptionIfAnEmptyStackIsPopped() {
+    val emptyStack = new Stack[String]
+    intercept[NoSuchElementException] {
+      emptyStack.pop()
+    }
+  }
+}
+
+/*
+Here's an example of a FunSuite with ShouldMatchers mixed in:
+*/
+import org.scalatest.FunSuite
+import org.scalatest.matchers.ShouldMatchers
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+@RunWith(classOf[JUnitRunner])
+class ListSuite extends FunSuite with ShouldMatchers {
+
+  test("An empty list should be empty") {
+    List() should be ('empty)
+    Nil should be ('empty)
+  }
+
+  test("A non-empty list should not be empty") {
+    List(1, 2, 3) should not be ('empty)
+    List("fee", "fie", "foe", "fum") should not be ('empty)
+  }
+
+  test("A list's length should equal the number of elements it contains") {
+    List() should have length (0)
+    List(1, 2) should have length (2)
+    List("fee", "fie", "foe", "fum") should have length (4)
+  }
+}
+
+/*
+ScalaTest also supports the behavior-driven development style, in which you
+combine tests with text that specifies the behavior being tested. Here's
+an example whose text output when run looks like:
+
+A Map
+- should only contain keys and values that were added to it
+- should report its size as the number of key/value pairs it contains
+*/
+import org.scalatest.FunSpec
+import scala.collection.mutable.Stack
+
+class ExampleSpec extends FunSpec {
+
+  describe("A Stack") {
+
+    it("should pop values in last-in-first-out order") {
+      val stack = new Stack[Int]
+      stack.push(1)
+      stack.push(2)
+      assert(stack.pop() === 2)
+      assert(stack.pop() === 1)
+    }
+
+    it("should throw NoSuchElementException if an empty stack is popped") {
+      val emptyStack = new Stack[Int]
+      intercept[NoSuchElementException] {
+        emptyStack.pop()
+      }
+    }
+  }
+}
diff --git a/src/test/scala/samples/specs.scala b/src/test/scala/samples/specs.scala
new file mode 100644
index 0000000..9e4dfe9
--- /dev/null
+++ b/src/test/scala/samples/specs.scala
@@ -0,0 +1,31 @@
+package samples
+
+import org.junit.runner.RunWith
+import org.specs2.mutable._
+import org.specs2.runner._
+  
+
+/**
+ * Sample specification.
+ * 
+ * This specification can be executed with: scala -cp <your classpath=""> ${package}.SpecsTest
+ * Or using maven: mvn test
+ *
+ * For more information on how to write or run specifications, please visit: 
+ *   http://etorreborre.github.com/specs2/guide/org.specs2.guide.Runners.html
+ *
+ */
+@RunWith(classOf[JUnitRunner])
+class MySpecTest extends Specification {
+  "The 'Hello world' string" should {
+    "contain 11 characters" in {
+      "Hello world" must have size(11)
+    }
+    "start with 'Hello'" in {
+      "Hello world" must startWith("Hello")
+    }
+    "end with 'world'" in {
+      "Hello world" must endWith("world")
+    }
+  }
+}