diff --git a/README.md b/README.md index 43a23f4..9ccab23 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Grails project with tests based on Spock. For examples based on Grails 1.3.7, take a look at branch [1_3_7](https://github.com/pschneider-manzell/grails-spock-examples/tree/grails_1_3_7) For examples based on Grails 2.2.0, take a look at branch [2_2_0](https://github.com/pschneider-manzell/grails-spock-examples/tree/grails_2_2_0) +For examples based on Grails 2.3.7, take a look at branch [2_3_7](https://github.com/pschneider-manzell/grails-spock-examples/tree/grails_2_3_7) It contains examples for: diff --git a/application.properties b/application.properties index 77befc2..9b1387e 100644 --- a/application.properties +++ b/application.properties @@ -1,6 +1,6 @@ #Grails Metadata file -#Fri Apr 04 08:49:24 CEST 2014 -app.grails.version=2.3.7 +#Mon Jun 09 16:50:48 CEST 2014 +app.grails.version=2.4.0 app.name=grails-spock-examples -app.servlet.version=2.5 +app.servlet.version=3.0 app.version=0.1 diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy index 2bfba77..3c4921a 100644 --- a/grails-app/conf/BuildConfig.groovy +++ b/grails-app/conf/BuildConfig.groovy @@ -1,3 +1,4 @@ +grails.servlet.version = "3.0" grails.project.class.dir = "target/classes" grails.project.test.class.dir = "target/test-classes" grails.project.test.reports.dir = "target/test-reports" @@ -6,29 +7,27 @@ grails.project.target.level = 1.6 grails.project.source.level = 1.6 grails.project.fork = [ - // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required - // compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true], - - // configure settings for the test-app JVM, uses the daemon by default - - //test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], - test: false, - // configure settings for the run-app JVM - run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], - // configure settings for the run-war JVM - war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], - // configure settings for the Console UI JVM - console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] + // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required + // compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true], + + // configure settings for the test-app JVM, uses the daemon by default + test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true], + // configure settings for the run-app JVM + run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], + // configure settings for the run-war JVM + war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], + // configure settings for the Console UI JVM + console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] ] - +grails.project.dependency.resolver = "maven" // or ivy grails.project.dependency.resolution = { // inherit Grails' default dependencies inherits("global") { // uncomment to disable ehcache // excludes 'ehcache' } - log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' + log "info" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' checksums true // Whether to verify checksums on resolve legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility @@ -50,8 +49,9 @@ grails.project.dependency.resolution = { //mavenRepo "http://repository.jboss.com/maven2/" } - def seleniumVersion = "2.35.0" + def seleniumVersion = "2.42.2" def gebVersion = "0.9.2" + def springVersion = "4.0.5.RELEASE" dependencies { @@ -66,23 +66,27 @@ grails.project.dependency.resolution = { test( "com.github.detro.ghostdriver:phantomjsdriver:1.1.0" ) { transitive = false } + compile "org.springframework:spring-orm:$springVersion" } plugins { + build ":tomcat:7.0.53" - compile ":scaffolding:2.0.1" + // plugins for the compile step + compile ":scaffolding:2.1.0" + compile ':cache:1.1.6' + compile ":asset-pipeline:1.8.7" - build ':tomcat:7.0.52.1' - runtime ':hibernate:3.6.10.10' - runtime ":jquery:1.9.1" - runtime ":resources:1.2.7" + runtime ':hibernate:3.6.10.14' + runtime ":jquery:1.11.0.2" + runtime ":resources:1.2.8" // Uncomment these (or add new ones) to enable additional resources cap$ //runtime ":zipped-resources:1.0" //runtime ":cached-resources:1.0" //runtime ":yui-minify-resources:0.1.4" - runtime ":database-migration:1.3.8" + runtime ":database-migration:1.4.0" test ":geb:$gebVersion" } diff --git a/grails-app/controllers/grails/geb/spock/AuthorController.groovy b/grails-app/controllers/grails/geb/spock/AuthorController.groovy index 0b12f7b..c90e272 100644 --- a/grails-app/controllers/grails/geb/spock/AuthorController.groovy +++ b/grails-app/controllers/grails/geb/spock/AuthorController.groovy @@ -3,16 +3,13 @@ package grails.geb.spock class AuthorController { static allowedMethods = [save: "POST", update: "POST", delete: "POST"] - + static scaffold = Author def index = { - redirect(action: "list", params: params) - } - - def list = { params.max = Math.min(params.max ? params.int('max') : 10, 100) [authorInstanceList: Author.list(params), authorInstanceTotal: Author.count()] } + def create = { def authorInstance = new Author() authorInstance.properties = params diff --git a/grailsw b/grailsw index 933fc94..20b62b9 100755 --- a/grailsw +++ b/grailsw @@ -79,6 +79,15 @@ if $cygwin ; then CP=`cygpath --path --unix "$CP"` fi +# quick detection of JDK version without JVM startup overhead +CLASSFILE_HEADER_FILE="${JAVA_HOME}/include/classfile_constants.h" +if [ -z "$GRAILS_NO_PERMGEN" -a -f "${CLASSFILE_HEADER_FILE}" ]; then + CLASSFILE_VERSION=`cat "${CLASSFILE_HEADER_FILE}" | grep "#define JVM_CLASSFILE_MAJOR_VERSION" | awk '{ print $3 }' 2> /dev/null` + if [ 0$CLASSFILE_VERSION -ge 52 ]; then + GRAILS_NO_PERMGEN=1 + fi +fi + # Remove possible trailing slash (after possible cygwin correction) GRAILS_HOME=`echo $GRAILS_HOME | sed -e 's|/$||g'` @@ -123,7 +132,7 @@ fi if [ -z "$STARTER_CONF" ]; then STARTER_CONF="$GRAILS_HOME/conf/groovy-starter.conf" fi -STARTER_CLASSPATH="wrapper/grails-wrapper-runtime-2.3.7.jar:wrapper:." +STARTER_CLASSPATH="wrapper/grails-wrapper-runtime-2.4.0.jar:wrapper:." # Allow access to Cocoa classes on OS X if $darwin; then @@ -191,7 +200,7 @@ if $mingw ; then fi if [ -z "$GRAILS_AGENT_CACHE_DIR" ]; then - GRAILS_AGENT_CACHE_DIR=~/.grails/2.3.7/ + GRAILS_AGENT_CACHE_DIR=~/.grails/2.4.0/ fi SPRINGLOADED_PARAMS=profile=grails\;cacheDir=$GRAILS_AGENT_CACHE_DIR if [ ! -d "$GRAILS_AGENT_CACHE_DIR" ]; then @@ -199,7 +208,7 @@ if [ ! -d "$GRAILS_AGENT_CACHE_DIR" ]; then fi # Process JVM args -AGENT_STRING="-javaagent:wrapper/springloaded-1.1.5.RELEASE.jar -noverify -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true -Dspringloaded=$SPRINGLOADED_PARAMS" +AGENT_STRING="-javaagent:wrapper/springloaded-1.2.0.RELEASE.jar -noverify -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true -Dspringloaded=$SPRINGLOADED_PARAMS" CMD_LINE_ARGS="" DISABLE_RELOADING=true @@ -316,7 +325,10 @@ startGrails() { then GRAILS_OPTS="$GRAILS_OPTS" else - GRAILS_OPTS="-server -Xmx768M -Xms64M -XX:PermSize=32m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8" + GRAILS_OPTS="-server -Xmx768M -Xms64M -Dfile.encoding=UTF-8" + if [ "$GRAILS_NO_PERMGEN" != "1" ]; then + GRAILS_OPTS="$GRAILS_OPTS -XX:PermSize=32m -XX:MaxPermSize=256m" + fi fi JAVA_OPTS="$GRAILS_OPTS $JAVA_OPTS $AGENT" # Start the Profiler or the JVM diff --git a/grailsw.bat b/grailsw.bat index cdce34b..5f6aa8f 100644 --- a/grailsw.bat +++ b/grailsw.bat @@ -60,13 +60,23 @@ if "%GRAILS_HOME:~-1%"=="\" SET GRAILS_HOME=%GRAILS_HOME:~0,-1% :init for %%x in ("%HOMEPATH%") do set SHORTHOME=%%~fsx -if "x%GRAILS_AGENT_CACHE_DIR%" == "x" set GRAILS_AGENT_CACHE_DIR=%SHORTHOME%/.grails/2.3.7/ +if "x%GRAILS_AGENT_CACHE_DIR%" == "x" set GRAILS_AGENT_CACHE_DIR=%SHORTHOME%/.grails/2.4.0/ set SPRINGLOADED_PARAMS="profile=grails;cacheDir=%GRAILS_AGENT_CACHE_DIR%" if not exist "%GRAILS_AGENT_CACHE_DIR%" mkdir "%GRAILS_AGENT_CACHE_DIR%" -set AGENT_STRING=-javaagent:wrapper/springloaded-1.1.5.RELEASE.jar -noverify -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true -Dspringloaded=\"%SPRINGLOADED_PARAMS%\" +if "%GRAILS_NO_PERMGEN%" == "" ( + type %JAVA_HOME%\include\classfile_constants.h 2>nul | findstr /R /C:"#define JVM_CLASSFILE_MAJOR_VERSION 5[23]" >nul + if not errorlevel 1 set GRAILS_NO_PERMGEN=1 +) + +set AGENT_STRING=-javaagent:wrapper/springloaded-1.2.0.RELEASE.jar -noverify -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true -Dspringloaded=\"%SPRINGLOADED_PARAMS%\" set DISABLE_RELOADING= -if "%GRAILS_OPTS%" == "" set GRAILS_OPTS=-server -Xmx768M -Xms64M -XX:PermSize=32m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8 +if "%GRAILS_OPTS%" == "" ( + set GRAILS_OPTS=-server -Xmx768M -Xms64M -Dfile.encoding=UTF-8 + if not "%GRAILS_NO_PERMGEN%" == "1" ( + set GRAILS_OPTS=%GRAILS_OPTS% -XX:PermSize=32m -XX:MaxPermSize=256m + ) +) @rem Get command-line arguments, handling Windows variants if "%@eval[2+2]" == "4" goto 4NT_args @@ -130,7 +140,7 @@ set CMD_LINE_ARGS=%$ :execute @rem Setup the command line -set STARTER_CLASSPATH=wrapper/grails-wrapper-runtime-2.3.7.jar;wrapper;. +set STARTER_CLASSPATH=wrapper/grails-wrapper-runtime-2.4.0.jar;wrapper;. if exist "%USERPROFILE%/.groovy/init.bat" call "%USERPROFILE%/.groovy/init.bat" @@ -159,7 +169,7 @@ set JAVA_OPTS=%GRAILS_OPTS% %JAVA_OPTS% %AGENT% set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name="%PROGNAME%" set JAVA_OPTS=%JAVA_OPTS% -Dgrails.home="%GRAILS_HOME%" -set JAVA_OPTS=%JAVA_OPTS% -Dgrails.version=2.3.7 +set JAVA_OPTS=%JAVA_OPTS% -Dgrails.version=2.4.0 set JAVA_OPTS=%JAVA_OPTS% -Dbase.dir=. set JAVA_OPTS=%JAVA_OPTS% -Dtools.jar="%TOOLS_JAR%" set JAVA_OPTS=%JAVA_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" diff --git a/test/unit/grails/geb/spock/AuthorControllerSpec.groovy b/test/unit/grails/geb/spock/AuthorControllerSpec.groovy index 75d1cbd..83467a2 100644 --- a/test/unit/grails/geb/spock/AuthorControllerSpec.groovy +++ b/test/unit/grails/geb/spock/AuthorControllerSpec.groovy @@ -9,36 +9,26 @@ import spock.lang.Specification class AuthorControllerSpec extends Specification { - def 'index action'() { - when: - controller.index() - - then: - response.redirectUrl.endsWith "list" - } - - - - def 'list action: 1 author'() { + def 'index action: 1 author'() { setup: authorInstance.save() expect: - controller.list() == [authorInstanceList: [authorInstance], authorInstanceTotal: 1] + controller.index() == [authorInstanceList: [authorInstance], authorInstanceTotal: 1] where: authorInstance = new Author(firstname: "John", lastname: "Doe") } - def 'list action: 2 authors and max = 1'() { + def 'index action: 2 authors and max = 1'() { setup: fistAuthorInstance.save() secondAuthorInstance.save() controller.params.max = 1 expect: - controller.list() == [authorInstanceList: [fistAuthorInstance], authorInstanceTotal: 2] + controller.index() == [authorInstanceList: [fistAuthorInstance], authorInstanceTotal: 2] where: fistAuthorInstance = new Author(firstname: "John1", lastname: "Doe1") @@ -71,9 +61,11 @@ class AuthorControllerSpec extends Specification { controller.params.lastname = "Doe" when: + request.method = 'POST' controller.save() then: + response.redirectUrl != null response.redirectUrl.endsWith "show/1" controller.flash.message != null @@ -85,9 +77,11 @@ class AuthorControllerSpec extends Specification { controller.params.lastname = lastname when: + request.method = 'POST' controller.save() then: + view != null view.endsWith "create" model.authorInstance.firstname == firstname model.authorInstance.lastname == null @@ -119,6 +113,7 @@ class AuthorControllerSpec extends Specification { controller.show() then: + response.redirectUrl != null response.redirectUrl.endsWith"list" controller.flash.message != null @@ -146,6 +141,7 @@ class AuthorControllerSpec extends Specification { controller.edit() then: + response.redirectUrl != null response.redirectUrl.endsWith "list" controller.flash.message != null @@ -160,9 +156,11 @@ class AuthorControllerSpec extends Specification { controller.params.id = authorInstance.id when: + request.method = 'POST' controller.update() then: + response.redirectUrl != null response.redirectUrl.endsWith "show/1" controller.flash.message != null diff --git a/web-app/WEB-INF/applicationContext.xml b/web-app/WEB-INF/applicationContext.xml index a48dec0..539f17d 100644 --- a/web-app/WEB-INF/applicationContext.xml +++ b/web-app/WEB-INF/applicationContext.xml @@ -1,34 +1,31 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - Grails application factory bean - - - + + Grails application factory bean + + - - A bean that manages Grails plugins - - - + + A bean that manages Grails plugins + + + - - - - - - + + + + + + - + + + utf-8 + + - - - utf-8 - - - - + \ No newline at end of file diff --git a/web-app/WEB-INF/sitemesh.xml b/web-app/WEB-INF/sitemesh.xml index 72399ce..1596a79 100644 --- a/web-app/WEB-INF/sitemesh.xml +++ b/web-app/WEB-INF/sitemesh.xml @@ -1,11 +1,11 @@ + class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" /> + class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" /> + class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" /> diff --git a/wrapper/grails-wrapper-runtime-2.3.7.jar b/wrapper/grails-wrapper-runtime-2.4.0.jar similarity index 87% rename from wrapper/grails-wrapper-runtime-2.3.7.jar rename to wrapper/grails-wrapper-runtime-2.4.0.jar index 7cdacfa..5ecf343 100644 Binary files a/wrapper/grails-wrapper-runtime-2.3.7.jar and b/wrapper/grails-wrapper-runtime-2.4.0.jar differ diff --git a/wrapper/springloaded-1.1.5.RELEASE.jar b/wrapper/springloaded-1.1.5.RELEASE.jar deleted file mode 100644 index cb88323..0000000 Binary files a/wrapper/springloaded-1.1.5.RELEASE.jar and /dev/null differ diff --git a/wrapper/springloaded-1.2.0.RELEASE.jar b/wrapper/springloaded-1.2.0.RELEASE.jar new file mode 100644 index 0000000..520edd0 Binary files /dev/null and b/wrapper/springloaded-1.2.0.RELEASE.jar differ