Skip to content

Commit

Permalink
Grails 7: initial work on tests: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoehm committed Dec 17, 2024
1 parent e436a04 commit 2b417d9
Show file tree
Hide file tree
Showing 28 changed files with 176 additions and 621 deletions.
3 changes: 1 addition & 2 deletions examples/extended/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ dependencies {
implementation "org.grails:grails-plugin-services"
implementation "org.grails:grails-plugin-url-mappings"
implementation "org.grails:grails-plugin-interceptors"
implementation "org.grails.plugins:cache"
implementation "org.grails.plugins:async"
implementation "org.grails.plugins:scaffolding"
implementation "org.grails.plugins:events"
implementation "org.grails.plugins:hibernate5"
implementation "org.hibernate:hibernate-core:$hibernateCoreVersion"
implementation "org.hibernate:hibernate-core-jakarta:$hibernateCoreVersion"
implementation "org.grails.plugins:gsp"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
Expand Down
195 changes: 59 additions & 136 deletions examples/extended/grails-app/conf/application.yml
Original file line number Diff line number Diff line change
@@ -1,143 +1,66 @@
---
grails:
profile: web
codegen:
defaultPackage: test
spring:
transactionManagement:
proxies: false
gorm:
# Whether to autowire entities.
# Disabled by default for performance reasons.
autowire: false
reactor:
# Whether to translate GORM events into Reactor events
# Disabled by default for performance reasons
events: false
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
spring:
main:
banner-mode: "off"
groovy:
template:
check-template-location: false

# Spring Actuator Endpoints are Disabled by Default
endpoints:
enabled: false
jmx:
enabled: true

---
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
endpoints:
jmx:
unique-names: true

---
---
hibernate:
cache:
queries: false
use_query_cache: false
use_second_level_cache: false
format_sql: true
use_sql_comments: true

views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlet: html
taglib: none
staticparts: none
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
dataSource:
dbCreate: update
driverClassName: org.h2.Driver
jmxExport: true
password:
pooled: true
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
username: sa
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
driverClassName: org.h2.Driver
username: sa
password: ''
pooled: true
jmxExport: true
dbCreate: update
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false

environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: none
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
---
grails:
mail:
Expand Down
4 changes: 4 additions & 0 deletions examples/extended/grails-app/domain/test/User.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class User implements Serializable {

static transients = ['springSecurityService']

static mapping = {
table name: '`user`'
}

static constraints = {
email nullable: true, email: true, unique: true
username unique: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package spec

import grails.testing.mixin.integration.Integration
import page.aclClass.AclClassCreatePage
import page.aclClass.AclClassEditPage
import page.aclClass.AclClassSearchPage
import spock.lang.IgnoreIf

@IgnoreIf({
if (!System.getProperty('geb.env')) {
return true
}
if (System.getProperty('geb.env') == 'phantomjs' && !System.getProperty('phantomjs.binary.path')) {
return true
}
if (System.getProperty('geb.env') == 'chrome' && !System.getProperty('webdriver.chrome.driver')) {
return true
}
false
})
@Integration
class AclClassSpec extends AbstractSecuritySpec {

void testFindAll() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package spec

import grails.testing.mixin.integration.Integration
import page.aclEntry.AclEntryCreatePage
import page.aclEntry.AclEntryEditPage
import page.aclEntry.AclEntrySearchPage
import spock.lang.IgnoreIf

@IgnoreIf({
if (!System.getProperty('geb.env')) {
return true
}
if (System.getProperty('geb.env') == 'phantomjs' && !System.getProperty('phantomjs.binary.path')) {
return true
}
if (System.getProperty('geb.env') == 'chrome' && !System.getProperty('webdriver.chrome.driver')) {
return true
}
false
})
@Integration
class AclEntrySpec extends AbstractSecuritySpec {

void testFindAll() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package spec

import grails.testing.mixin.integration.Integration
import page.aclObjectIdentity.AclObjectIdentityCreatePage
import page.aclObjectIdentity.AclObjectIdentityEditPage
import page.aclObjectIdentity.AclObjectIdentitySearchPage
import spock.lang.IgnoreIf

@IgnoreIf({
if (!System.getProperty('geb.env')) {
return true
}
if (System.getProperty('geb.env') == 'phantomjs' && !System.getProperty('phantomjs.binary.path')) {
return true
}
if (System.getProperty('geb.env') == 'chrome' && !System.getProperty('webdriver.chrome.driver')) {
return true
}
false
})
@Integration
class AclObjectIdentitySpec extends AbstractSecuritySpec {

void testFindAll() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package spec

import grails.testing.mixin.integration.Integration
import page.aclSid.AclSidCreatePage
import page.aclSid.AclSidEditPage
import page.aclSid.AclSidSearchPage
import spock.lang.IgnoreIf

@IgnoreIf({
if (!System.getProperty('geb.env')) {
return true
}
if (System.getProperty('geb.env') == 'phantomjs' && !System.getProperty('phantomjs.binary.path')) {
return true
}
if (System.getProperty('geb.env') == 'chrome' && !System.getProperty('webdriver.chrome.driver')) {
return true
}
false
})
@Integration
class AclSidSpec extends AbstractSecuritySpec {

void testFindAll() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
package spec

import spock.lang.IgnoreIf

@IgnoreIf({
if (!System.getProperty('geb.env')) {
return true
}
if (System.getProperty('geb.env') == 'phantomjs' && !System.getProperty('phantomjs.binary.path')) {
return true
}
if (System.getProperty('geb.env') == 'chrome' && !System.getProperty('webdriver.chrome.driver')) {
return true
}
false
})
import grails.testing.mixin.integration.Integration

@Integration
class ExtendedMenuSpec extends AbstractSecuritySpec {

void testIndex() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
package spec

import spock.lang.IgnoreIf

@IgnoreIf({
if (!System.getProperty('geb.env')) {
return true
}
if (System.getProperty('geb.env') == 'phantomjs' && !System.getProperty('phantomjs.binary.path')) {
return true
}
if (System.getProperty('geb.env') == 'chrome' && !System.getProperty('webdriver.chrome.driver')) {
return true
}
false
})
import grails.testing.mixin.integration.Integration

@Integration
class ExtendedSecurityInfoSpec extends AbstractSecuritySpec {

void testConfig() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
package spec

import grails.testing.mixin.integration.Integration
import page.persistentLogin.PersistentLoginSearchPage
import spock.lang.IgnoreIf

@IgnoreIf({
if (!System.getProperty('geb.env')) {
return true
}
if (System.getProperty('geb.env') == 'phantomjs' && !System.getProperty('phantomjs.binary.path')) {
return true
}
if (System.getProperty('geb.env') == 'chrome' && !System.getProperty('webdriver.chrome.driver')) {
return true
}
false
})
@Integration
class PersistentLoginSpec extends AbstractSecuritySpec {

void testFindAll() {
Expand Down
Loading

0 comments on commit 2b417d9

Please sign in to comment.