Permalink
Browse files

first cut of new geb/spock based functional test suite

  • Loading branch information...
0 parents commit 77bafbc8acfd259624cf038f6d67502210c94219 @graemerocher graemerocher committed Jan 18, 2012
Showing with 2,675 additions and 0 deletions.
  1. +32 −0 README.md
  2. +6 −0 apps/dependency-resolution/application.properties
  3. +5 −0 apps/dependency-resolution/grails-app/conf/ApplicationResources.groovy
  4. +7 −0 apps/dependency-resolution/grails-app/conf/BootStrap.groovy
  5. +46 −0 apps/dependency-resolution/grails-app/conf/BuildConfig.groovy
  6. +93 −0 apps/dependency-resolution/grails-app/conf/Config.groovy
  7. +43 −0 apps/dependency-resolution/grails-app/conf/DataSource.groovy
  8. +13 −0 apps/dependency-resolution/grails-app/conf/UrlMappings.groovy
  9. +3 −0 apps/dependency-resolution/grails-app/conf/spring/resources.groovy
  10. +55 −0 apps/dependency-resolution/grails-app/i18n/messages.properties
  11. +11 −0 apps/dependency-resolution/grails-app/views/error.gsp
  12. +116 −0 apps/dependency-resolution/grails-app/views/index.gsp
  13. +28 −0 apps/dependency-resolution/grails-app/views/layouts/main.gsp
  14. +33 −0 apps/dependency-resolution/web-app/WEB-INF/applicationContext.xml
  15. +14 −0 apps/dependency-resolution/web-app/WEB-INF/sitemesh.xml
  16. +550 −0 apps/dependency-resolution/web-app/WEB-INF/tld/grails.tld
  17. +311 −0 apps/dependency-resolution/web-app/WEB-INF/tld/spring.tld
  18. +109 −0 apps/dependency-resolution/web-app/css/errors.css
  19. +585 −0 apps/dependency-resolution/web-app/css/main.css
  20. +82 −0 apps/dependency-resolution/web-app/css/mobile.css
  21. BIN apps/dependency-resolution/web-app/images/apple-touch-icon-retina.png
  22. BIN apps/dependency-resolution/web-app/images/apple-touch-icon.png
  23. BIN apps/dependency-resolution/web-app/images/favicon.ico
  24. BIN apps/dependency-resolution/web-app/images/grails_logo.jpg
  25. BIN apps/dependency-resolution/web-app/images/grails_logo.png
  26. BIN apps/dependency-resolution/web-app/images/leftnav_btm.png
  27. BIN apps/dependency-resolution/web-app/images/leftnav_midstretch.png
  28. BIN apps/dependency-resolution/web-app/images/leftnav_top.png
  29. BIN apps/dependency-resolution/web-app/images/skin/database_add.png
  30. BIN apps/dependency-resolution/web-app/images/skin/database_delete.png
  31. BIN apps/dependency-resolution/web-app/images/skin/database_edit.png
  32. BIN apps/dependency-resolution/web-app/images/skin/database_save.png
  33. BIN apps/dependency-resolution/web-app/images/skin/database_table.png
  34. BIN apps/dependency-resolution/web-app/images/skin/exclamation.png
  35. BIN apps/dependency-resolution/web-app/images/skin/house.png
  36. BIN apps/dependency-resolution/web-app/images/skin/information.png
  37. BIN apps/dependency-resolution/web-app/images/skin/shadow.jpg
  38. BIN apps/dependency-resolution/web-app/images/skin/sorted_asc.gif
  39. BIN apps/dependency-resolution/web-app/images/skin/sorted_desc.gif
  40. BIN apps/dependency-resolution/web-app/images/spinner.gif
  41. BIN apps/dependency-resolution/web-app/images/springsource.png
  42. +9 −0 apps/dependency-resolution/web-app/js/application.js
  43. +68 −0 build.gradle
  44. BIN gradle/wrapper/gradle-wrapper.jar
  45. +6 −0 gradle/wrapper/gradle-wrapper.properties
  46. +165 −0 gradlew
  47. +16 −0 src/test/groovy/grails/functional/tests/BaseApplicationSpec.groovy
  48. +104 −0 src/test/groovy/grails/functional/tests/BaseSpec.groovy
  49. +16 −0 src/test/groovy/grails/functional/tests/RunAppSpec.groovy
  50. +92 −0 src/test/groovy/grails/functional/tests/Utils.java
  51. +57 −0 src/test/groovy/grails/functional/tests/internal/GrailsExecutor.groovy
@@ -0,0 +1,32 @@
+# Grails Functional Test Suite v2
+
+New version of the functional test suite for Grails based on Gradle, Spock and Geb.
+
+Tests are found within the <code>src/test/groovy</code> directory.
+
+A basic test looks like:
+
+ class RunAppSpec extends BaseSpec {
+ void "Test run-app starts correctly"() {
+ given:"A new project"
+ grails {
+ createApp "test"
+ runApp()
+ }
+
+ when:"The home page is requested"
+ go ""
+ then:"The Grails welcome page is shown"
+ title == "Welcome to Grails"
+ }
+ }
+
+Tests are executed using standard Gradle test command:
+
+ ./gradlew test
+
+Running a single test can be done with:
+
+ ./gradlew testSingleRunApp
+
+Where "RunApp" above is the test name
@@ -0,0 +1,6 @@
+#Grails Metadata file
+#Wed Jan 18 15:16:53 CET 2012
+app.grails.version=2.0.1.BUILD-SNAPSHOT
+app.name=dependency-resolution
+app.servlet.version=2.5
+app.version=0.1
@@ -0,0 +1,5 @@
+modules = {
+ application {
+ resource url:'js/application.js'
+ }
+}
@@ -0,0 +1,7 @@
+class BootStrap {
+
+ def init = { servletContext ->
+ }
+ def destroy = {
+ }
+}
@@ -0,0 +1,46 @@
+grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
+grails.project.class.dir = "target/classes"
+grails.project.test.class.dir = "target/test-classes"
+grails.project.test.reports.dir = "target/test-reports"
+grails.project.target.level = 1.6
+grails.project.source.level = 1.6
+//grails.project.war.file = "target/${appName}-${appVersion}.war"
+
+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'
+ checksums true // Whether to verify checksums on resolve
+
+ repositories {
+ inherits true // Whether to inherit repository definitions from plugins
+ grailsPlugins()
+ grailsHome()
+ grailsCentral()
+ mavenCentral()
+
+ // uncomment these to enable remote dependency resolution from public Maven repositories
+ //mavenCentral()
+ //mavenLocal()
+ //mavenRepo "http://snapshots.repository.codehaus.org"
+ //mavenRepo "http://repository.codehaus.org"
+ //mavenRepo "http://download.java.net/maven/2/"
+ //mavenRepo "http://repository.jboss.com/maven2/"
+ }
+ dependencies {
+ // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
+
+ // runtime 'mysql:mysql-connector-java:5.1.16'
+ }
+
+ plugins {
+ runtime ":hibernate:$grailsVersion"
+ runtime ":jquery:1.7.1"
+ runtime ":resources:1.1.5"
+
+ build ":tomcat:$grailsVersion"
+ }
+}
@@ -0,0 +1,93 @@
+// locations to search for config files that get merged into the main config
+// config files can either be Java properties files or ConfigSlurper scripts
+
+// grails.config.locations = [ "classpath:${appName}-config.properties",
+// "classpath:${appName}-config.groovy",
+// "file:${userHome}/.grails/${appName}-config.properties",
+// "file:${userHome}/.grails/${appName}-config.groovy"]
+
+// if (System.properties["${appName}.config.location"]) {
+// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
+// }
+
+
+grails.project.groupId = appName // change this to alter the default package name and Maven publishing destination
+grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
+grails.mime.use.accept.header = false
+grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
+ xml: ['text/xml', 'application/xml'],
+ text: 'text/plain',
+ js: 'text/javascript',
+ rss: 'application/rss+xml',
+ atom: 'application/atom+xml',
+ css: 'text/css',
+ csv: 'text/csv',
+ all: '*/*',
+ json: ['application/json','text/json'],
+ form: 'application/x-www-form-urlencoded',
+ multipartForm: 'multipart/form-data'
+ ]
+
+// URL Mapping Cache Max Size, defaults to 5000
+//grails.urlmapping.cache.maxsize = 1000
+
+// What URL patterns should be processed by the resources plugin
+grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*']
+
+
+// The default codec used to encode data with ${}
+grails.views.default.codec = "none" // none, html, base64
+grails.views.gsp.encoding = "UTF-8"
+grails.converters.encoding = "UTF-8"
+// enable Sitemesh preprocessing of GSP pages
+grails.views.gsp.sitemesh.preprocess = true
+// scaffolding templates configuration
+grails.scaffolding.templates.domainSuffix = 'Instance'
+
+// Set to false to use the new Grails 1.2 JSONBuilder in the render method
+grails.json.legacy.builder = false
+// enabled native2ascii conversion of i18n properties files
+grails.enable.native2ascii = true
+// packages to include in Spring bean scanning
+grails.spring.bean.packages = []
+// whether to disable processing of multi part requests
+grails.web.disable.multipart=false
+
+// request parameters to mask when logging exceptions
+grails.exceptionresolver.params.exclude = ['password']
+
+// enable query caching by default
+grails.hibernate.cache.queries = true
+
+// set per-environment serverURL stem for creating absolute links
+environments {
+ development {
+ grails.logging.jul.usebridge = true
+ }
+ production {
+ grails.logging.jul.usebridge = false
+ // TODO: grails.serverURL = "http://www.changeme.com"
+ }
+}
+
+// log4j configuration
+log4j = {
+ // Example of changing the log pattern for the default console
+ // appender:
+ //
+ //appenders {
+ // console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
+ //}
+
+ error 'org.codehaus.groovy.grails.web.servlet', // controllers
+ 'org.codehaus.groovy.grails.web.pages', // GSP
+ 'org.codehaus.groovy.grails.web.sitemesh', // layouts
+ 'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
+ 'org.codehaus.groovy.grails.web.mapping', // URL mapping
+ 'org.codehaus.groovy.grails.commons', // core / classloading
+ 'org.codehaus.groovy.grails.plugins', // plugins
+ 'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
+ 'org.springframework',
+ 'org.hibernate',
+ 'net.sf.ehcache.hibernate'
+}
@@ -0,0 +1,43 @@
+dataSource {
+ pooled = true
+ driverClassName = "org.h2.Driver"
+ username = "sa"
+ password = ""
+}
+hibernate {
+ cache.use_second_level_cache = true
+ cache.use_query_cache = true
+ cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
+}
+// environment specific settings
+environments {
+ development {
+ dataSource {
+ dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
+ url = "jdbc:h2:mem:devDb;MVCC=TRUE"
+ }
+ }
+ test {
+ dataSource {
+ dbCreate = "update"
+ url = "jdbc:h2:mem:testDb;MVCC=TRUE"
+ }
+ }
+ production {
+ dataSource {
+ dbCreate = "update"
+ url = "jdbc:h2:prodDb;MVCC=TRUE"
+ pooled = true
+ properties {
+ maxActive = -1
+ minEvictableIdleTimeMillis=1800000
+ timeBetweenEvictionRunsMillis=1800000
+ numTestsPerEvictionRun=3
+ testOnBorrow=true
+ testWhileIdle=true
+ testOnReturn=true
+ validationQuery="SELECT 1"
+ }
+ }
+ }
+}
@@ -0,0 +1,13 @@
+class UrlMappings {
+
+ static mappings = {
+ "/$controller/$action?/$id?"{
+ constraints {
+ // apply constraints here
+ }
+ }
+
+ "/"(view:"/index")
+ "500"(view:'/error')
+ }
+}
@@ -0,0 +1,3 @@
+// Place your Spring DSL code here
+beans = {
+}
@@ -0,0 +1,55 @@
+default.doesnt.match.message=Property [{0}] of class [{1}] with value [{2}] does not match the required pattern [{3}]
+default.invalid.url.message=Property [{0}] of class [{1}] with value [{2}] is not a valid URL
+default.invalid.creditCard.message=Property [{0}] of class [{1}] with value [{2}] is not a valid credit card number
+default.invalid.email.message=Property [{0}] of class [{1}] with value [{2}] is not a valid e-mail address
+default.invalid.range.message=Property [{0}] of class [{1}] with value [{2}] does not fall within the valid range from [{3}] to [{4}]
+default.invalid.size.message=Property [{0}] of class [{1}] with value [{2}] does not fall within the valid size range from [{3}] to [{4}]
+default.invalid.max.message=Property [{0}] of class [{1}] with value [{2}] exceeds maximum value [{3}]
+default.invalid.min.message=Property [{0}] of class [{1}] with value [{2}] is less than minimum value [{3}]
+default.invalid.max.size.message=Property [{0}] of class [{1}] with value [{2}] exceeds the maximum size of [{3}]
+default.invalid.min.size.message=Property [{0}] of class [{1}] with value [{2}] is less than the minimum size of [{3}]
+default.invalid.validator.message=Property [{0}] of class [{1}] with value [{2}] does not pass custom validation
+default.not.inlist.message=Property [{0}] of class [{1}] with value [{2}] is not contained within the list [{3}]
+default.blank.message=Property [{0}] of class [{1}] cannot be blank
+default.not.equal.message=Property [{0}] of class [{1}] with value [{2}] cannot equal [{3}]
+default.null.message=Property [{0}] of class [{1}] cannot be null
+default.not.unique.message=Property [{0}] of class [{1}] with value [{2}] must be unique
+
+default.paginate.prev=Previous
+default.paginate.next=Next
+default.boolean.true=True
+default.boolean.false=False
+default.date.format=yyyy-MM-dd HH:mm:ss z
+default.number.format=0
+
+default.created.message={0} {1} created
+default.updated.message={0} {1} updated
+default.deleted.message={0} {1} deleted
+default.not.deleted.message={0} {1} could not be deleted
+default.not.found.message={0} not found with id {1}
+default.optimistic.locking.failure=Another user has updated this {0} while you were editing
+
+default.home.label=Home
+default.list.label={0} List
+default.add.label=Add {0}
+default.new.label=New {0}
+default.create.label=Create {0}
+default.show.label=Show {0}
+default.edit.label=Edit {0}
+
+default.button.create.label=Create
+default.button.edit.label=Edit
+default.button.update.label=Update
+default.button.delete.label=Delete
+default.button.delete.confirm.message=Are you sure?
+
+# Data binding errors. Use "typeMismatch.$className.$propertyName to customize (eg typeMismatch.Book.author)
+typeMismatch.java.net.URL=Property {0} must be a valid URL
+typeMismatch.java.net.URI=Property {0} must be a valid URI
+typeMismatch.java.util.Date=Property {0} must be a valid Date
+typeMismatch.java.lang.Double=Property {0} must be a valid number
+typeMismatch.java.lang.Integer=Property {0} must be a valid number
+typeMismatch.java.lang.Long=Property {0} must be a valid number
+typeMismatch.java.lang.Short=Property {0} must be a valid number
+typeMismatch.java.math.BigDecimal=Property {0} must be a valid number
+typeMismatch.java.math.BigInteger=Property {0} must be a valid number
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Grails Runtime Exception</title>
+ <meta name="layout" content="main">
+ <link rel="stylesheet" href="${resource(dir: 'css', file: 'errors.css')}" type="text/css">
+ </head>
+ <body>
+ <g:renderException exception="${exception}" />
+ </body>
+</html>
Oops, something went wrong.

0 comments on commit 77bafbc

Please sign in to comment.