Tuesday, 6 August 2013

grails DataSource in Unit Test

grails DataSource in Unit Test

I'm trying to bootstrap some data into the in-memory H2 database for use
in a domain and service mock test. Here is how I have the test
environment's datasource configured:
test {
dataSource {
dbCreate = "create-drop"
url =
"jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;INIT=runscript
from 'sample_bootstrap_data.sql'"
}
}
I am able to do a run-app, access the dbconsole and see all of the data.
The problem I'm having is in the service test, with accessing this data. I
have a question: How would I access this data in the pre-initialized
schema in a unit test?

No comments:

Post a Comment