I'm having some trouble with an environment configuration. For some tests, we need a real database for our integration tests. To have a clean database everytime we start the test, we thought we just change the dbCreate property in the configuration files that are already loaded:
config-integration.properties:
# connection
db.name=integration_test
db.host=127.0.0.1
db.port=3306
dataSource.driverClassName=com.mysql.jdbc.Driver
dataSource.url=jdbc:mysql://${db.host}:${db.port}/${db.name}?useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true
dataSource.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
# configuration
dataSource.username=foo
dataSource.password=bar
dataSource.dbCreate=create-drop
dataSource.pooled=true
dataSource.properties.maxActive=50
dataSource.properties.maxIdle=25
dataSource.properties.minIdle=5
dataSource.properties.initialSize=5
dataSource.properties.minEvictableIdleTimeMillis=60000
dataSource.properties.timeBetweenEvictionRunsMillis=60000
dataSource.properties.maxWait=10000
dataSource.properties.validationQuery=/* ping */
Config.groovy:
environment {
....
integration {
log4j = {
root { debug 'stdout' }
warn 'org.apache'
warn 'grails.spring'
info 'org.codehaus.groovy.grails'
warn 'net.sf.ehcache'
warn 'org.hibernate'
}
grails.serverURL = "http://www.foobar.com"
if (!grails.config.locations || !(grails.config.locations instanceof List)) {
grails.config.locations = []
}
// loading default configuration
grails.config.locations << "classpath:app/config-integration.properties"
grails.gorm.failOnError = true
}
....
}
The problem now is, that this simply doesn't work. The tables are not created and therefore the tests die with an SQL Exception. There's not even a message about a wrong username/password if I change it to something incorrect. So it looks like the configuration is not loaded at the moment when grails/hibernate should create the tables in the database.
Edit: What I forgot: If I define the dataSource in the Config.groovy itself, it works.
Does anyone have an idea what I'm doing wrong here?
Thanks a lot in advance!