Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from csterwa/master

Updated for functional auto-test execution with baseUrl
  • Loading branch information...
commit 4d246af618cdeb70c02d001c49b83d6625a657ab 2 parents 6a8da8e + 925110f
@mjhugo authored
Showing with 1,115 additions and 19 deletions.
  1. +2 −1  .gitignore
  2. +14 −2 README.md
  3. +6 −2 application.properties
  4. +335 −0 grailsw
  5. +177 −0 grailsw.bat
  6. +10 −2 scripts/AutoTest.groovy
  7. +1 −1  test/project/bookstore/application.properties
  8. +12 −0 test/project/bookstore/grails-app/conf/BuildConfig.groovy
  9. +7 −0 test/project/bookstore/grails-app/controllers/bookstore/BookController.groovy
  10. +335 −0 test/project/bookstore/grailsw
  11. +177 −0 test/project/bookstore/grailsw.bat
  12. +17 −0 test/project/bookstore/test/functional/bookstore/BookControllerSpec.groovy
  13. +11 −0 test/project/bookstore/test/integration/bookstore/SimpleIntegrationSpec.groovy
  14. +0 −8 test/project/bookstore/test/integration/bookstore/SimpleIntegrationTests.groovy
  15. +9 −3 test/project/bookstore/test/unit/bookstore/{BookTests.groovy → BookSpec.groovy}
  16. BIN  test/project/bookstore/wrapper/grails-wrapper-runtime-2.1.1.jar
  17. +1 −0  test/project/bookstore/wrapper/grails-wrapper.properties
  18. BIN  test/project/bookstore/wrapper/springloaded-core-1.0.6.jar
  19. BIN  wrapper/grails-wrapper-runtime-2.1.1.jar
  20. +1 −0  wrapper/grails-wrapper.properties
  21. BIN  wrapper/springloaded-core-1.0.6.jar
View
3  .gitignore
@@ -8,4 +8,5 @@ test/project/bookstore/web-app/WEB-INF/tld/fmt.tld
.DS_Store
target/
grails-auto-test-*.zip
-plugin.xml
+plugin.xml
+web-app
View
16 README.md
@@ -5,9 +5,13 @@
- Björn Wilmsmann, MetaSieve
- Mike Hugo
+## Modifications Made By
+
+- Chris Sterling
+
## Grails support
-Version 1.0 of this plugin will only work with Grails 2.0 or higher. If you have a Grails application using a version of grails prior to 2.0, please use version 0.1 of this plugin
+Version 1.0 of this plugin works with Grails 2.0 or higher. If you have a Grails application using a version of grails prior to 2.0, please use version 0.1 of this plugin
## Usage
@@ -21,7 +25,15 @@ The plugin will monitor the project directory and will attempt to run only the s
Example usage screencast: http://youtu.be/7qLuDlJqFwY
-Currently, there is no support for running the __entire__ test suite when something is changed (which is the way the plugin behaved in previous versions). This will be added in a future release.
+In order to run functional tests continually upon changes, the application must be started separately and the "-baseUrl" command line arg must be used to run against already started instance. Here is an example:
+
+```
+$ grails
+| Enter a script name to run. Use TAB for completion:
+grails> run-app
+| Server running. Browse to http://localhost:8080/app
+grails> auto-test -baseUrl=http://localhost:8080/app/
+```
## Support
View
8 application.properties
@@ -1,2 +1,6 @@
-app.grails.version=2.0.0
-app.name=AutoTest
+#Sat Dec 08 13:14:32 PST 2012
+app.grails.version=2.2.0.RC1
+app.name=AutoTest
+plugins.hibernate=2.1.0
+plugins.tomcat=2.1.0
View
335 grailsw
@@ -0,0 +1,335 @@
+##############################################################################
+## ##
+## Grails JVM Bootstrap for UN*X ##
+## ##
+##############################################################################
+
+PROGNAME=`basename "$0"`
+DIRNAME=`dirname "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that
+MAX_FD="maximum"
+
+warn() {
+ echo "${PROGNAME}: $*"
+}
+
+die() {
+ warn "$*"
+ exit 1
+}
+
+earlyInit() {
+ return
+}
+lateInit() {
+ return
+}
+
+GROOVY_STARTUP=~/.groovy/startup
+if [ -r "$GROOVY_STARTUP" ]; then
+ . "$GROOVY_STARTUP"
+fi
+
+earlyInit
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false;
+darwin=false;
+case "`uname`" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+
+ Darwin*)
+ darwin=true
+ ;;
+esac
+
+# Attempt to set JAVA_HOME if it's not already set
+if [ -z "$JAVA_HOME" ]; then
+
+ # Set JAVA_HOME for Darwin
+ if $darwin; then
+
+ [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] &&
+ export JAVA_HOME="/Library/Java/Home"
+
+ [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] &&
+ export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
+
+ fi
+
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$GRAILS_HOME" ] &&
+ GRAILS_HOME=`cygpath --unix "$GRAILS_HOME"`
+ [ -n "$JAVACMD" ] &&
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CP" ] &&
+ CP=`cygpath --path --unix "$CP"`
+fi
+
+# Remove possible trailing slash (after possible cygwin correction)
+GRAILS_HOME=`echo $GRAILS_HOME | sed -e 's|/$||g'`
+
+# Locate GRAILS_HOME if not it is not set
+if [ -z "$GRAILS_HOME" -o ! -d "$GRAILS_HOME" ] ; then
+ # resolve links - $0 may be a link to groovy's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+ done
+
+ SAVED="`pwd`"
+ cd "`dirname \"$PRG\"`/.."
+ GRAILS_HOME="`pwd -P`"
+ cd "$SAVED"
+fi
+
+# Warn the user if JAVA_HOME and/or GRAILS_HOME are not set.
+if [ -z "$JAVA_HOME" ] ; then
+ die "JAVA_HOME environment variable is not set"
+elif [ ! -d "$JAVA_HOME" ] ; then
+ die "JAVA_HOME is not a directory: $JAVA_HOME"
+fi
+
+if [ -z "$GRAILS_HOME" ] ; then
+ warn "GRAILS_HOME environment variable is not set"
+fi
+
+if [ ! -d "$GRAILS_HOME" ] ; then
+ die "GRAILS_HOME is not a directory: $GRAILS_HOME"
+fi
+
+# Use default groovy-conf config
+if [ -z "$STARTER_CONF" ]; then
+ STARTER_CONF="$GRAILS_HOME/conf/groovy-starter.conf"
+fi
+STARTER_CLASSPATH="wrapper/grails-wrapper-runtime-2.1.1.jar:wrapper:."
+
+# Allow access to Cocoa classes on OS X
+if $darwin; then
+ STARTER_CLASSPATH="$STARTER_CLASSPATH:/System/Library/Java/Support"
+fi
+
+# Create the final classpath
+# Setting a classpath using the -cp or -classpath option means not to use
+# the global classpath. Groovy behaves then the same as the java
+# interpreter
+if [ -n "$CP" ] ; then
+ CP="$CP"
+elif [ -n "$CLASSPATH" ] ; then
+ CP="$CLASSPATH"
+fi
+
+# Determine the Java command to use to start the JVM
+if [ -z "$JAVACMD" ]; then
+ if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="java"
+ fi
+fi
+if [ ! -x "$JAVACMD" ]; then
+ die "JAVA_HOME is not defined correctly; can not execute: $JAVACMD"
+fi
+
+# Increase the maximum file descriptors if we can
+if [ "$cygwin" = "false" ]; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ "$MAX_FD_LIMIT" != "unlimited" ]; then
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ # use the businessSystem max
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+ fi
+fi
+
+# Fix the cygwin agent issue
+AGENT_GRAILS_HOME=$GRAILS_HOME
+if $cygwin ; then
+ [ -n "$GRAILS_HOME" ] &&
+ AGENT_GRAILS_HOME=`cygpath --windows "$GRAILS_HOME"`
+fi
+
+if [ -z "$GRAILS_AGENT_CACHE_DIR" ]; then
+ GRAILS_AGENT_CACHE_DIR=~/.grails/@grails.version@/
+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-core-1.0.6.jar -noverify -Dspringloaded=$SPRINGLOADED_PARAMS"
+CMD_LINE_ARGS=""
+DISABLE_RELOADING=false
+
+while true; do
+ if [ "$1" = "-cp" ] || [ "$1" = "-classpath" ]; then
+ CP=$2
+ shift 2
+ break
+ fi
+
+ if [ "$1" = "-reloading" ]; then
+ AGENT=$AGENT_STRING
+ shift
+ break
+ fi
+
+ if [ "$1" = "-noreloading" ]; then
+ DISABLE_RELOADING=true
+ shift
+ break
+ fi
+
+ if [ "$1" = "-debug" ]; then
+ JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Dgrails.full.stacktrace=true -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
+ shift
+ break
+ fi
+
+ if [ "$1" != -* ]; then
+ break
+ fi
+
+ CMD_LINE_ARGS="$CMD_LINE_ARGS $1"
+ shift
+done
+
+# Enable agent-based reloading for the 'run-app' command.
+if ! $DISABLE_RELOADING; then
+ for a in "$@"; do
+ if [ "$a" = "run-app" ]; then
+ AGENT=$AGENT_STRING
+ fi
+ done
+
+ if [ $# = 0 ]; then
+ AGENT=$AGENT_STRING
+ fi
+fi
+
+ARGUMENTS="$CMD_LINE_ARGS $@"
+
+# Setup Profiler
+useprofiler=false
+if [ "x$PROFILER" != "x" ]; then
+ if [ -r "$PROFILER" ]; then
+ . $PROFILER
+ useprofiler=true
+ else
+ die "Profiler file not found: $PROFILER"
+ fi
+fi
+
+# For Darwin, use classes.jar for TOOLS_JAR
+TOOLS_JAR="$JAVA_HOME/lib/tools.jar"
+if $darwin; then
+ JAVA_OPTS="-Xdock:name=Grails -Xdock:icon=$GRAILS_HOME/media/icons/grails.icns $JAVA_OPTS"
+# TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes/classes.jar"
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ GRAILS_HOME=`cygpath --path --mixed "$GRAILS_HOME"`
+ JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
+ STARTER_CONF=`cygpath --path --mixed "$STARTER_CONF"`
+ CP=`cygpath --path --mixed "$CP"`
+ TOOLS_JAR=`cygpath --path --mixed "$TOOLS_JAR"`
+ STARTER_CLASSPATH=`cygpath --path --mixed "$STARTER_CLASSPATH"`
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GROOVY_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GROOVY_CYGPATTERN)"
+ fi
+ # Now convert the arguments
+ ARGUMENTS=""
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ if [ $CHECK -ne 0 ] ; then
+ convArg=`cygpath --path --ignore --mixed "$arg"`
+ else
+ convArg=$arg
+ fi
+ ARGUMENTS="$ARGUMENTS $convArg"
+ done
+fi
+
+STARTER_MAIN_CLASS=org.grails.wrapper.GrailsWrapper
+
+lateInit
+
+startGrails() {
+ CLASS=$1
+ shift
+ if [ -n "$GRAILS_OPTS" ]
+ then
+ GRAILS_OPTS="$GRAILS_OPTS"
+ else
+ GRAILS_OPTS="-server -Xmx768M -Xms768M -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8"
+ fi
+ JAVA_OPTS="$GRAILS_OPTS $JAVA_OPTS $AGENT"
+ # Start the Profiler or the JVM
+ if $useprofiler; then
+ runProfiler
+ else
+ if [ $# -eq 0 ] ; then # no argument given
+ exec "$JAVACMD" $JAVA_OPTS \
+ -classpath "$STARTER_CLASSPATH" \
+ -Dgrails.home="$GRAILS_HOME" \
+ -Dtools.jar="$TOOLS_JAR" \
+ $STARTER_MAIN_CLASS \
+ --main $CLASS \
+ --conf "$STARTER_CONF" \
+ --classpath "$CP"
+ else
+ exec "$JAVACMD" $JAVA_OPTS \
+ -classpath "$STARTER_CLASSPATH" \
+ -Dgrails.home="$GRAILS_HOME" \
+ -Dtools.jar="$TOOLS_JAR" \
+ $STARTER_MAIN_CLASS \
+ --main $CLASS \
+ --conf "$STARTER_CONF" \
+ --classpath "$CP" \
+ "${ARGUMENTS}"
+ fi
+ fi
+}
+
+startGrails $STARTER_MAIN_CLASS "$@"
View
177 grailsw.bat
@@ -0,0 +1,177 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem ##
+@rem Grails JVM Bootstrap for Windows ##
+@rem ##
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set CLASS=org.grails.wrapper.GrailsWrapper
+
+if exist "%USERPROFILE%/.groovy/preinit.bat" call "%USERPROFILE%/.groovy/preinit.bat"
+
+@rem Determine the command interpreter to execute the "CD" later
+set COMMAND_COM="cmd.exe"
+if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
+if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"
+
+@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
+set FIND_EXE="find.exe"
+if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
+if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"
+
+:check_JAVA_HOME
+@rem Make sure we have a valid JAVA_HOME
+if not "%JAVA_HOME%" == "" goto have_JAVA_HOME
+
+echo.
+echo ERROR: Environment variable JAVA_HOME has not been set.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+echo.
+goto end
+
+:have_JAVA_HOME
+@rem Remove trailing slash from JAVA_HOME if found
+if "%JAVA_HOME:~-1%"=="\" SET JAVA_HOME=%JAVA_HOME:~0,-1%
+
+@rem Validate JAVA_HOME
+%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
+if not errorlevel 1 goto check_GRAILS_HOME
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+echo.
+goto end
+
+:check_GRAILS_HOME
+@rem Define GRAILS_HOME if not set
+if "%GRAILS_HOME%" == "" set GRAILS_HOME=%DIRNAME%..
+
+@rem Remove trailing slash from GRAILS_HOME if found
+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/@grails.version@/
+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-core-1.0.6.jar -noverify -Dspringloaded=%SPRINGLOADED_PARAMS%
+set DISABLE_RELOADING=
+if "%GRAILS_OPTS%" == "" set GRAILS_OPTS=-server -Xmx768M -Xms768M -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8
+
+@rem Get command-line arguments, handling Windows variants
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set CP=
+set INTERACTIVE=true
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+set CURR_ARG=%~1
+if "%CURR_ARG:~0,2%" == "-D" (
+ set GRAILS_OPTS=%GRAILS_OPTS% %~1=%~2
+ shift
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-cp" (
+ set CP=%~2
+ shift
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-debug" (
+ set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent -Dgrails.full.stacktrace=true -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-classpath" (
+ set CP=%~2
+ shift
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-reloading" (
+ set AGENT=%AGENT_STRING%
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "xrun-app" (
+ set AGENT=%AGENT_STRING%
+ set INTERACTIVE=
+ set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-noreloading" (
+ set DISABLE_RELOADING=true
+ shift
+ goto win9xME_args_slurp
+)
+set INTERACTIVE=
+set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
+shift
+goto win9xME_args_slurp
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+set STARTER_CLASSPATH=wrapper/grails-wrapper-runtime-2.1.1.jar;wrapper;.
+
+if exist "%USERPROFILE%/.groovy/init.bat" call "%USERPROFILE%/.groovy/init.bat"
+
+@rem Setting a classpath using the -cp or -classpath option means not to use
+@rem the global classpath. Groovy behaves then the same as the java interpreter
+
+if "x" == "x%CLASSPATH%" goto after_classpath
+set CP=%CP%;%CLASSPATH%
+:after_classpath
+
+if "x%DISABLE_RELOADING%" == "xtrue" (
+ set AGENT=
+) else (
+ if "x%INTERACTIVE%" == "xtrue" (
+ set AGENT=%AGENT_STRING%
+ )
+)
+
+set STARTER_MAIN_CLASS=org.grails.wrapper.GrailsWrapper
+set STARTER_CONF=%GRAILS_HOME%\conf\groovy-starter.conf
+
+set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar
+
+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=@grails.version@
+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%"
+
+if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"
+
+@rem Execute Grails
+CALL "%JAVA_EXE%" %JAVA_OPTS% -classpath "%STARTER_CLASSPATH%" %STARTER_MAIN_CLASS% --main %CLASS% --conf "%STARTER_CONF%" --classpath "%CP%" "%CMD_LINE_ARGS%"
+:end
+@rem End local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" endlocal
+
+@rem Optional pause the batch file
+if "%GROOVY_BATCH_PAUSE%" == "on" pause
+
View
12 scripts/AutoTest.groovy
@@ -15,7 +15,15 @@ target(default: "autotest") {
File baseProjectDirectory = new File(basedir)
long interval = 2000
FileListener listener = new FileListener()
- listener.args = argsMap.params
+
+ argsMap.each { key, value ->
+ if (key == "params") {
+ listener.args.addAll(value)
+ } else {
+ listener.args.add("-" + key + "=" + value)
+ }
+ }
+ println("listener args == ${listener.args}")
FileAlterationObserver observer = new FileAlterationObserver(baseProjectDirectory);
observer.addListener(listener)
@@ -30,7 +38,7 @@ target(default: "autotest") {
}
class FileListener extends FileAlterationListenerAdaptor {
Set testsToRun = []
- Set args
+ Set args = []
@Synchronized
void onFileChange(File file) {
View
2  test/project/bookstore/application.properties
@@ -1,6 +1,6 @@
#Grails Metadata file
#Mon Jan 30 21:07:04 CST 2012
-app.grails.version=2.0.0
+app.grails.version=2.2.0.RC1
app.name=bookstore
app.servlet.version=2.5
app.version=0.1
View
12 test/project/bookstore/grails-app/conf/BuildConfig.groovy
@@ -37,6 +37,10 @@ grails.project.dependency.resolution = {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.16'
+ test("org.spockframework:spock-grails-support:0.6-groovy-1.8") {
+ excludes 'spock-core'
+ }
+ test 'org.spockframework:spock-core:0.7-groovy-2.0'
}
plugins {
@@ -44,6 +48,14 @@ grails.project.dependency.resolution = {
runtime ":jquery:1.7.1"
runtime ":resources:1.1.5"
+ test(':spock:0.7') {
+ excludes 'spock-grails-support'
+ }
+
+ compile(":functional-spock:0.6") {
+ excludes 'spock-grails-support'
+ }
+
build ":tomcat:$grailsVersion"
}
}
View
7 test/project/bookstore/grails-app/controllers/bookstore/BookController.groovy
@@ -0,0 +1,7 @@
+package bookstore
+
+class BookController {
+
+ def index() {}
+
+}
View
335 test/project/bookstore/grailsw
@@ -0,0 +1,335 @@
+##############################################################################
+## ##
+## Grails JVM Bootstrap for UN*X ##
+## ##
+##############################################################################
+
+PROGNAME=`basename "$0"`
+DIRNAME=`dirname "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that
+MAX_FD="maximum"
+
+warn() {
+ echo "${PROGNAME}: $*"
+}
+
+die() {
+ warn "$*"
+ exit 1
+}
+
+earlyInit() {
+ return
+}
+lateInit() {
+ return
+}
+
+GROOVY_STARTUP=~/.groovy/startup
+if [ -r "$GROOVY_STARTUP" ]; then
+ . "$GROOVY_STARTUP"
+fi
+
+earlyInit
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false;
+darwin=false;
+case "`uname`" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+
+ Darwin*)
+ darwin=true
+ ;;
+esac
+
+# Attempt to set JAVA_HOME if it's not already set
+if [ -z "$JAVA_HOME" ]; then
+
+ # Set JAVA_HOME for Darwin
+ if $darwin; then
+
+ [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] &&
+ export JAVA_HOME="/Library/Java/Home"
+
+ [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] &&
+ export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
+
+ fi
+
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$GRAILS_HOME" ] &&
+ GRAILS_HOME=`cygpath --unix "$GRAILS_HOME"`
+ [ -n "$JAVACMD" ] &&
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CP" ] &&
+ CP=`cygpath --path --unix "$CP"`
+fi
+
+# Remove possible trailing slash (after possible cygwin correction)
+GRAILS_HOME=`echo $GRAILS_HOME | sed -e 's|/$||g'`
+
+# Locate GRAILS_HOME if not it is not set
+if [ -z "$GRAILS_HOME" -o ! -d "$GRAILS_HOME" ] ; then
+ # resolve links - $0 may be a link to groovy's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+ done
+
+ SAVED="`pwd`"
+ cd "`dirname \"$PRG\"`/.."
+ GRAILS_HOME="`pwd -P`"
+ cd "$SAVED"
+fi
+
+# Warn the user if JAVA_HOME and/or GRAILS_HOME are not set.
+if [ -z "$JAVA_HOME" ] ; then
+ die "JAVA_HOME environment variable is not set"
+elif [ ! -d "$JAVA_HOME" ] ; then
+ die "JAVA_HOME is not a directory: $JAVA_HOME"
+fi
+
+if [ -z "$GRAILS_HOME" ] ; then
+ warn "GRAILS_HOME environment variable is not set"
+fi
+
+if [ ! -d "$GRAILS_HOME" ] ; then
+ die "GRAILS_HOME is not a directory: $GRAILS_HOME"
+fi
+
+# Use default groovy-conf config
+if [ -z "$STARTER_CONF" ]; then
+ STARTER_CONF="$GRAILS_HOME/conf/groovy-starter.conf"
+fi
+STARTER_CLASSPATH="wrapper/grails-wrapper-runtime-2.1.1.jar:wrapper:."
+
+# Allow access to Cocoa classes on OS X
+if $darwin; then
+ STARTER_CLASSPATH="$STARTER_CLASSPATH:/System/Library/Java/Support"
+fi
+
+# Create the final classpath
+# Setting a classpath using the -cp or -classpath option means not to use
+# the global classpath. Groovy behaves then the same as the java
+# interpreter
+if [ -n "$CP" ] ; then
+ CP="$CP"
+elif [ -n "$CLASSPATH" ] ; then
+ CP="$CLASSPATH"
+fi
+
+# Determine the Java command to use to start the JVM
+if [ -z "$JAVACMD" ]; then
+ if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="java"
+ fi
+fi
+if [ ! -x "$JAVACMD" ]; then
+ die "JAVA_HOME is not defined correctly; can not execute: $JAVACMD"
+fi
+
+# Increase the maximum file descriptors if we can
+if [ "$cygwin" = "false" ]; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ "$MAX_FD_LIMIT" != "unlimited" ]; then
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ # use the businessSystem max
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+ fi
+fi
+
+# Fix the cygwin agent issue
+AGENT_GRAILS_HOME=$GRAILS_HOME
+if $cygwin ; then
+ [ -n "$GRAILS_HOME" ] &&
+ AGENT_GRAILS_HOME=`cygpath --windows "$GRAILS_HOME"`
+fi
+
+if [ -z "$GRAILS_AGENT_CACHE_DIR" ]; then
+ GRAILS_AGENT_CACHE_DIR=~/.grails/@grails.version@/
+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-core-1.0.6.jar -noverify -Dspringloaded=$SPRINGLOADED_PARAMS"
+CMD_LINE_ARGS=""
+DISABLE_RELOADING=false
+
+while true; do
+ if [ "$1" = "-cp" ] || [ "$1" = "-classpath" ]; then
+ CP=$2
+ shift 2
+ break
+ fi
+
+ if [ "$1" = "-reloading" ]; then
+ AGENT=$AGENT_STRING
+ shift
+ break
+ fi
+
+ if [ "$1" = "-noreloading" ]; then
+ DISABLE_RELOADING=true
+ shift
+ break
+ fi
+
+ if [ "$1" = "-debug" ]; then
+ JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Dgrails.full.stacktrace=true -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
+ shift
+ break
+ fi
+
+ if [ "$1" != -* ]; then
+ break
+ fi
+
+ CMD_LINE_ARGS="$CMD_LINE_ARGS $1"
+ shift
+done
+
+# Enable agent-based reloading for the 'run-app' command.
+if ! $DISABLE_RELOADING; then
+ for a in "$@"; do
+ if [ "$a" = "run-app" ]; then
+ AGENT=$AGENT_STRING
+ fi
+ done
+
+ if [ $# = 0 ]; then
+ AGENT=$AGENT_STRING
+ fi
+fi
+
+ARGUMENTS="$CMD_LINE_ARGS $@"
+
+# Setup Profiler
+useprofiler=false
+if [ "x$PROFILER" != "x" ]; then
+ if [ -r "$PROFILER" ]; then
+ . $PROFILER
+ useprofiler=true
+ else
+ die "Profiler file not found: $PROFILER"
+ fi
+fi
+
+# For Darwin, use classes.jar for TOOLS_JAR
+TOOLS_JAR="$JAVA_HOME/lib/tools.jar"
+if $darwin; then
+ JAVA_OPTS="-Xdock:name=Grails -Xdock:icon=$GRAILS_HOME/media/icons/grails.icns $JAVA_OPTS"
+# TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes/classes.jar"
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ GRAILS_HOME=`cygpath --path --mixed "$GRAILS_HOME"`
+ JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
+ STARTER_CONF=`cygpath --path --mixed "$STARTER_CONF"`
+ CP=`cygpath --path --mixed "$CP"`
+ TOOLS_JAR=`cygpath --path --mixed "$TOOLS_JAR"`
+ STARTER_CLASSPATH=`cygpath --path --mixed "$STARTER_CLASSPATH"`
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GROOVY_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GROOVY_CYGPATTERN)"
+ fi
+ # Now convert the arguments
+ ARGUMENTS=""
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ if [ $CHECK -ne 0 ] ; then
+ convArg=`cygpath --path --ignore --mixed "$arg"`
+ else
+ convArg=$arg
+ fi
+ ARGUMENTS="$ARGUMENTS $convArg"
+ done
+fi
+
+STARTER_MAIN_CLASS=org.grails.wrapper.GrailsWrapper
+
+lateInit
+
+startGrails() {
+ CLASS=$1
+ shift
+ if [ -n "$GRAILS_OPTS" ]
+ then
+ GRAILS_OPTS="$GRAILS_OPTS"
+ else
+ GRAILS_OPTS="-server -Xmx768M -Xms768M -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8"
+ fi
+ JAVA_OPTS="$GRAILS_OPTS $JAVA_OPTS $AGENT"
+ # Start the Profiler or the JVM
+ if $useprofiler; then
+ runProfiler
+ else
+ if [ $# -eq 0 ] ; then # no argument given
+ exec "$JAVACMD" $JAVA_OPTS \
+ -classpath "$STARTER_CLASSPATH" \
+ -Dgrails.home="$GRAILS_HOME" \
+ -Dtools.jar="$TOOLS_JAR" \
+ $STARTER_MAIN_CLASS \
+ --main $CLASS \
+ --conf "$STARTER_CONF" \
+ --classpath "$CP"
+ else
+ exec "$JAVACMD" $JAVA_OPTS \
+ -classpath "$STARTER_CLASSPATH" \
+ -Dgrails.home="$GRAILS_HOME" \
+ -Dtools.jar="$TOOLS_JAR" \
+ $STARTER_MAIN_CLASS \
+ --main $CLASS \
+ --conf "$STARTER_CONF" \
+ --classpath "$CP" \
+ "${ARGUMENTS}"
+ fi
+ fi
+}
+
+startGrails $STARTER_MAIN_CLASS "$@"
View
177 test/project/bookstore/grailsw.bat
@@ -0,0 +1,177 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem ##
+@rem Grails JVM Bootstrap for Windows ##
+@rem ##
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set CLASS=org.grails.wrapper.GrailsWrapper
+
+if exist "%USERPROFILE%/.groovy/preinit.bat" call "%USERPROFILE%/.groovy/preinit.bat"
+
+@rem Determine the command interpreter to execute the "CD" later
+set COMMAND_COM="cmd.exe"
+if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
+if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"
+
+@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
+set FIND_EXE="find.exe"
+if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
+if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"
+
+:check_JAVA_HOME
+@rem Make sure we have a valid JAVA_HOME
+if not "%JAVA_HOME%" == "" goto have_JAVA_HOME
+
+echo.
+echo ERROR: Environment variable JAVA_HOME has not been set.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+echo.
+goto end
+
+:have_JAVA_HOME
+@rem Remove trailing slash from JAVA_HOME if found
+if "%JAVA_HOME:~-1%"=="\" SET JAVA_HOME=%JAVA_HOME:~0,-1%
+
+@rem Validate JAVA_HOME
+%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
+if not errorlevel 1 goto check_GRAILS_HOME
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+echo.
+goto end
+
+:check_GRAILS_HOME
+@rem Define GRAILS_HOME if not set
+if "%GRAILS_HOME%" == "" set GRAILS_HOME=%DIRNAME%..
+
+@rem Remove trailing slash from GRAILS_HOME if found
+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/@grails.version@/
+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-core-1.0.6.jar -noverify -Dspringloaded=%SPRINGLOADED_PARAMS%
+set DISABLE_RELOADING=
+if "%GRAILS_OPTS%" == "" set GRAILS_OPTS=-server -Xmx768M -Xms768M -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8
+
+@rem Get command-line arguments, handling Windows variants
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set CP=
+set INTERACTIVE=true
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+set CURR_ARG=%~1
+if "%CURR_ARG:~0,2%" == "-D" (
+ set GRAILS_OPTS=%GRAILS_OPTS% %~1=%~2
+ shift
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-cp" (
+ set CP=%~2
+ shift
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-debug" (
+ set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent -Dgrails.full.stacktrace=true -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-classpath" (
+ set CP=%~2
+ shift
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-reloading" (
+ set AGENT=%AGENT_STRING%
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "xrun-app" (
+ set AGENT=%AGENT_STRING%
+ set INTERACTIVE=
+ set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
+ shift
+ goto win9xME_args_slurp
+)
+if "x%~1" == "x-noreloading" (
+ set DISABLE_RELOADING=true
+ shift
+ goto win9xME_args_slurp
+)
+set INTERACTIVE=
+set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
+shift
+goto win9xME_args_slurp
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+set STARTER_CLASSPATH=wrapper/grails-wrapper-runtime-2.1.1.jar;wrapper;.
+
+if exist "%USERPROFILE%/.groovy/init.bat" call "%USERPROFILE%/.groovy/init.bat"
+
+@rem Setting a classpath using the -cp or -classpath option means not to use
+@rem the global classpath. Groovy behaves then the same as the java interpreter
+
+if "x" == "x%CLASSPATH%" goto after_classpath
+set CP=%CP%;%CLASSPATH%
+:after_classpath
+
+if "x%DISABLE_RELOADING%" == "xtrue" (
+ set AGENT=
+) else (
+ if "x%INTERACTIVE%" == "xtrue" (
+ set AGENT=%AGENT_STRING%
+ )
+)
+
+set STARTER_MAIN_CLASS=org.grails.wrapper.GrailsWrapper
+set STARTER_CONF=%GRAILS_HOME%\conf\groovy-starter.conf
+
+set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar
+
+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=@grails.version@
+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%"
+
+if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"
+
+@rem Execute Grails
+CALL "%JAVA_EXE%" %JAVA_OPTS% -classpath "%STARTER_CLASSPATH%" %STARTER_MAIN_CLASS% --main %CLASS% --conf "%STARTER_CONF%" --classpath "%CP%" "%CMD_LINE_ARGS%"
+:end
+@rem End local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" endlocal
+
+@rem Optional pause the batch file
+if "%GROOVY_BATCH_PAUSE%" == "on" pause
+
View
17 test/project/bookstore/test/functional/bookstore/BookControllerSpec.groovy
@@ -0,0 +1,17 @@
+package bookstore
+
+import spock.lang.Specification
+import grails.test.mixin.TestFor
+
+@TestFor(BookController)
+class BookControllerSpec extends Specification {
+
+ def "book controller index"() {
+ when:
+ controller.index()
+
+ then:
+ response.status == 200
+ }
+
+}
View
11 test/project/bookstore/test/integration/bookstore/SimpleIntegrationSpec.groovy
@@ -0,0 +1,11 @@
+package bookstore
+
+import spock.lang.Specification
+
+class SimpleIntegrationSpec extends Specification {
+
+ def "asserting true"() {
+ expect:
+ true
+ }
+}
View
8 test/project/bookstore/test/integration/bookstore/SimpleIntegrationTests.groovy
@@ -1,8 +0,0 @@
-package bookstore
-
-class SimpleIntegrationTests {
-
- void testSomething() {
- assert true
- }
-}
View
12 ...ct/bookstore/test/unit/bookstore/BookTests.groovy → ...ect/bookstore/test/unit/bookstore/BookSpec.groovy
@@ -1,14 +1,20 @@
package bookstore
import grails.test.mixin.*
-import org.junit.*
+import spock.lang.Specification
@TestFor(Book)
-class BookTests {
+class BookSpec extends Specification {
- void testTitleIsRequired() {
+ def "save a book"() {
+ given:
Book book = new Book()
+
+ when:
book.save()
+
+ then:
assert "nullable" == book.errors['title'].code
}
+
}
View
BIN  test/project/bookstore/wrapper/grails-wrapper-runtime-2.1.1.jar
Binary file not shown
View
1  test/project/bookstore/wrapper/grails-wrapper.properties
@@ -0,0 +1 @@
+wrapper.dist.url=http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/
View
BIN  test/project/bookstore/wrapper/springloaded-core-1.0.6.jar
Binary file not shown
View
BIN  wrapper/grails-wrapper-runtime-2.1.1.jar
Binary file not shown
View
1  wrapper/grails-wrapper.properties
@@ -0,0 +1 @@
+wrapper.dist.url=http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/
View
BIN  wrapper/springloaded-core-1.0.6.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.