From 3934409aa8820d4eff55978194d008da8639594f Mon Sep 17 00:00:00 2001 From: Michael Italia Date: Thu, 1 Aug 2013 10:11:29 -0400 Subject: [PATCH 1/5] Add config files and build file for Travis-CI The test suite needs to be able to run in Travis-CI which is different from a local test setup. Mostly, this just means making sure that the mysql and postgres tests can connect properly. --- .travis.yml | 20 +++++++++++++++++++ .../resources/mysql_travis_test.properties | 5 +++++ .../resources/postgres_travis_test.properties | 4 ++++ 3 files changed, 29 insertions(+) create mode 100644 .travis.yml create mode 100644 src/test/resources/mysql_travis_test.properties create mode 100644 src/test/resources/postgres_travis_test.properties diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7a19d93 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: scala +scala: + - 2.10.0 + +#once develop is fixed we can turn this on +branches: + only: + - master +services: + - mysql + - posgres + - sqlite3 + +before_script: + - mysql -e 'create database dataexpress_test;' + - psql -c 'create database dataexpress_test;' -U postgres + +#Note that sbt needs the entire command quoted as well as quotes around the tags to exclude +script: + - sbt ++$TRAVIS_SCALA_VERSION 'test-only * -- -l "edu.chop.cbmi.dataExpress.test.util.tags.SqlServerTest edu.chop.cbmi.dataExpress.test.util.tags.OracleTest"' diff --git a/src/test/resources/mysql_travis_test.properties b/src/test/resources/mysql_travis_test.properties new file mode 100644 index 0000000..a78a832 --- /dev/null +++ b/src/test/resources/mysql_travis_test.properties @@ -0,0 +1,5 @@ +driverClassName=com.mysql.jdbc.Driver +jdbcUri=jdbc:mysql://127.0.0.1/dataexpress_test +user=travis +password= +jdbcCompliantTruncation=false diff --git a/src/test/resources/postgres_travis_test.properties b/src/test/resources/postgres_travis_test.properties new file mode 100644 index 0000000..bed8175 --- /dev/null +++ b/src/test/resources/postgres_travis_test.properties @@ -0,0 +1,4 @@ +driverClassName=org.postgresql.Driver +jdbcUri=dbc:postgresql://127.0.0.1/dataexpress_test +user=travis +password= From 784098a3f518b580d6fa02324cf4dd5c8338f42f Mon Sep 17 00:00:00 2001 From: Michael Italia Date: Thu, 1 Aug 2013 10:15:47 -0400 Subject: [PATCH 2/5] Clean up imports and pull in all utils packages Made sure that all items in the util package are getting pulled in so that future additional tags can be added without explicit imports. --- .../dataExpress/test/backends/MySqlBackendFeatureSpec.scala | 2 +- .../dataExpress/test/backends/OracleBackendFeatureSpec.scala | 5 ++--- .../cbmi/dataExpress/test/backends/OracleBackendSpec.scala | 3 +-- .../test/backends/PostgresBackendFeatureSpec.scala | 2 +- .../test/backends/SqlServerBackendFeatureSpec.scala | 3 +-- .../edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala | 4 ---- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala index cb02886..819ffbb 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala @@ -15,7 +15,7 @@ import java.util.Properties import edu.chop.cbmi.dataExpress.backends.MySqlBackend import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ -import edu.chop.cbmi.dataExpress.test.util.TestProps +import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.test.util.cars.dataSetup.backends.MySqlDataSetup import scala.language.reflectiveCalls diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala index 61df76e..4962e70 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala @@ -10,11 +10,10 @@ package edu.chop.cbmi.dataExpress.test.backends -import org.scalatest.FeatureSpec +import org.scalatest.{FeatureSpec} import org.scalatest.matchers.ShouldMatchers import org.scalatest.GivenWhenThen -import java.util.Properties -import edu.chop.cbmi.dataExpress.test.util.TestProps +import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ import edu.chop.cbmi.dataExpress.backends.OracleBackend diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala index 0cb9770..d4719d2 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala @@ -8,8 +8,7 @@ package edu.chop.cbmi.dataExpress.backends.test * To change this template use File | Settings | File Templates. */ import org.scalatest.matchers.ShouldMatchers -import org.scalatest.{GivenWhenThen, Spec, FunSpec} -import java.util.Properties +import org.scalatest.{GivenWhenThen, FunSpec, Tag} import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.backends.OracleBackend import scala.language.reflectiveCalls diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala index 8ba4d27..bb7d724 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala @@ -21,7 +21,7 @@ import edu.chop.cbmi.dataExpress.backends.PostgresBackend import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ -import edu.chop.cbmi.dataExpress.test.util.TestProps +import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.test.util.cars.dataSetup.backends.PostgresDataSetup import scala.language.reflectiveCalls diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala index 3404532..f53229d 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala @@ -1,9 +1,8 @@ package edu.chop.cbmi.dataExpress.test.backends -import org.scalatest.FeatureSpec +import org.scalatest.{Tag, FeatureSpec, GivenWhenThen} import org.scalatest.matchers.ShouldMatchers -import org.scalatest.GivenWhenThen import edu.chop.cbmi.dataExpress.backends.SqlServerBackend import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.dataModels._ diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala index 5fc6d4f..1a406ad 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala @@ -1,7 +1,5 @@ package edu.chop.cbmi.dataExpress.test.tutorial -import org.scalatest.junit.JUnitRunner -import org.scalatest.FeatureSpec import org.scalatest.matchers.ShouldMatchers import org.scalatest.GivenWhenThen import java.util.{UUID, Properties} @@ -9,8 +7,6 @@ import java.io.File import edu.chop.cbmi.dataExpress.backends._ import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ -import edu.chop.cbmi.dataExpress.dsl._ -import edu.chop.cbmi.dataExpress.dsl.stores.SqlDb import edu.chop.cbmi.dataExpress.dsl.ETL._ import edu.chop.cbmi.dataExpress.dsl.ETL import edu.chop.cbmi.dataExpress.dsl.stores.SqlDb From 6bbae25e81048626328fa158b6b967211a66b080 Mon Sep 17 00:00:00 2001 From: Michael Italia Date: Thu, 1 Aug 2013 10:20:04 -0400 Subject: [PATCH 3/5] Add "OracleTest" and "SqlServerTest" tags to allow exclusion of proprietary DB tests This allows tests to be excluded when either Oracle or MS SQL Server databases are available. This is primarily to support the testing of the codebase using Travis-CI since these environments are not available there. --- .../backends/OracleBackendFeatureSpec.scala | 120 ++++-------------- .../test/backends/OracleBackendSpec.scala | 25 +--- .../SqlServerBackendFeatureSpec.scala | 64 +++------- .../test/backends/SqlServerBackendSpec.scala | 9 +- .../cbmi/dataExpress/test/util/Tags.scala | 6 + 5 files changed, 61 insertions(+), 163 deletions(-) create mode 100644 src/test/scala/edu/chop/cbmi/dataExpress/test/util/Tags.scala diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala index 4962e70..aa29da6 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala @@ -20,7 +20,6 @@ import edu.chop.cbmi.dataExpress.backends.OracleBackend import scala.language.reflectiveCalls import edu.chop.cbmi.dataExpress.test.util.cars.dataSetup.backends.OracleDataSetup - class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with ShouldMatchers { def fixture = @@ -28,7 +27,8 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul val props = TestProps.getDbProps("oracle") } - + //TODO: Hard-coding schema names and users in the tests like this is confusing. It's not clear how they relate to the properties file + //This stuff all needs to be re-worked val dbSchema:Option[String] = Some("QE10C01") val targetDbUserName:String = "QE10C01" @@ -72,7 +72,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - scenario("The user can create a table with four columns") { + scenario("The user can create a table with four columns", OracleTest) { val f = fixture val tableName = "cars_deba_a" @@ -143,7 +143,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - scenario("The user can truncate a table and commit") { + scenario("The user can truncate a table and commit", OracleTest) { val f = fixture val tableName:String = "cars_deba_a" @@ -181,9 +181,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - scenario("The inserted row can be committed by executing an insert query") { + scenario("The inserted row can be committed by executing an insert query", OracleTest) { val f = fixture val backend = new OracleBackend(f.props) val tableName = "cars_deba_a" @@ -223,8 +221,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - scenario("The user can obtain a record from executing a select query") { + scenario("The user can obtain a record from executing a select query", OracleTest) { //Prerequisites: scenario 1: Passed val f = fixture @@ -257,12 +254,8 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - //THIS SHOULD WORK - scenario("The user can determine whether a select query has returned a record") { + scenario("The user can determine whether a select query has returned a record", OracleTest) { //Prerequisites: scenario 1: Passed val f = fixture @@ -303,13 +296,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - - scenario("The user can commit an open transaction") { + scenario("The user can commit an open transaction", OracleTest) { val f = fixture @@ -383,10 +370,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("The user can truncate a populated table") { + scenario("The user can truncate a populated table", OracleTest) { val f = fixture val tableName:String = "cars_deba_a" @@ -419,10 +403,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("The user can roll back an open transaction") { + scenario("The user can roll back an open transaction", OracleTest) { val f = fixture @@ -482,12 +463,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - scenario("The user can open a transaction, insert a row, and end the transaction") { + scenario("The user can open a transaction, insert a row, and end the transaction", OracleTest) { val f = fixture @@ -562,9 +538,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - scenario("The user can create a table with 32 columns") { + scenario("The user can create a table with 32 columns", OracleTest) { val f = fixture val tableName = "cars_deba_b" @@ -613,9 +587,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - scenario("The user can insert a row without constructing an insert statement") { + scenario("The user can insert a row without constructing an insert statement", OracleTest) { val f = fixture val tableName: String = "cars_deba_a" val columnNames: List[String] = List("carid", "carnumber", "carmake", "carmodel") @@ -650,13 +622,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - - scenario("The user can insert a batch of rows and commit without having to construct the insert statements") { + scenario("The user can insert a batch of rows and commit without having to construct the insert statements", OracleTest) { val f = fixture val tableName:String = "cars_deba_a" @@ -719,10 +685,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("The user can drop a table") { + scenario("The user can drop a table", OracleTest) { val f = fixture val tableName:String = "cars_deba_c" @@ -773,12 +736,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - scenario("The user can drop a table with cascade") { + scenario("The user can drop a table with cascade", OracleTest) { val f = fixture val tableName: String = "cars_deba_c" val viewName: String = "cars_deba_c_v" @@ -817,11 +775,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - scenario("The user can iterate over the results of a select query") { + scenario("The user can iterate over the results of a select query", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -853,10 +807,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - scenario("The user can update a record in a table using a valid update statement") { + scenario("The user can update a record in a table using a valid update statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -915,8 +866,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - scenario("The user can update a multiple records in a table using a valid update statement") { + scenario("The user can update a multiple records in a table using a valid update statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -969,11 +919,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - - scenario("The user can update a multiple records in a table without constructing update statement") { + scenario("The user can update a multiple records in a table without constructing update statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a with carmake = 'MiniCoopeRb' val f = fixture @@ -1032,11 +978,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - - scenario("The user can insert a multiple rows using a loop without constructing an insert statement") { + scenario("The user can insert a multiple rows using a loop without constructing an insert statement", OracleTest) { //Prerequisites: None of theses record should exist val f = fixture @@ -1089,11 +1031,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - scenario("The user can delete multiple records in a table using a valid delete statement") { + scenario("The user can delete multiple records in a table using a valid delete statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -1133,12 +1071,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - scenario("The user can drop all tables that begin with a certain string") { + scenario("The user can drop all tables that begin with a certain string", OracleTest) { /*http://stackoverflow.com/questions/3476765/mysql-drop-all-tables-ignoring-foreign-keys*/ @@ -1202,17 +1135,14 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("Remove Test Data Setup") { + scenario("Remove Test Data Setup", OracleTest) { /**** Remove Test Data ****/ removeTestDataSetup /**** ****/ } - scenario("Close Test SetUp Connections") { + scenario("Close Test SetUp Connections", OracleTest) { setup.targetBackend.close diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala index d4719d2..d07d89a 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala @@ -1,12 +1,5 @@ package edu.chop.cbmi.dataExpress.backends.test -/** - * Created by IntelliJ IDEA. - * User: italiam - * Date: 11/22/11 - * Time: 1:22 PM - * To change this template use File | Settings | File Templates. - */ import org.scalatest.matchers.ShouldMatchers import org.scalatest.{GivenWhenThen, FunSpec, Tag} import edu.chop.cbmi.dataExpress.test.util._ @@ -24,23 +17,20 @@ class OracleBackendSpec extends FunSpec with ShouldMatchers with GivenWhenThen - it("should have a null connection to start") { + it("should have a null connection to start", OracleTest) { val backend = new OracleBackend(f.props) backend.connection should be (null) backend.close() } - it("should connect using a Properties object") { + it("should connect using a Properties object", OracleTest) { val backend = new OracleBackend(f.props) backend.connect() backend.connection should not be (null) backend.close() } - - - - it("should throw an exception if one of the properties isn't provided") { + it("should throw an exception if one of the properties isn't provided", OracleTest) { val badProps = f.props badProps.remove("jdbcUri") val backend = new OracleBackend(badProps) @@ -48,8 +38,7 @@ class OracleBackendSpec extends FunSpec with ShouldMatchers with GivenWhenThen backend.close() } - - it("should have a closed connection after it closes the connection") { + it("should have a closed connection after it closes the connection", OracleTest) { val newFixture = fixture val backend = new OracleBackend(newFixture.props) backend.connect() @@ -58,12 +47,6 @@ class OracleBackendSpec extends FunSpec with ShouldMatchers with GivenWhenThen backend.connection.isClosed() should be (true) } - - - - - - } } diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala index f53229d..652ab16 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala @@ -10,7 +10,6 @@ import edu.chop.cbmi.dataExpress.dataModels.sql._ import edu.chop.cbmi.dataExpress.dataModels.sql.IntegerDataType import scala.language.reflectiveCalls - class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with ShouldMatchers { def fixture = @@ -39,7 +38,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - scenario("The user can create a table with four columns") { + scenario("The user can create a table with four columns", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val columnFixedWidth: Boolean = false @@ -82,9 +81,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - - scenario("The user can truncate a table and commit") { + scenario("The user can truncate a table and commit", SqlServerTest) { val f = fixture val tableName: String = "cars_deba_a" val countStatement: String = """select count(*) as 'count' from """ + tableName @@ -107,10 +104,8 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - //TODO: This test needs to be re-written with an auto-incrementing sequence in the table to fully test insert returning keys - scenario("The inserted row can be committed") { + scenario("The inserted row can be committed", SqlServerTest) { val f = fixture val backend = new SqlServerBackend(f.props) val tableName = "cars_deba_a" @@ -149,9 +144,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - - scenario("The user can obtain a record from executing a select query") { + scenario("The user can obtain a record from executing a select query", SqlServerTest) { //Prerequisites: ignore 1: Passed val f = fixture @@ -177,7 +170,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - scenario("The user can determine whether a select query has returned a record") { + scenario("The user can determine whether a select query has returned a record", SqlServerTest) { //Prerequisites: ignore 1: Passed @@ -205,8 +198,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can commit an open transaction") { + scenario("The user can commit an open transaction", SqlServerTest) { val f = fixture var backend = new SqlServerBackend(f.props) @@ -247,8 +239,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can truncate a populated table") { + scenario("The user can truncate a populated table", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val countStatement = "select count(1) as 'count' from %s".format(tableName) @@ -273,8 +264,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can roll back an open transaction") { + scenario("The user can roll back an open transaction", SqlServerTest) { val f = fixture val backend = new SqlServerBackend(f.props) val tableName = "cars_deba_a" @@ -320,8 +310,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can open a transaction, insert a row, and end the transaction") { + scenario("The user can open a transaction, insert a row, and end the transaction", SqlServerTest) { val f = fixture val backend = new SqlServerBackend(f.props) @@ -374,8 +363,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can create a table with 32 columns") { + scenario("The user can create a table with 32 columns", SqlServerTest) { val f = fixture val tableName = "cars_deba_b" val columnFixedWidth:Boolean = false @@ -409,8 +397,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can insert a row without constructing an insert statement") { + scenario("The user can insert a row without constructing an insert statement", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val columnNames = List("carid","carnumber","carmake","carmodel") @@ -447,7 +434,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - scenario("The user can insert a batch of rows and commit without having to construct the insert statements") { + scenario("The user can insert a batch of rows and commit without having to construct the insert statements", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val columnNames = List("carid","carnumber","carmake","carmodel") @@ -487,7 +474,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - scenario("The user can drop a table") { + scenario("The user can drop a table", SqlServerTest) { val f = fixture val tableName = "cars_deba_c" val columnFixedWidth = false @@ -520,7 +507,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } //Cascade on drop table is unsupported in sql server - scenario("The user gets an exception when trying to drop a table with cascade") { + scenario("The user gets an exception when trying to drop a table with cascade", SqlServerTest) { val f = fixture val tableName = "cars_deba_c" val viewName = "cars_deba_c_v" @@ -552,7 +539,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - scenario("The user can iterate over the results of a select query") { + scenario("The user can iterate over the results of a select query", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture val backend = new SqlServerBackend(f.props) @@ -578,7 +565,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - scenario("The user can update a record in a table using a valid update statement") { + scenario("The user can update a record in a table using a valid update statement", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -614,8 +601,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can update a multiple records in a table using a valid update statement") { + scenario("The user can update a multiple records in a table using a valid update statement", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -651,8 +637,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can update a multiple records in a table without constructing update statement") { + scenario("The user can update a multiple records in a table without constructing update statement", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a with carmake = 'MiniCoopeRb' val f = fixture @@ -691,8 +676,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can insert a multiple rows using a loop without constructing an insert statement") { + scenario("The user can insert a multiple rows using a loop without constructing an insert statement", SqlServerTest) { //Prerequisites: None of theses record should exist val f = fixture val tableName = "cars_deba_a" @@ -727,22 +711,16 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - - scenario("Remove Test Data Setup") { + scenario("Remove Test Data Setup", SqlServerTest) { /**** Remove Test Data ****/ removeTestDataSetup /**** ****/ } - scenario("Close Test SetUp Connections") { + scenario("Close Test SetUp Connections", SqlServerTest) { setup.targetBackend.close } - - - - } diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala index 3a0f2d1..0553855 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala @@ -6,6 +6,7 @@ import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.backends.SqlServerBackend import scala.language.reflectiveCalls + class SqlServerBackendSpec extends FunSpec with ShouldMatchers { def fixture = @@ -17,20 +18,20 @@ class SqlServerBackendSpec extends FunSpec with ShouldMatchers { - it("should have a null connection to start") { + it("should have a null connection to start", SqlServerTest) { val backend = new SqlServerBackend(f.props) backend.connection should be (null) backend.close() } - it("should connect using a Properties object") { + it("should connect using a Properties object", SqlServerTest) { val backend = new SqlServerBackend(f.props) backend.connect() backend.connection should not be (null) backend.close() } - it("should throw an exception if one of the properties isn't provided") { + it("should throw an exception if one of the properties isn't provided", SqlServerTest) { val badProps = f.props badProps.remove("jdbcUri") val backend = new SqlServerBackend(badProps) @@ -39,7 +40,7 @@ class SqlServerBackendSpec extends FunSpec with ShouldMatchers { } - it("should have a closed connection after it closes the connection") { + it("should have a closed connection after it closes the connection", SqlServerTest) { val newFixture = fixture val backend = new SqlServerBackend(newFixture.props) backend.connect() diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/util/Tags.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/Tags.scala new file mode 100644 index 0000000..527540d --- /dev/null +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/Tags.scala @@ -0,0 +1,6 @@ +package edu.chop.cbmi.dataExpress.test.util + +import org.scalatest.Tag + +object OracleTest extends Tag("edu.chop.cbmi.dataExpress.test.util.tags.OracleTest") +object SqlServerTest extends Tag("edu.chop.cbmi.dataExpress.test.util.tags.SqlServerTest") \ No newline at end of file From f30492ccba67f96cfaed2c53545bae40b4bbb613 Mon Sep 17 00:00:00 2001 From: Michael Italia Date: Thu, 1 Aug 2013 10:20:24 -0400 Subject: [PATCH 4/5] Removed whitespace --- .../scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala index 1a406ad..013fcad 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala @@ -18,6 +18,7 @@ import org.scalatest.FlatSpec */ + class TutorialFeatureSpec extends FlatSpec with GivenWhenThen with ShouldMatchers { "The setup" should "be able to take a clean database and create the necessary tables" in withBlankDatabase {db => From 54568c8d7d13526d40a52e028157fc6ebacf814f Mon Sep 17 00:00:00 2001 From: Michael Italia Date: Thu, 1 Aug 2013 10:23:30 -0400 Subject: [PATCH 5/5] Provide correct properties files when tests are running in Travis-CI environment Reading in of properties files is part of our test process, so we need custom properties files if we're running in Travis-CI. Travis-CI sets an system environment variable that we can detect and take the appropriate action to supply proper db config files to the tests. --- .../dataExpress/test/util/TestProps.scala | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala index 5f7dfb9..8f35af3 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala @@ -22,6 +22,25 @@ object TestProps { } private def choosePropFile(dbname: String) = { + val travis = System.getenv("TRAVIS") + + travis match { + case "true"=> getTravisDbProps(dbname) + case _ => getLocalDbProps(dbname) + } + + } + + private def getTravisDbProps(dbname: String) = { + dbname match { + case "mysql" => "/mysql_travis_test.properties" + case "postgres" => "/postgres_travis_test.properties" + case "sqlite" => "/sqlite_test.properties" + case _ => "/%s_travis_test.properties".format(dbname) + + } + } + private def getLocalDbProps(dbname: String) = { dbname match { case "mysql" => "/mysql_test.properties" case "postgres" => "/postgres_test.properties" @@ -29,8 +48,10 @@ object TestProps { case "sqlserver" => "/sqlserver_test.properties" case _ => "/%s_test.properties".format(dbname) } + } + def connectToDB(sb : SqlBackend) = { sb.connect sb