Skip to content

Commit

Permalink
Upgraded to grails 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pschneider-manzell committed Jun 10, 2014
1 parent d0ac2ab commit a2ec221
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 82 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions application.properties
Original file line number Diff line number Diff line change
@@ -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
48 changes: 26 additions & 22 deletions grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

Expand All @@ -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 {

Expand All @@ -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"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 16 additions & 4 deletions grailsw
Original file line number Diff line number Diff line change
Expand Up @@ -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'`

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -191,15 +200,15 @@ 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
mkdir -p "$GRAILS_AGENT_CACHE_DIR"
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

Expand Down Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions grailsw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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%"
Expand Down
26 changes: 12 additions & 14 deletions test/unit/grails/geb/spock/AuthorControllerSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -119,6 +113,7 @@ class AuthorControllerSpec extends Specification {
controller.show()

then:
response.redirectUrl != null
response.redirectUrl.endsWith"list"
controller.flash.message != null

Expand Down Expand Up @@ -146,6 +141,7 @@ class AuthorControllerSpec extends Specification {
controller.edit()

then:
response.redirectUrl != null
response.redirectUrl.endsWith "list"
controller.flash.message != null

Expand All @@ -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

Expand Down
49 changes: 23 additions & 26 deletions web-app/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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">
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">

<bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
<description>Grails application factory bean</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="grailsResourceLoader" ref="grailsResourceLoader" />
</bean>
<bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
<description>Grails application factory bean</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
</bean>

<bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
<description>A bean that manages Grails plugins</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="application" ref="grailsApplication" />
</bean>
<bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
<description>A bean that manages Grails plugins</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="application" ref="grailsApplication" />
</bean>

<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
<constructor-arg>
<ref bean="grailsApplication" />
</constructor-arg>
<property name="pluginManager" ref="pluginManager" />
</bean>
<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
<constructor-arg>
<ref bean="grailsApplication" />
</constructor-arg>
<property name="pluginManager" ref="pluginManager" />
</bean>

<bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean" />
<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
</bean>

<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
</bean>

<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" />
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" />
</beans>
6 changes: 3 additions & 3 deletions web-app/WEB-INF/sitemesh.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<sitemesh>
<page-parsers>
<parser content-type="text/html"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
<parser content-type="text/html;charset=ISO-8859-1"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
<parser content-type="text/html;charset=UTF-8"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
</page-parsers>

<decorator-mappers>
Expand Down
Binary file not shown.
Binary file removed wrapper/springloaded-1.1.5.RELEASE.jar
Binary file not shown.
Binary file added wrapper/springloaded-1.2.0.RELEASE.jar
Binary file not shown.

0 comments on commit a2ec221

Please sign in to comment.