Commits

Hector Miuler Malpica Gallegos committed ae42deb

proyecto para prueba de scala con spring

Comments (0)

Files changed (7)

+# use glob syntax.
+syntax: glob
+*.ser
+*.class
+*~
+*.bak
+#*.off
+*.old
+
+# eclipse conf file
+.settings
+.classpath
+.project
+.manager
+.scala_dependencies
+
+# idea
+.idea
+*.iml
+
+# building
+target
+build
+null
+tmp*
+temp*
+dist
+test-output
+build.log
+
+# other scm
+.svn
+.CVS
+.hg*
+
+# switch to regexp syntax.
+#  syntax: regexp
+#  ^\.pc/
+
+#SHITTY output not in target directory
+build.log
+target
+.*\.swp
+<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.miuler.prueba</groupId>
+  <artifactId>spring-scala</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>${project.artifactId}</name>
+  <description>My wonderfull scala app</description>
+  <inceptionYear>2010</inceptionYear>
+  <licenses>
+    <license>
+      <name>My License</name>
+      <url>http://....</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
+  <properties>
+    <maven.compiler.source>1.5</maven.compiler.source>
+    <maven.compiler.target>1.5</maven.compiler.target>
+    <encoding>UTF-8</encoding>
+    <scala.version>2.8.0</scala.version>
+  </properties>
+
+<!--
+  <repositories>
+    <repository>
+      <id>scala-tools.org</id>
+      <name>Scala-Tools Maven2 Repository</name>
+      <url>http://scala-tools.org/repo-releases</url>
+    </repository>
+  </repositories>
+
+  <pluginRepositories>
+    <pluginRepository>
+      <id>scala-tools.org</id>
+      <name>Scala-Tools Maven2 Repository</name>
+      <url>http://scala-tools.org/repo-releases</url>
+    </pluginRepository>
+  </pluginRepositories>
+-->
+  <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.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.scala-tools.testing</groupId>
+      <artifactId>specs_${scala.version}</artifactId>
+      <version>1.6.5</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.scalatest</groupId>
+      <artifactId>scalatest</artifactId>
+      <version>1.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <sourceDirectory>src/main/scala</sourceDirectory>
+    <testSourceDirectory>src/test/scala</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.scala-tools</groupId>
+        <artifactId>maven-scala-plugin</artifactId>
+        <version>2.15.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.6</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>

src/main/scala/com/miuler/prueba/App.scala

+package com.miuler.prueba
+
+/**
+ * @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))
+  }
+
+}

src/test/scala/samples/junit.scala

+package samples
+
+import org.junit._
+import Assert._
+
+@Test
+class AppTest {
+
+    @Test
+    def testOK() = assertTrue(true)
+
+//    @Test
+//    def testKO() = assertTrue(false)
+
+}
+
+

src/test/scala/samples/scalatest.scala

+/*
+ * 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.Spec
+import org.scalatest.matchers.MustMatchers
+
+class MapSpec extends Spec with MustMatchers {
+
+  describe("A Map") {
+
+    it("should only contain keys and values that were added to it") {
+      Map("ho" -> 12) must (not contain key ("hi") and not contain value (13))
+      Map("hi" -> 13) must (contain key ("hi") and contain value (13))
+    }
+
+    it("should report its size as the number of key/value pairs it contains") {
+      Map() must have size (0)
+      Map("ho" -> 12) must have size (1)
+      Map("hi" -> 13, "ho" -> 12) must have size (2)
+    }
+  }
+}
+

src/test/scala/samples/specs.scala

+package samples
+
+import org.junit.runner.RunWith
+import org.specs._
+import org.specs.matcher._
+import org.specs.runner.{ JUnitSuiteRunner, JUnit }
+//import org.scalacheck.Gen
+
+/**
+ * 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://code.google.com/p/specs.
+ *
+ */
+@RunWith(classOf[JUnitSuiteRunner])
+class MySpecTest extends Specification with JUnit /*with ScalaCheck*/ {
+
+  "My" should {
+    "allow " in {
+      
+      //0
+    }
+    "deny " in {
+      //0
+    }
+  }
+  
+  "A List" should {
+    "have a size method returning the number of elements in the list" in {
+      List(1, 2, 3).size must_== 3
+    }
+    // add more examples here
+    // ...
+  }
+
+}
+
+object MySpecMain {
+  def main(args: Array[String]) {
+    new MySpecTest().main(args)
+  }
+}