Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore demo 33 #433

Merged
merged 12 commits into from
Sep 30, 2024
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ subprojects { project ->
apply plugin: "groovy"
if (project.name.startsWith("examples")) {
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.plugins.views-json"
//apply plugin: "org.grails.plugins.views-json"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required for tests here, issue: grails/grails-views#587

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is used to compile examples/demo33/grails-app/views/json/index.gson

} else {
apply plugin: "java-library"
if (isGrailsPlugin) {
Expand Down Expand Up @@ -125,6 +125,7 @@ subprojects { project ->
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testImplementation "org.junit.platform:junit-platform-runner:$junitPlatformVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
testRuntimeOnly "org.junit.platform:junit-platform-commons:$junitCommonsVersion"
}

tasks.withType(Test) {
Expand Down
15 changes: 7 additions & 8 deletions examples/demo33/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ apply plugin:"com.github.erdi.webdriver-binaries"

webdriverBinaries {
if (!System.getenv().containsKey('CI')) {
chromedriver "$chromeDriverVersion"
geckodriver "$geckodriverVersion"
chromedriver "$chromeDriverVersion"
}
}

Expand Down Expand Up @@ -45,17 +45,16 @@ dependencies {
runtimeOnly "com.h2database:h2"
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:$assetPipelineVersion"
testImplementation "org.grails.plugins:geb"
testRuntimeOnly "org.seleniumhq.selenium:htmlunit-driver:$seleniumHtmlunitVersion"
testRuntimeOnly "net.sourceforge.htmlunit:htmlunit:$htmlunitVersion"

testImplementation project(':grails-web-testing-support')
testImplementation project(':grails-gorm-testing-support')

testImplementation "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
testImplementation "org.seleniumhq.selenium:selenium-api:$seleniumVersion"
testImplementation "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
testImplementation "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.grails.plugins:geb"
jamesfredley marked this conversation as resolved.
Show resolved Hide resolved
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-api:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
}

bootRun {
Expand Down
8 changes: 0 additions & 8 deletions examples/demo33/gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package demo

import grails.testing.mixin.integration.Integration
import grails.testing.spock.OnceBefore
import grails.testing.spock.RunOnce
import org.junit.Before
import spock.lang.Specification

@Integration
class DependencyInjectionSpec extends Specification {

HelperService helperService

@OnceBefore
@Before
@RunOnce
void init() {
assert helperService != null
}
jamesfredley marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
35 changes: 31 additions & 4 deletions examples/demo33/src/integration-test/resources/GebConfig.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions

driver = {
ChromeOptions o = new ChromeOptions()
o.addArguments('headless')
new ChromeDriver(o)
environments {

// run via “./gradlew -Dgeb.env=chrome iT”
chrome {
driver = { new ChromeDriver() }
}

// run via “./gradlew -Dgeb.env=chromeHeadless iT”
chromeHeadless {
driver = {
ChromeOptions o = new ChromeOptions()
o.addArguments('headless')
new ChromeDriver(o)
}
}

// run via “./gradlew -Dgeb.env=firefoxHeadless iT”
firefoxHeadless {
driver = {
FirefoxOptions o = new FirefoxOptions()
o.addArguments('-headless')
new FirefoxDriver(o)
}
}

// run via “./gradlew -Dgeb.env=firefox iT”
firefox {
driver = { new FirefoxDriver() }
}
}
5 changes: 5 additions & 0 deletions examples/demo33/src/test/groovy/demo/AutowiredTestSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package demo

// tag::test_declaration[]
import grails.testing.spring.AutowiredTest
import spock.lang.Ignore
import spock.lang.PendingFeature
import spock.lang.Specification

@Ignore('helperService is null')
class AutowiredTestSpec extends Specification implements AutowiredTest {

Closure doWithSpring() {{ ->
Expand All @@ -16,11 +19,13 @@ class AutowiredTestSpec extends Specification implements AutowiredTest {
assert helperService != null
}

@PendingFeature(reason = 'helperService is null')
void 'some test method'() {
expect:
helperService != null
}

@PendingFeature(reason = 'helperService is null')
void 'some other test method'() {
expect:
helperService != null
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/CarServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package demo

import grails.testing.gorm.DataTest
import grails.testing.services.ServiceUnitTest
import spock.lang.Ignore
import spock.lang.Specification

@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class CarServiceSpec extends Specification implements ServiceUnitTest<CarService>, DataTest{

void setupSpec() {
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/CarSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package demo

import grails.testing.gorm.DomainUnitTest
import spock.lang.Ignore
import spock.lang.Specification

@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class CarSpec extends Specification implements DomainUnitTest<Car> {

def setup() {
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/ConfigServiceSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package demo

import grails.testing.services.ServiceUnitTest
import spock.lang.PendingFeature
import spock.lang.Specification

class ConfigServiceSpec extends Specification implements ServiceUnitTest<ConfigService> {
Expand All @@ -9,6 +10,7 @@ class ConfigServiceSpec extends Specification implements ServiceUnitTest<ConfigS
config['mc.allow.signup'] = true
}}

@PendingFeature(reason = 'isSignupAllowed() == false')
def "singup is allowed if configuration parameter is set"() {
expect:
service.isSignupAllowed()
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/DataTestTraitSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package demo

import grails.testing.gorm.DataTest
import spock.lang.Ignore
import spock.lang.Specification

@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class DataTestTraitSpec extends Specification implements DataTest {

void setupSpec() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package demo

import grails.testing.gorm.DomainUnitTest
import spock.lang.Ignore
import spock.lang.Specification

@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class DefaultNullableConstraintConfigSpec extends Specification implements DomainUnitTest<Person> {

Closure doWithConfig() {{ c ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package demo

import grails.testing.gorm.DataTest
import spock.lang.Ignore
import spock.lang.Specification

@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class GetDomainClassesToMockMethodSpec extends Specification implements DataTest {

Class[] getDomainClassesToMock() {
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/LocaleTagLibSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package demo
import grails.testing.web.taglib.TagLibUnitTest
import grails.validation.Validateable
import org.springframework.context.i18n.LocaleContextHolder
import spock.lang.PendingFeature
import spock.lang.Specification

class LocaleTagLibSpec extends Specification implements TagLibUnitTest<SampleTagLib> {

@PendingFeature(reason = 'Field error in object \'demo.Widget\' on field \'title\': rejected value [null]; codes [demo.Widget.title.nullable.error.demo.Widget.title,demo.Widget.title.nullable.error.title,demo.Widget.title.nullable.error.java.lang.String,demo.Widget.title.nullable.error,widget.title.nullable.error.demo.Widget.title,widget.title.nullable.error.title,widget.title.nullable.error.java.lang.String,widget.title.nullable.error,demo.Widget.title.nullable.demo.Widget.title,demo.Widget.title.nullable.title,demo.Widget.title.nullable.java.lang.String,demo.Widget.title.nullable,widget.title.nullable.demo.Widget.title,widget.title.nullable.title,widget.title.nullable.java.lang.String,widget.title.nullable,nullable.demo.Widget.title,nullable.title,nullable.java.lang.String,nullable]; arguments [title,class demo.Widget]; default message [Property [{0}] of class [{1}] cannot be null] grails_validation_Validateable__beforeValidateHelper=org.grails.datastore.gorm.support.BeforeValidateHelper@d7da0ae>')
void 'test customizing messageSource'() {
given:
def w = new Widget()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package demo

import grails.test.hibernate.HibernateSpec
import grails.testing.web.controllers.ControllerUnitTest
import spock.lang.Ignore

class PersonControllerHibernateSpec extends HibernateSpec implements ControllerUnitTest<PersonController> {

@Ignore('Either class [demo.Person] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.')
void "test action which invokes GORM method"() {

setup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package demo

import grails.testing.gorm.DataTest
import grails.testing.web.controllers.ControllerUnitTest
import spock.lang.Ignore
import spock.lang.Specification

@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class PersonControllerSpec extends Specification implements ControllerUnitTest<PersonController>, DataTest {

void setupSpec() {
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/PersonServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package demo

import grails.testing.gorm.DataTest
import grails.testing.services.ServiceUnitTest
import spock.lang.Ignore
import spock.lang.Issue
import spock.lang.Specification

@Issue('grails/grails-testing-support#18')
@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class PersonServiceSpec extends Specification implements ServiceUnitTest<PersonService>, DataTest {

void setupSpec() {
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/PersonSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package demo

import grails.testing.gorm.DomainUnitTest
import spock.lang.Ignore
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Stepwise

@Stepwise
@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class PersonSpec extends Specification implements DomainUnitTest<Person> {

@Shared int id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package demo

import grails.testing.services.ServiceUnitTest
import spock.lang.PendingFeature
import spock.lang.Specification

class ReportingServiceSpec extends Specification implements ServiceUnitTest<ReportingService> {
Expand All @@ -10,6 +11,7 @@ class ReportingServiceSpec extends Specification implements ServiceUnitTest<Repo
someHelper RushHelper
}}

@PendingFeature(reason = 'java.lang.NullPointerException: Cannot get property \'someNumber\' on null object')
void "test dependency injection"() {
expect:
service.retrieveSomeNumber() == 2112
Expand Down
2 changes: 2 additions & 0 deletions examples/demo33/src/test/groovy/demo/TestServiceSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package demo

import grails.testing.services.ServiceUnitTest
import spock.lang.PendingFeature
import spock.lang.Specification

class TestServiceSpec extends Specification implements ServiceUnitTest<TestService> {
Expand All @@ -15,6 +16,7 @@ class TestServiceSpec extends Specification implements ServiceUnitTest<TestServi
config.demo = ["foo": "test"]
} }

@PendingFeature(reason = 'bar != test')
void "when local-override is set then the service picks the update config value"() {
expect:
service.foo == "test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package demo

import grails.persistence.Entity
import grails.testing.gorm.DataTest
import groovy.transform.NotYetImplemented
import groovy.test.NotYetImplemented
import spock.lang.Ignore
import spock.lang.Specification

@Ignore('Cannot invoke "org.grails.orm.hibernate.HibernateGormEnhancer.registerEntity(org.grails.datastore.mapping.model.PersistentEntity)" because "this.this$0.gormEnhancer" is null')
class UniqueConstraintOnHasOneSpec extends Specification implements DataTest {

void setupSpec() {
Expand Down
12 changes: 8 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ githubSlug=grails/grails-testing-support
githubBranch=4.0.x
developers=Jeff Brown,James Kleeh

asciidoctorJvmVersion=4.0.3
#4.0.2-4.0.3 breaks org.ysb33r.gradle:grolifant for chromedriver
asciidoctorJvmVersion=4.0.1
assetPipelineVersion=5.0.1
bytebuddyVersion=1.15.1
grailsGradlePluginVersion=7.0.0-SNAPSHOT
Expand All @@ -24,19 +25,22 @@ javassistVersion=3.30.2-GA
javaParserVersion=3.25.10
jlineVersion=2.14.6
jsonViewsVersion=4.0.0-SNAPSHOT
junitPlatformVersion=1.11.0
junitJupiterVersion=5.11.0
junitPlatformVersion=1.11.1
junitJupiterVersion=5.11.1
junitCommonsVersion=1.11.1
objenesisVersion=3.4
picocliVersion=4.7.6
seleniumVersion=4.23.1
seleniumHtmlunitVersion=4.13.0
htmlunitVersion=2.7.0
htmlunitVersion=4.4.0
servletApiVersion=6.0.0
slf4jVersion=2.0.16
spockVersion=2.3-groovy-4.0
springVersion=6.1.13
springBootVersion=3.3.4
webdriverBinariesVersion=3.2
chromeDriverVersion=126.0.6478.126
geckodriverVersion=0.32.2

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ include 'grails-testing-support',
'grails-web-testing-support',
'grails-gorm-testing-support'

//include 'examples-demo33'
// project(":examples-demo33").projectDir = new File(settingsDir, "examples/demo33")
include 'examples-demo33'
project(":examples-demo33").projectDir = new File(settingsDir, "examples/demo33")

Loading