Permalink
Browse files

Fixed CORE-1529 After `grails clean` test data is not dumped from the…

… database between functional tests
  • Loading branch information...
1 parent a65d175 commit 967accce25c067acfd119fb5628501cb66d5af6f @alxndrsn alxndrsn committed Oct 3, 2012
@@ -35,7 +35,13 @@ eventTestPhaseStart = { phaseName ->
eventTestStart = { testName ->
if (currentTestPhase == 'functional' || currentTestPhase == 'integration') {
- def sql = Sql.newInstance("jdbc:h2:mem:testDb${frontlinesms2.StaticApplicationInstance.uniqueId}", 'sa', '', 'org.h2.Driver')
+ // Need to generate appInstanceId here as StaticApplicationInstance may not be
+ // on the classpath at this point (i.e. after `grails clean`)
+ def appInstanceId = System.properties['frontlinesms.appInstanceId']
+ if(!appInstanceId) appInstanceId = "${new Random().nextLong()}"
+ System.properties['frontlinesms.appInstanceId'] = appInstanceId
+
+ def sql = Sql.newInstance("jdbc:h2:mem:testDb$appInstanceId", 'sa', '', 'org.h2.Driver')
sql.execute "SET REFERENTIAL_INTEGRITY FALSE"
sql.eachRow("SHOW TABLES") { table -> sql.execute('DELETE FROM ' + table.TABLE_NAME) }
sql.execute "SET REFERENTIAL_INTEGRITY TRUE"
@@ -1,5 +1,14 @@
package frontlinesms2
class StaticApplicationInstance {
- static long uniqueId = new Random().nextLong()
-}
+ private static final String APPINSTANCE_ID = 'frontlinesms.appInstanceId'
+ static synchronized String getUniqueId() {
+ def id = System.properties[APPINSTANCE_ID]
+ if(!id) {
+ id = "${new Random().nextLong()}"
+ System.properties[APPINSTANCE_ID] = id
+ }
+ return id
+ }
+}
+
@@ -36,7 +36,7 @@ driver = {
println "Configured WebDriver: ${driver.class}"
3.times { try {
- driver.navigate().to('http://localhost:8080/core') // TODO should read this url from grails settings
+ driver.navigate().to('http://localhost:8080/frontlinesms-core') // TODO should read this url from grails settings
} catch(TimeoutException ex) { sleep 10000 } }
def width = 1366
def height = 768

0 comments on commit 967accc

Please sign in to comment.