Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
754 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package freeslick.profile | ||
|
||
import com.typesafe.slick.testkit | ||
import com.typesafe.slick.testkit.tests._ | ||
import com.typesafe.slick.testkit.util._ | ||
import freeslick.DB2Profile | ||
import freeslick.testkit._ | ||
import org.junit.runner.RunWith | ||
import slick.jdbc.meta.MTable | ||
import slick.util.Logging | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
@RunWith(classOf[Testkit]) | ||
class DB2ITTest extends FreeslickDriverTest(DB2Test.DB2Test("db2")) { | ||
override def tests = { | ||
super.tests | ||
.filterNot(_ == classOf[testkit.tests.JoinTest]) // Replaced with a FreeslickJoinTest | ||
.filterNot(_ == classOf[testkit.tests.MutateTest]) // DB2 has restrictions on mutable RowSets see FreeslickMutateTest | ||
//Seq(classOf[UUIDTest]) | ||
} | ||
} | ||
|
||
@RunWith(classOf[Testkit]) | ||
class DB2NoTSITTest extends FreeslickDriverTest(DB2Test.DB2Test("db2NoTableSpace")) { | ||
override def tests = { | ||
Seq(classOf[testkit.tests.ModelBuilderTest]) // testing syntax if no tablespaces specified | ||
} | ||
} | ||
|
||
object DB2Test extends Logging { | ||
def DB2Test(testDBName: String): TestDB = new ExternalJdbcTestDB(testDBName) { | ||
val driver = new DB2Profile { | ||
override def connectionConfig = Some(config.getConfig("adminConn")) | ||
} | ||
import driver.api._ | ||
|
||
def adminSchema: String = config.getConfig("adminConn").getString("user").toUpperCase | ||
def mTableIdentifier(mTable: MTable): String = | ||
mTable.name.schema.map(driver.quoteIdentifier(_) + ".").getOrElse("") + driver.quoteIdentifier(mTable.name.name) | ||
override def localTables(implicit ec: ExecutionContext): DBIO[Vector[String]] = { | ||
MTable.getTables(None, Some(adminSchema), None, Some(Seq("TABLE"))).map(_.map(mq => mTableIdentifier(mq))) | ||
} | ||
|
||
override def localSequences(implicit ec: ExecutionContext): DBIO[Vector[String]] = { | ||
sql"select sequence_schema, sequence_name from user_sequences".as[(String, String)].map(_.map{case(schema, name) => | ||
s"${driver.quoteIdentifier(schema)}.${driver.quoteIdentifier(name)}"}) | ||
} | ||
|
||
override def dropUserArtifacts(implicit session: profile.Backend#Session) = { | ||
blockingRunOnSession { implicit ec => | ||
for { | ||
tables <- localTables | ||
_ <- DBIO.seq(tables.map(t => sqlu"""drop table #$t"""): _*) | ||
sequences <- localSequences | ||
_ <- DBIO.seq(sequences.map(s => sqlu"drop sequence #$s"): _*) | ||
} yield () | ||
} | ||
} | ||
|
||
override lazy val capabilities = driver.capabilities + TestDB.capabilities.plainSql | ||
} | ||
} |
12 changes: 9 additions & 3 deletions
12
...scala/freeslick/FreeslickDriverTest.scala → ...eeslick/profile/FreeslickDriverTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 13 additions & 4 deletions
17
src/it/scala/freeslick/OracleTest.scala → .../scala/freeslick/profile/OracleTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/it/scala/freeslick/BooleanTest.scala → ...scala/freeslick/testkit/BooleanTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/it/scala/freeslick/FetchOffsetTest.scala → ...a/freeslick/testkit/FetchOffsetTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package freeslick | ||
package freeslick.testkit | ||
|
||
import com.typesafe.slick.testkit.util.{AsyncTest, JdbcTestDB} | ||
|
||
|
5 changes: 2 additions & 3 deletions
5
...cala/freeslick/FreeslickGroupByTest.scala → ...eslick/testkit/FreeslickGroupByTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...t/scala/freeslick/FreeslickJoinTest.scala → ...freeslick/testkit/FreeslickJoinTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package freeslick.testkit | ||
|
||
import com.typesafe.slick.testkit.util.{AsyncTest, JdbcTestDB} | ||
|
||
class FreeslickMutateTest extends AsyncTest[JdbcTestDB] { | ||
|
||
import tdb.profile.api._ | ||
|
||
def testMutate = ifCapF(jcap.mutable) { | ||
class Data(tag: Tag) extends Table[(Int,String)](tag, "DATA") { | ||
def id = column[Int]("ID", O.PrimaryKey) | ||
def data = column[String]("DATA") | ||
def * = (id, data) | ||
} | ||
val data = TableQuery[Data] | ||
|
||
var seenEndMarker = false | ||
db.run(data.schema.create >> (data ++= Seq((1, "a"), (2, "b"), (3, "c"), (4, "d")))).flatMap { _ => | ||
foreach(db.stream(data.mutate.transactionally)) { m => | ||
if(!m.end) { | ||
if(m.row._1 == 1) m.row = m.row.copy(_2 = "aa") | ||
else if(m.row._1 == 2) m.delete | ||
else if(m.row._1 == 3) m += ((5, "ee")) | ||
} else seenEndMarker = true | ||
} | ||
}.flatMap { _ => | ||
seenEndMarker shouldBe false | ||
db.run(data.sortBy(_.id).result).map(_ shouldBe Seq((1, "aa"), (3, "c"), (4, "d"), (5, "ee"))) | ||
} | ||
} | ||
|
||
def testDeleteMutate = ifCapF(jcap.mutable) { | ||
class T(tag: Tag) extends Table[(Int, Int)](tag, "T_DELMUTABLE") { | ||
def a = column[Int]("A") | ||
def b = column[Int]("B", O.PrimaryKey) | ||
def * = (a, b) | ||
} | ||
val ts = TableQuery[T] | ||
def tsByA = ts.findBy(_.a) | ||
|
||
var seenEndMarker = false | ||
val a = seq( | ||
ts.schema.create, | ||
ts ++= Seq((1,1), (1,2), (1,3), (1,4)), | ||
ts ++= Seq((2,5), (2,6), (2,7), (2,8)) | ||
) andThen tsByA(1).mutate(sendEndMarker = true).transactionally | ||
|
||
val isDB2 = tdb.profile.toString.contains("DB2") | ||
foreach(db.stream(a)){ m => | ||
if(!m.end) m.delete | ||
else { | ||
seenEndMarker = true | ||
// DB2 can't mutate a result set, once it has gone past the end | ||
// default behaviour to close the result set | ||
if (!isDB2) { | ||
m += ((3, 9)) | ||
} | ||
} | ||
}.flatMap { _ => | ||
seenEndMarker shouldBe true | ||
db.run(ts.to[Set].result).map(_ shouldBe (Set((2,5), (2,6), (2,7), (2,8)) ++ | ||
(if (!isDB2) Set((3, 9)) else Set()))) | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ala/freeslick/FreeslickSubqueryTest.scala → ...slick/testkit/FreeslickSubqueryTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package freeslick | ||
package freeslick.testkit | ||
|
||
import com.typesafe.slick.testkit.util.{AsyncTest, JdbcTestDB} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package freeslick.testkit | ||
|
||
import com.typesafe.slick.testkit.util.{JdbcTestDB, AsyncTest} | ||
|
||
class JDBCFunctionTest extends AsyncTest[JdbcTestDB] { | ||
|
||
import tdb.driver.api._ | ||
|
||
def testLibraryFunctions = { | ||
for { | ||
_ <- Functions.user.result | ||
_ <- Functions.database.result | ||
_ <- Functions.currentDate.result | ||
_ <- Functions.currentTime.result | ||
_ <- Functions.pi.result | ||
} yield {} | ||
} | ||
} |
5 changes: 1 addition & 4 deletions
5
...a/freeslick/MSSQLServerPlainSQLTest.scala → ...ick/testkit/MSSQLServerPlainSQLTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.