Permalink
Browse files

test app updates

  • Loading branch information...
1 parent 752ff5e commit 84074b43aadf53b7f248d00e061499b1548010ed Burt Beckwith committed Aug 21, 2012
Showing with 38 additions and 31 deletions.
  1. +36 −25 scripts/CreateAclTestApp.groovy
  2. +2 −6 webtest/projectfiles/conf/BootStrap.groovy
@@ -68,7 +68,7 @@ private void init(String name, config) {
projectDir = config.projectDir
appName = 'spring-security-acl-test-' + name
testprojectRoot = "$projectDir/$appName"
- dotGrails = config.dotGrails
+ dotGrails = config.dotGrails + '/' + grailsVersion
}
private void createApp() {
@@ -78,35 +78,32 @@ private void createApp() {
deleteDir testprojectRoot
deleteDir "$dotGrails/projects/$appName"
- callGrails(grailsHome, projectDir, 'dev', 'create-app') {
- ant.arg value: appName
- }
+ callGrails grailsHome, projectDir, 'dev', 'create-app', [appName]
}
private void installPlugins() {
- // install plugins in local dir to make optional STS setup easier
- // also configure the functional tests to run in order
- new File("$testprojectRoot/grails-app/conf/BuildConfig.groovy").withWriterAppend {
- it.writeLine 'grails.project.plugins.dir = "plugins"'
- it.writeLine 'grails.testing.patterns = ["User1Functional", "User2Functional", "AdminFunctional"]'
- }
+ File buildConfig = new File(testprojectRoot, 'grails-app/conf/BuildConfig.groovy')
+ String contents = buildConfig.text
- ant.mkdir dir: "${testprojectRoot}/plugins"
- callGrails(grailsHome, testprojectRoot, 'dev', 'install-plugin') {
- ant.arg value: "functional-test ${functionalTestPluginVersion}"
- }
- callGrails(grailsHome, testprojectRoot, 'dev', 'install-plugin') {
- ant.arg value: pluginZip.absolutePath
- }
+ contents = contents.replace('grails.project.class.dir = "target/classes"', "grails.project.work.dir = 'target'")
+ contents = contents.replace('grails.project.test.class.dir = "target/test-classes"', '')
+ contents = contents.replace('grails.project.test.reports.dir = "target/test-reports"', '')
+
+ // configure the functional tests to run in order
+ contents += '\ngrails.testing.patterns = ["User1Functional", "User2Functional", "AdminFunctional"]\n'
+
+ buildConfig.withWriter { it.writeLine contents }
+
+ callGrails grailsHome, testprojectRoot, 'dev', 'install-plugin', ["functional-test ${functionalTestPluginVersion}"]
+
+ callGrails grailsHome, testprojectRoot, 'dev', 'install-plugin', [pluginZip.absolutePath]
+
+ callGrails grailsHome, testprojectRoot, 'dev', 'compile'
}
private void runQuickstart() {
- callGrails(grailsHome, testprojectRoot, 'dev', 's2-quickstart') {
- ant.arg value: 'com.testacl'
- ant.arg value: 'User'
- ant.arg value: 'Role'
- }
+ callGrails grailsHome, testprojectRoot, 'dev', 's2-quickstart', ['com.testacl', 'User', 'Role']
}
private void createProjectFiles() {
@@ -152,12 +149,26 @@ private void error(String message) {
exit 1
}
-private void callGrails(String grailsHome, String dir, String env, String action, extraArgs = null) {
- ant.exec(executable: "${grailsHome}/bin/grails", dir: dir, failonerror: 'true') {
+private void callGrails(String grailsHome, String dir, String env, String action, List extraArgs = null) {
+
+ String resultproperty = 'exitCode' + System.currentTimeMillis()
+ String outputproperty = 'execOutput' + System.currentTimeMillis()
+
+ println "Running 'grails $env $action ${extraArgs?.join(' ') ?: ''}'"
+
+ ant.exec(executable: "${grailsHome}/bin/grails", dir: dir, failonerror: false,
+ resultproperty: resultproperty, outputproperty: outputproperty) {
ant.env key: 'GRAILS_HOME', value: grailsHome
ant.arg value: env
ant.arg value: action
- extraArgs?.call()
+ extraArgs.each { ant.arg value: it }
+ }
+
+ println ant.project.getProperty(outputproperty)
+
+ int exitCode = ant.project.getProperty(resultproperty) as Integer
+ if (exitCode) {
+ exit exitCode
}
}
@@ -18,7 +18,6 @@ class BootStrap {
def aclUtilService
def objectIdentityRetrievalStrategy
def sessionFactory
- def springSecurityService
def init = { servletContext ->
createUsers()
@@ -29,7 +28,6 @@ class BootStrap {
grantPermissions()
-
sessionFactory.currentSession.flush()
// logout
@@ -42,13 +40,11 @@ class BootStrap {
3.times {
long id = it + 1
- def user = new User(username: "user$id", enabled: true,
- password: springSecurityService.encodePassword("password$id")).save()
+ def user = new User(username: "user$id", enabled: true, password: "password$id").save()
UserRole.create user, roleUser
}
- def admin = new User(username: 'admin', enabled: true,
- password: springSecurityService.encodePassword('admin123')).save()
+ def admin = new User(username: 'admin', enabled: true, password: 'admin123').save()
UserRole.create admin, roleUser
UserRole.create admin, roleAdmin, true

0 comments on commit 84074b4

Please sign in to comment.