HI all
i am seeking some advices here as i am still a squeryl noob
So i followed the sample pattern in the org.squeryl.test framework where ther is a DbTestBase, a SchemaTester and a RunTestsInsideTransaction for my unit tests, where the
connector used during unit tests is an in memory H2 database.
the session / schema gets created during the SchemaTester.beforeAll method , where my data also gets populated when doing an insert
however, when my test is attempting to do a Query, i receive the exception at the end of this email
Perhaps i am querying in the wrong way?
i paste below the code in my test class, as i have literally copied SchemaTester, DbTestBase and RunTestsInsideTransactions from squeryl sample project
class TestData {
import SharesSchema._
val sharePricesTests = sharePrices.insert(
SharePrice(new java.util.Date(), "TestTicker",
-1.0, -2.0,
-3.0, -4.0,
-4.0, -5.0))
println("FINISHING POPULATNG DATA")
}
@RunWith(classOf[JUnitRunner])
class SquerylPersistenceServiceTest extends SchemaTester with QueryTester with RunTestsInsideTransaction
with Matchers with BeforeAndAfterAll with H2_Connection {
val schema = SharesSchema
override def prePopulate = {
println("Pre populating.............")
val testData = new TestData()
}
test("Simple Insert/Query") {
lazy val data = from(SharesSchema.sharePrices)(sharePrice => select(sharePrice)).toList
data.size should be(1)
}
}
The exception is below. It seems my test class cannot find the schema, even though the schema has been created in the parent class. If i create the schema in the test("Simple Insert Query") then everything works fine.....
thanks in advance and regards
marco
PS this is the exception
org.squeryl.SquerylSQLException: Exception while executing statement : Table "SHAREPRICE" not found; SQL statement:
Select
shareprice9.mvAvg50 as shareprice9_mvAvg50,
shareprice9.peg as shareprice9_peg,
shareprice9.mvAvg as shareprice9_mvAvg,
shareprice9.LATEST_PRICE as shareprice9_LATEST_PRICE,
shareprice9.eps as shareprice9_eps,
shareprice9.ticker as shareprice9_ticker,
shareprice9.fwdEps as shareprice9_fwdEps,
shareprice9.DATE as shareprice9_DATE
From
shareprice shareprice9 [42102-168]
errorCode: 42102, sqlState: 42S02
Select
shareprice9.mvAvg50 as shareprice9_mvAvg50,
shareprice9.peg as shareprice9_peg,
shareprice9.mvAvg as shareprice9_mvAvg,
shareprice9.LATEST_PRICE as shareprice9_LATEST_PRICE,
shareprice9.eps as shareprice9_eps,
shareprice9.ticker as shareprice9_ticker,
shareprice9.fwdEps as shareprice9_fwdEps,
shareprice9.DATE as shareprice9_DATE
From
shareprice shareprice9