Skip to content

Commit 02f70ab

Browse files
committed
Sample App Built
0 parents  commit 02f70ab

File tree

7 files changed

+107
-0
lines changed

7 files changed

+107
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Scala Sample with PostgreSQL
2+
=================
3+
4+
Build sample for Scala with PostgreSQL using PostgreSQL-Async, JUnit for unit tests and Scoverage for code coverage.

build.sbt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name := "scala"
2+
3+
version := "0.98.5"
4+
5+
scalaVersion := "2.10.2"
6+
7+
crossScalaVersions := Seq("2.10.2", "2.10.3")
8+
9+
libraryDependencies ++= Seq(
10+
"junit" % "junit" % "4.5",
11+
"org.scalatest" % "scalatest_2.10" % "2.2.0",
12+
//"org.scalatest" % "scalatest_2.11" % "2.2.0-RC2",
13+
//"org.scalatest" %% "scalatest" % "2.1.6" % "test",
14+
"com.github.mauricio" % "postgresql-async_2.10" % "0.2.12"
15+
//"com.github.mauricio" %% "postgresql-async" % "0.2.6"
16+
)
17+
18+
testOptions in Test <+= (target in Test) map {
19+
t => Tests.Argument(TestFrameworks.ScalaTest, "junitxml(directory=\"%s\")" format (t / "../shippable/testresults"))
20+
}
21+
22+
instrumentSettings
23+
24+
ScoverageKeys.minimumCoverage := 70
25+
26+
ScoverageKeys.failOnMinimumCoverage := false
27+
28+
ScoverageKeys.highlighting := {
29+
if (scalaBinaryVersion.value == "2.10") false
30+
else false
31+
}

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.1

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "0.99.5")

shippable.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: scala
2+
3+
scala:
4+
- 2.10.2
5+
6+
addons:
7+
postgresql: "9.3"
8+
9+
before_script:
10+
- psql -c 'DROP DATABASE IF EXISTS test' -U postgres
11+
- psql -c 'CREATE DATABASE test;' -U postgres
12+
13+
script:
14+
- export SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:PermSize=256M -XX:MaxPermSize=512M"
15+
- sbt clean scoverage:test
16+
17+
after_script:
18+
- mkdir -p shippable/codecoverage
19+
- mv target/scala-2.10/coverage-report/cobertura.xml shippable/codecoverage/
20+
21+
notifications:
22+
email:
23+
- exampleone@org.com
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.shippable
2+
3+
import com.github.mauricio.async.db.postgresql.PostgreSQLConnection
4+
import com.github.mauricio.async.db.postgresql.util.URLParser
5+
import com.github.mauricio.async.db.util.ExecutorServiceUtils.CachedExecutionContext
6+
import com.github.mauricio.async.db.{RowData, QueryResult, Connection}
7+
import scala.concurrent.duration._
8+
import scala.concurrent.{Await, Future}
9+
10+
class HelloWorld {
11+
def returnValue(): String= {
12+
13+
val configuration = URLParser.parse("jdbc:postgresql://localhost:5233/test?user=postgres")
14+
val connection: Connection = new PostgreSQLConnection(configuration)
15+
var finalResult = ""
16+
17+
Await.result(connection.connect, 5 seconds)
18+
19+
val future: Future[QueryResult] = connection.sendQuery("SELECT * FROM users WHERE username='lindsaybluth';")
20+
21+
val mapResult: Future[Any] = future.map(queryResult => queryResult.rows match {
22+
case Some(resultSet) => {
23+
val row : RowData = resultSet.head
24+
finalResult = row(2).toString
25+
}
26+
case None => -1
27+
}
28+
)
29+
val result = Await.result( mapResult, 5 seconds )
30+
connection.disconnect
31+
return finalResult
32+
}
33+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.shippable
2+
3+
import org.scalatest.junit.JUnitSuite
4+
import junit.framework.Assert._
5+
import org.junit.Test
6+
7+
class TestStuff extends JUnitSuite {
8+
val calc = new HelloWorld
9+
10+
@ Test def readHelloWorld {
11+
val result: Boolean = calc.returnValue().containsSlice("lindsay@bluth.com")
12+
assertEquals(true, result)
13+
}
14+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy