diff --git a/grails-testing-support/examples/demo33/build.gradle b/demo33/build.gradle similarity index 76% rename from grails-testing-support/examples/demo33/build.gradle rename to demo33/build.gradle index 8b1ef087..13662716 100644 --- a/grails-testing-support/examples/demo33/build.gradle +++ b/demo33/build.gradle @@ -1,4 +1,23 @@ +buildscript { + repositories { + maven { url "https://repo.grails.org/grails/core" } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + classpath "org.grails.plugins:views-gradle:$viewsVersion" + } +} + +group "org.grails" +version '0.0.1' + +apply plugin:"org.grails.grails-web" +apply plugin:"org.grails.plugins.views-json" +apply plugin: "org.grails.grails-gsp" + dependencies { + implementation platform("org.grails:grails-bom:$grailsVersion") + implementation "org.springframework.boot:spring-boot-starter-logging" implementation "org.springframework.boot:spring-boot-autoconfigure" implementation "org.grails:grails-core" @@ -27,8 +46,8 @@ dependencies { runtimeOnly "org.apache.tomcat:tomcat-jdbc" runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails" - testImplementation project(':grails-web-testing-support') - testImplementation project(':grails-gorm-testing-support') + testImplementation 'org.grails:grails-web-testing-support' + testImplementation 'org.grails:grails-gorm-testing-support' } bootRun { diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/apple-touch-icon-retina.png b/demo33/grails-app/assets/images/apple-touch-icon-retina.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/apple-touch-icon-retina.png rename to demo33/grails-app/assets/images/apple-touch-icon-retina.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/apple-touch-icon.png b/demo33/grails-app/assets/images/apple-touch-icon.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/apple-touch-icon.png rename to demo33/grails-app/assets/images/apple-touch-icon.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/favicon.ico b/demo33/grails-app/assets/images/favicon.ico similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/favicon.ico rename to demo33/grails-app/assets/images/favicon.ico diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/grails-cupsonly-logo-white.svg b/demo33/grails-app/assets/images/grails-cupsonly-logo-white.svg similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/grails-cupsonly-logo-white.svg rename to demo33/grails-app/assets/images/grails-cupsonly-logo-white.svg diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_add.png b/demo33/grails-app/assets/images/skin/database_add.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_add.png rename to demo33/grails-app/assets/images/skin/database_add.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_delete.png b/demo33/grails-app/assets/images/skin/database_delete.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_delete.png rename to demo33/grails-app/assets/images/skin/database_delete.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_edit.png b/demo33/grails-app/assets/images/skin/database_edit.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_edit.png rename to demo33/grails-app/assets/images/skin/database_edit.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_save.png b/demo33/grails-app/assets/images/skin/database_save.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_save.png rename to demo33/grails-app/assets/images/skin/database_save.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_table.png b/demo33/grails-app/assets/images/skin/database_table.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/database_table.png rename to demo33/grails-app/assets/images/skin/database_table.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/exclamation.png b/demo33/grails-app/assets/images/skin/exclamation.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/exclamation.png rename to demo33/grails-app/assets/images/skin/exclamation.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/house.png b/demo33/grails-app/assets/images/skin/house.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/house.png rename to demo33/grails-app/assets/images/skin/house.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/information.png b/demo33/grails-app/assets/images/skin/information.png similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/information.png rename to demo33/grails-app/assets/images/skin/information.png diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/shadow.jpg b/demo33/grails-app/assets/images/skin/shadow.jpg similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/shadow.jpg rename to demo33/grails-app/assets/images/skin/shadow.jpg diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/sorted_asc.gif b/demo33/grails-app/assets/images/skin/sorted_asc.gif similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/sorted_asc.gif rename to demo33/grails-app/assets/images/skin/sorted_asc.gif diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/skin/sorted_desc.gif b/demo33/grails-app/assets/images/skin/sorted_desc.gif similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/skin/sorted_desc.gif rename to demo33/grails-app/assets/images/skin/sorted_desc.gif diff --git a/grails-testing-support/examples/demo33/grails-app/assets/images/spinner.gif b/demo33/grails-app/assets/images/spinner.gif similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/images/spinner.gif rename to demo33/grails-app/assets/images/spinner.gif diff --git a/grails-testing-support/examples/demo33/grails-app/assets/javascripts/application.js b/demo33/grails-app/assets/javascripts/application.js similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/javascripts/application.js rename to demo33/grails-app/assets/javascripts/application.js diff --git a/grails-testing-support/examples/demo33/grails-app/assets/javascripts/bootstrap.js b/demo33/grails-app/assets/javascripts/bootstrap.js similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/javascripts/bootstrap.js rename to demo33/grails-app/assets/javascripts/bootstrap.js diff --git a/grails-testing-support/examples/demo33/grails-app/assets/javascripts/jquery-2.2.0.min.js b/demo33/grails-app/assets/javascripts/jquery-2.2.0.min.js similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/javascripts/jquery-2.2.0.min.js rename to demo33/grails-app/assets/javascripts/jquery-2.2.0.min.js diff --git a/grails-testing-support/examples/demo33/grails-app/assets/stylesheets/application.css b/demo33/grails-app/assets/stylesheets/application.css similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/stylesheets/application.css rename to demo33/grails-app/assets/stylesheets/application.css diff --git a/grails-testing-support/examples/demo33/grails-app/assets/stylesheets/bootstrap.css b/demo33/grails-app/assets/stylesheets/bootstrap.css similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/stylesheets/bootstrap.css rename to demo33/grails-app/assets/stylesheets/bootstrap.css diff --git a/grails-testing-support/examples/demo33/grails-app/assets/stylesheets/errors.css b/demo33/grails-app/assets/stylesheets/errors.css similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/stylesheets/errors.css rename to demo33/grails-app/assets/stylesheets/errors.css diff --git a/grails-testing-support/examples/demo33/grails-app/assets/stylesheets/grails.css b/demo33/grails-app/assets/stylesheets/grails.css similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/stylesheets/grails.css rename to demo33/grails-app/assets/stylesheets/grails.css diff --git a/grails-testing-support/examples/demo33/grails-app/assets/stylesheets/main.css b/demo33/grails-app/assets/stylesheets/main.css similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/stylesheets/main.css rename to demo33/grails-app/assets/stylesheets/main.css diff --git a/grails-testing-support/examples/demo33/grails-app/assets/stylesheets/mobile.css b/demo33/grails-app/assets/stylesheets/mobile.css similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/assets/stylesheets/mobile.css rename to demo33/grails-app/assets/stylesheets/mobile.css diff --git a/grails-testing-support/examples/demo33/grails-app/conf/application.yml b/demo33/grails-app/conf/application.yml similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/conf/application.yml rename to demo33/grails-app/conf/application.yml diff --git a/grails-testing-support/examples/demo33/grails-app/conf/logback.xml b/demo33/grails-app/conf/logback.xml similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/conf/logback.xml rename to demo33/grails-app/conf/logback.xml diff --git a/grails-testing-support/examples/demo33/grails-app/conf/spring/resources.groovy b/demo33/grails-app/conf/spring/resources.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/conf/spring/resources.groovy rename to demo33/grails-app/conf/spring/resources.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/DemoController.groovy b/demo33/grails-app/controllers/demo/DemoController.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/DemoController.groovy rename to demo33/grails-app/controllers/demo/DemoController.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/DemoUrlMappings.groovy b/demo33/grails-app/controllers/demo/DemoUrlMappings.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/DemoUrlMappings.groovy rename to demo33/grails-app/controllers/demo/DemoUrlMappings.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/JsonController.groovy b/demo33/grails-app/controllers/demo/JsonController.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/JsonController.groovy rename to demo33/grails-app/controllers/demo/JsonController.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/NamePropertyController.groovy b/demo33/grails-app/controllers/demo/NamePropertyController.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/NamePropertyController.groovy rename to demo33/grails-app/controllers/demo/NamePropertyController.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/PersonController.groovy b/demo33/grails-app/controllers/demo/PersonController.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/PersonController.groovy rename to demo33/grails-app/controllers/demo/PersonController.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/SubController.groovy b/demo33/grails-app/controllers/demo/SubController.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/SubController.groovy rename to demo33/grails-app/controllers/demo/SubController.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/TestController.groovy b/demo33/grails-app/controllers/demo/TestController.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/TestController.groovy rename to demo33/grails-app/controllers/demo/TestController.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/TestInterceptor.groovy b/demo33/grails-app/controllers/demo/TestInterceptor.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/TestInterceptor.groovy rename to demo33/grails-app/controllers/demo/TestInterceptor.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/controllers/demo/UrlMappings.groovy b/demo33/grails-app/controllers/demo/UrlMappings.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/controllers/demo/UrlMappings.groovy rename to demo33/grails-app/controllers/demo/UrlMappings.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/domain/demo/Car.groovy b/demo33/grails-app/domain/demo/Car.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/domain/demo/Car.groovy rename to demo33/grails-app/domain/demo/Car.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/domain/demo/Person.groovy b/demo33/grails-app/domain/demo/Person.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/domain/demo/Person.groovy rename to demo33/grails-app/domain/demo/Person.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages.properties b/demo33/grails-app/i18n/messages.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages.properties rename to demo33/grails-app/i18n/messages.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_cs_CZ.properties b/demo33/grails-app/i18n/messages_cs_CZ.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_cs_CZ.properties rename to demo33/grails-app/i18n/messages_cs_CZ.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_da.properties b/demo33/grails-app/i18n/messages_da.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_da.properties rename to demo33/grails-app/i18n/messages_da.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_de.properties b/demo33/grails-app/i18n/messages_de.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_de.properties rename to demo33/grails-app/i18n/messages_de.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_es.properties b/demo33/grails-app/i18n/messages_es.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_es.properties rename to demo33/grails-app/i18n/messages_es.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_fr.properties b/demo33/grails-app/i18n/messages_fr.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_fr.properties rename to demo33/grails-app/i18n/messages_fr.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_it.properties b/demo33/grails-app/i18n/messages_it.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_it.properties rename to demo33/grails-app/i18n/messages_it.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_ja.properties b/demo33/grails-app/i18n/messages_ja.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_ja.properties rename to demo33/grails-app/i18n/messages_ja.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_nb.properties b/demo33/grails-app/i18n/messages_nb.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_nb.properties rename to demo33/grails-app/i18n/messages_nb.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_nl.properties b/demo33/grails-app/i18n/messages_nl.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_nl.properties rename to demo33/grails-app/i18n/messages_nl.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_pl.properties b/demo33/grails-app/i18n/messages_pl.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_pl.properties rename to demo33/grails-app/i18n/messages_pl.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_pt_BR.properties b/demo33/grails-app/i18n/messages_pt_BR.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_pt_BR.properties rename to demo33/grails-app/i18n/messages_pt_BR.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_pt_PT.properties b/demo33/grails-app/i18n/messages_pt_PT.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_pt_PT.properties rename to demo33/grails-app/i18n/messages_pt_PT.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_ru.properties b/demo33/grails-app/i18n/messages_ru.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_ru.properties rename to demo33/grails-app/i18n/messages_ru.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_sv.properties b/demo33/grails-app/i18n/messages_sv.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_sv.properties rename to demo33/grails-app/i18n/messages_sv.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_th.properties b/demo33/grails-app/i18n/messages_th.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_th.properties rename to demo33/grails-app/i18n/messages_th.properties diff --git a/grails-testing-support/examples/demo33/grails-app/i18n/messages_zh_CN.properties b/demo33/grails-app/i18n/messages_zh_CN.properties similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/i18n/messages_zh_CN.properties rename to demo33/grails-app/i18n/messages_zh_CN.properties diff --git a/grails-testing-support/examples/demo33/grails-app/init/demo/Application.groovy b/demo33/grails-app/init/demo/Application.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/init/demo/Application.groovy rename to demo33/grails-app/init/demo/Application.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/init/demo/BootStrap.groovy b/demo33/grails-app/init/demo/BootStrap.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/init/demo/BootStrap.groovy rename to demo33/grails-app/init/demo/BootStrap.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/services/demo/CarService.groovy b/demo33/grails-app/services/demo/CarService.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/services/demo/CarService.groovy rename to demo33/grails-app/services/demo/CarService.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/services/demo/ConfigService.groovy b/demo33/grails-app/services/demo/ConfigService.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/services/demo/ConfigService.groovy rename to demo33/grails-app/services/demo/ConfigService.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/services/demo/HelperService.groovy b/demo33/grails-app/services/demo/HelperService.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/services/demo/HelperService.groovy rename to demo33/grails-app/services/demo/HelperService.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/services/demo/NamePropertyService.groovy b/demo33/grails-app/services/demo/NamePropertyService.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/services/demo/NamePropertyService.groovy rename to demo33/grails-app/services/demo/NamePropertyService.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/services/demo/PersonService.groovy b/demo33/grails-app/services/demo/PersonService.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/services/demo/PersonService.groovy rename to demo33/grails-app/services/demo/PersonService.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/services/demo/ReportingService.groovy b/demo33/grails-app/services/demo/ReportingService.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/services/demo/ReportingService.groovy rename to demo33/grails-app/services/demo/ReportingService.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/services/demo/TestService.groovy b/demo33/grails-app/services/demo/TestService.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/services/demo/TestService.groovy rename to demo33/grails-app/services/demo/TestService.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/taglib/demo/FirstTagLib.groovy b/demo33/grails-app/taglib/demo/FirstTagLib.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/taglib/demo/FirstTagLib.groovy rename to demo33/grails-app/taglib/demo/FirstTagLib.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/taglib/demo/SampleTagLib.groovy b/demo33/grails-app/taglib/demo/SampleTagLib.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/taglib/demo/SampleTagLib.groovy rename to demo33/grails-app/taglib/demo/SampleTagLib.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/taglib/demo/SecondTagLib.groovy b/demo33/grails-app/taglib/demo/SecondTagLib.groovy similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/taglib/demo/SecondTagLib.groovy rename to demo33/grails-app/taglib/demo/SecondTagLib.groovy diff --git a/grails-testing-support/examples/demo33/grails-app/views/error.gsp b/demo33/grails-app/views/error.gsp similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/views/error.gsp rename to demo33/grails-app/views/error.gsp diff --git a/grails-testing-support/examples/demo33/grails-app/views/index.gsp b/demo33/grails-app/views/index.gsp similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/views/index.gsp rename to demo33/grails-app/views/index.gsp diff --git a/grails-testing-support/examples/demo33/grails-app/views/json/index.gson b/demo33/grails-app/views/json/index.gson similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/views/json/index.gson rename to demo33/grails-app/views/json/index.gson diff --git a/grails-testing-support/examples/demo33/grails-app/views/json/index.gsp b/demo33/grails-app/views/json/index.gsp similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/views/json/index.gsp rename to demo33/grails-app/views/json/index.gsp diff --git a/grails-testing-support/examples/demo33/grails-app/views/layouts/main.gsp b/demo33/grails-app/views/layouts/main.gsp similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/views/layouts/main.gsp rename to demo33/grails-app/views/layouts/main.gsp diff --git a/grails-testing-support/examples/demo33/grails-app/views/notFound.gsp b/demo33/grails-app/views/notFound.gsp similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/views/notFound.gsp rename to demo33/grails-app/views/notFound.gsp diff --git a/grails-testing-support/examples/demo33/grails-app/views/test/foo.gsp b/demo33/grails-app/views/test/foo.gsp similarity index 100% rename from grails-testing-support/examples/demo33/grails-app/views/test/foo.gsp rename to demo33/grails-app/views/test/foo.gsp diff --git a/grails-testing-support/examples/demo33/src/integration-test/groovy/demo/DependencyInjectionSpec.groovy b/demo33/src/integration-test/groovy/demo/DependencyInjectionSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/integration-test/groovy/demo/DependencyInjectionSpec.groovy rename to demo33/src/integration-test/groovy/demo/DependencyInjectionSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/integration-test/groovy/demo/JsonControllerSpec.groovy b/demo33/src/integration-test/groovy/demo/JsonControllerSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/integration-test/groovy/demo/JsonControllerSpec.groovy rename to demo33/src/integration-test/groovy/demo/JsonControllerSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/main/groovy/demo/MathHelper.groovy b/demo33/src/main/groovy/demo/MathHelper.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/main/groovy/demo/MathHelper.groovy rename to demo33/src/main/groovy/demo/MathHelper.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/ApplyTemplateWithoutReferringToTagLibPropertySpec.groovy b/demo33/src/test/groovy/demo/ApplyTemplateWithoutReferringToTagLibPropertySpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/ApplyTemplateWithoutReferringToTagLibPropertySpec.groovy rename to demo33/src/test/groovy/demo/ApplyTemplateWithoutReferringToTagLibPropertySpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/AutowiredTestSpec.groovy b/demo33/src/test/groovy/demo/AutowiredTestSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/AutowiredTestSpec.groovy rename to demo33/src/test/groovy/demo/AutowiredTestSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/CarServiceSpec.groovy b/demo33/src/test/groovy/demo/CarServiceSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/CarServiceSpec.groovy rename to demo33/src/test/groovy/demo/CarServiceSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/CarSpec.groovy b/demo33/src/test/groovy/demo/CarSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/CarSpec.groovy rename to demo33/src/test/groovy/demo/CarSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/ConfigServiceSpec.groovy b/demo33/src/test/groovy/demo/ConfigServiceSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/ConfigServiceSpec.groovy rename to demo33/src/test/groovy/demo/ConfigServiceSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/ControllerTagLibMethodDispatchSpec.groovy b/demo33/src/test/groovy/demo/ControllerTagLibMethodDispatchSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/ControllerTagLibMethodDispatchSpec.groovy rename to demo33/src/test/groovy/demo/ControllerTagLibMethodDispatchSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/DataTestTraitSpec.groovy b/demo33/src/test/groovy/demo/DataTestTraitSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/DataTestTraitSpec.groovy rename to demo33/src/test/groovy/demo/DataTestTraitSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/DefaultNullableConstraintConfigSpec.groovy b/demo33/src/test/groovy/demo/DefaultNullableConstraintConfigSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/DefaultNullableConstraintConfigSpec.groovy rename to demo33/src/test/groovy/demo/DefaultNullableConstraintConfigSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/DefineBeansSpec.groovy b/demo33/src/test/groovy/demo/DefineBeansSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/DefineBeansSpec.groovy rename to demo33/src/test/groovy/demo/DefineBeansSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/DemoControllerSpec.groovy b/demo33/src/test/groovy/demo/DemoControllerSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/DemoControllerSpec.groovy rename to demo33/src/test/groovy/demo/DemoControllerSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/DemoControllerTest.groovy b/demo33/src/test/groovy/demo/DemoControllerTest.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/DemoControllerTest.groovy rename to demo33/src/test/groovy/demo/DemoControllerTest.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/DemoUrlMappingsSpec.groovy b/demo33/src/test/groovy/demo/DemoUrlMappingsSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/DemoUrlMappingsSpec.groovy rename to demo33/src/test/groovy/demo/DemoUrlMappingsSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/FirstTagLibSpec.groovy b/demo33/src/test/groovy/demo/FirstTagLibSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/FirstTagLibSpec.groovy rename to demo33/src/test/groovy/demo/FirstTagLibSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/GetDomainClassesToMockMethodSpec.groovy b/demo33/src/test/groovy/demo/GetDomainClassesToMockMethodSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/GetDomainClassesToMockMethodSpec.groovy rename to demo33/src/test/groovy/demo/GetDomainClassesToMockMethodSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/HelperServiceSpec.groovy b/demo33/src/test/groovy/demo/HelperServiceSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/HelperServiceSpec.groovy rename to demo33/src/test/groovy/demo/HelperServiceSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/JsonControllerSpec.groovy b/demo33/src/test/groovy/demo/JsonControllerSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/JsonControllerSpec.groovy rename to demo33/src/test/groovy/demo/JsonControllerSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/LocaleTagLibSpec.groovy b/demo33/src/test/groovy/demo/LocaleTagLibSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/LocaleTagLibSpec.groovy rename to demo33/src/test/groovy/demo/LocaleTagLibSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/ManualControllerMockSpec.groovy b/demo33/src/test/groovy/demo/ManualControllerMockSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/ManualControllerMockSpec.groovy rename to demo33/src/test/groovy/demo/ManualControllerMockSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/NamePropertyControllerSpec.groovy b/demo33/src/test/groovy/demo/NamePropertyControllerSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/NamePropertyControllerSpec.groovy rename to demo33/src/test/groovy/demo/NamePropertyControllerSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/NamePropertyServiceSpec.groovy b/demo33/src/test/groovy/demo/NamePropertyServiceSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/NamePropertyServiceSpec.groovy rename to demo33/src/test/groovy/demo/NamePropertyServiceSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/PersonControllerHibernateSpec.groovy b/demo33/src/test/groovy/demo/PersonControllerHibernateSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/PersonControllerHibernateSpec.groovy rename to demo33/src/test/groovy/demo/PersonControllerHibernateSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/PersonControllerSpec.groovy b/demo33/src/test/groovy/demo/PersonControllerSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/PersonControllerSpec.groovy rename to demo33/src/test/groovy/demo/PersonControllerSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/PersonServiceSpec.groovy b/demo33/src/test/groovy/demo/PersonServiceSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/PersonServiceSpec.groovy rename to demo33/src/test/groovy/demo/PersonServiceSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/PersonSpec.groovy b/demo33/src/test/groovy/demo/PersonSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/PersonSpec.groovy rename to demo33/src/test/groovy/demo/PersonSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/ReportingServiceSpec.groovy b/demo33/src/test/groovy/demo/ReportingServiceSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/ReportingServiceSpec.groovy rename to demo33/src/test/groovy/demo/ReportingServiceSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/SampleTagLibSpec.groovy b/demo33/src/test/groovy/demo/SampleTagLibSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/SampleTagLibSpec.groovy rename to demo33/src/test/groovy/demo/SampleTagLibSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/SimpleJunitTagSpec.groovy b/demo33/src/test/groovy/demo/SimpleJunitTagSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/SimpleJunitTagSpec.groovy rename to demo33/src/test/groovy/demo/SimpleJunitTagSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/SubControllerSpec.groovy b/demo33/src/test/groovy/demo/SubControllerSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/SubControllerSpec.groovy rename to demo33/src/test/groovy/demo/SubControllerSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/TestControllerSpec.groovy b/demo33/src/test/groovy/demo/TestControllerSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/TestControllerSpec.groovy rename to demo33/src/test/groovy/demo/TestControllerSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/TestInterceptorSpec.groovy b/demo33/src/test/groovy/demo/TestInterceptorSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/TestInterceptorSpec.groovy rename to demo33/src/test/groovy/demo/TestInterceptorSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/TestServiceSpec.groovy b/demo33/src/test/groovy/demo/TestServiceSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/TestServiceSpec.groovy rename to demo33/src/test/groovy/demo/TestServiceSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/UniqueConstraintOnHasOneSpec.groovy b/demo33/src/test/groovy/demo/UniqueConstraintOnHasOneSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/UniqueConstraintOnHasOneSpec.groovy rename to demo33/src/test/groovy/demo/UniqueConstraintOnHasOneSpec.groovy diff --git a/grails-testing-support/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy b/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy similarity index 100% rename from grails-testing-support/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy rename to demo33/src/test/groovy/demo/UrlMappingsSpec.groovy diff --git a/grails-testing-support/.github/release-drafter.yml b/grails-testing-support/.github/release-drafter.yml deleted file mode 100644 index 1c607b71..00000000 --- a/grails-testing-support/.github/release-drafter.yml +++ /dev/null @@ -1,134 +0,0 @@ -name-template: $RESOLVED_VERSION -tag-template: v$RESOLVED_VERSION -pull-request: - title-templates: - fix: '🐛 $TITLE (#$NUMBER)' - feat: '🚀 $TITLE (#$NUMBER)' - default: '$TITLE (#$NUMBER)' -autolabeler: - - label: 'bug' - branch: - - '/fix\/.+/' - title: - - '/fix/i' - - label: 'improvement' - branch: - - '/improv\/.+/' - title: - - '/improv/i' - - label: 'feature' - branch: - - '/feature\/.+/' - title: - - '/feat/i' - - label: 'documentation' - branch: - - '/docs\/.+/' - title: - - '/docs/i' - - label: 'maintenance' - branch: - - '/(chore|refactor|style|test|ci|perf|build)\/.+/' - title: - - '/(chore|refactor|style|test|ci|perf|build)/i' - - label: 'chore' - branch: - - '/chore\/.+/' - title: - - '/chore/i' - - label: 'refactor' - branch: - - '/refactor\/.+/' - title: - - '/refactor/i' - - label: 'style' - branch: - - '/style\/.+/' - title: - - '/style/i' - - label: 'test' - branch: - - '/test\/.+/' - title: - - '/test/i' - - label: 'ci' - branch: - - '/ci\/.+/' - title: - - '/ci/i' - - label: 'perf' - branch: - - '/perf\/.+/' - title: - - '/perf/i' - - label: 'build' - branch: - - '/build\/.+/' - title: - - '/build/i' - - label: 'deps' - branch: - - '/deps\/.+/' - title: - - '/deps/i' - - label: 'revert' - branch: - - '/revert\/.+/' - title: - - '/revert/i' -categories: - - title: '🚀 Features' - labels: - - 'feat' - - "type: enhancement" - - "type: new feature" - - "type: major" - - "type: minor" - - title: 'ðŸ’Ą Improvements' - labels: - - 'improvement' - - "type: improvement" - - - title: '🐛 Bug Fixes' - labels: - - 'fix' - - 'bug' - - "type: bug" - - title: '📚 Documentation' - labels: - - 'docs' - - title: '🔧 Maintenance' - labels: - - 'maintenance' - - 'chore' - - 'refactor' - - 'style' - - 'test' - - 'ci' - - 'perf' - - 'build' - - "type: ci" - - "type: build" - - title: '⏊ Reverts' - labels: - - 'revert' -change-template: '- $TITLE @$AUTHOR (#$NUMBER)' -version-resolver: - major: - labels: - - 'type: major' - minor: - labels: - - 'type: minor' - patch: - labels: - - 'type: patch' - default: patch -template: | - ## What's Changed - - $CHANGES - - ## Contributors - - $CONTRIBUTORS diff --git a/grails-testing-support/.github/renovate.json b/grails-testing-support/.github/renovate.json deleted file mode 100644 index 2f31d795..00000000 --- a/grails-testing-support/.github/renovate.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "extends": [ - "config:base" - ], - "labels": ["type: dependency upgrade"], - "packageRules": [ - { - "matchPackagePatterns": ["*"], - "allowedVersions": "!/SNAPSHOT$/" - }, - { - "matchPackagePatterns": [ - "^org\\.apache\\.groovy" - ], - "groupName": "groovy monorepo" - }, - { - "matchPackagePatterns": [ - "^org\\.spockframework" - ], - "groupName": "spock framework monorepo" - }, - { - "matchPackageNames": [ - "org.grails:grails-bom", - "org.grails:grails-bootstrap", - "org.grails:grails-codecs", - "org.grails:grails-console", - "org.grails:grails-core", - "org.grails:grails-databinding", - "org.grails:grails-dependencies", - "org.grails:grails-docs", - "org.grails:grails-encoder", - "org.grails:grails-gradle-model", - "org.grails:grails-logging", - "org.grails:grails-plugin-codecs", - "org.grails:grails-plugin-controllers", - "org.grails:grails-plugin-databinding", - "org.grails:grails-plugin-datasource", - "org.grails:grails-plugin-domain-class", - "org.grails:grails-plugin-i18n", - "org.grails:grails-plugin-interceptors", - "org.grails:grails-plugin-mimetypes", - "org.grails:grails-plugin-rest", - "org.grails:grails-plugin-services", - "org.grails:grails-plugin-url-mappings", - "org.grails:grails-plugin-url-validation", - "org.grails:grails-shell", - "org.grails:grails-spring", - "org.grails:grails-test", - "org.grails:grails-validation", - "org.grails:grails-web", - "org.grails:grails-web-boot", - "org.grails:grails-web-common", - "org.grails:grails-web-databinding", - "org.grails:grails-web-fileupload", - "org.grails:grails-web-mvc", - "org.grails:grails-web-url-mappings" - ], - "groupName": "grails monorepo" - } - ] -} diff --git a/grails-testing-support/.github/workflows/docs.yml b/grails-testing-support/.github/workflows/docs.yml deleted file mode 100644 index fa1d73b8..00000000 --- a/grails-testing-support/.github/workflows/docs.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Publish Docs -on: - workflow_dispatch: - inputs: - version: - description: 'Version to publish' - required: true -jobs: - docs: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: 17 - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_TOKEN }} - ref: v${{ github.event.inputs.version }} - - name: Publish Documentation - id: docs - uses: gradle/gradle-build-action@v3 - with: - arguments: docs - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to Github Pages - if: success() - uses: grails/github-pages-deploy-action@v2 - env: - BETA: ${{ contains(github.event.inputs.version, 'M') }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} - BRANCH: gh-pages - FOLDER: build/docs - VERSION: ${{ github.event.inputs.version }} - COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }} - COMMIT_NAME: ${{ env.GIT_USER_NAME }} \ No newline at end of file diff --git a/grails-testing-support/.github/workflows/gradle.yml b/grails-testing-support/.github/workflows/gradle.yml deleted file mode 100644 index 6a0853c9..00000000 --- a/grails-testing-support/.github/workflows/gradle.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Java CI -on: - push: - branches: - - '[2-9]+.[1-9]+.x' - - '[3-9]+.[0-9]+.x' - pull_request: - branches: - - '[2-9]+.[1-9]+.x' - - '[3-9]+.[0-9]+.x' -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - java: ['17'] - env: - WORKSPACE: ${{ github.workspace }} - GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8 - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: ${{ matrix.java }} - - name: Run Tests - if: github.event_name == 'pull_request' - id: tests - uses: gradle/gradle-build-action@v3 - with: - arguments: check - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - - name: Run Build - if: github.event_name == 'push' - id: build - uses: gradle/gradle-build-action@v3 - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - with: - arguments: build --refresh-dependencies - - name: Publish Test Report - if: steps.build.outcome == 'failure' || steps.tests.outcome == 'failure' - uses: scacap/action-surefire-report@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - report_paths: '**/build/test-results/test/TEST-*.xml' - - name: Publish to repo.grails.org - id: publish - if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '17' - uses: gradle/gradle-build-action@v3 - with: - arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish - env: - ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} - ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - - name: Generate Docs - id: docs - if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '17' - uses: gradle/gradle-build-action@v3 - with: - arguments: docs - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to Github Pages - if: steps.docs.outcome == 'success' && github.event_name == 'push' && matrix.java == '17' - uses: grails/github-pages-deploy-action@main - env: - TARGET_REPOSITORY: ${{ github.repository }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} - BRANCH: gh-pages - FOLDER: build/docs - COMMIT_EMAIL: behlp@objectcomputing.com - COMMIT_NAME: Puneet Behl diff --git a/grails-testing-support/.github/workflows/groovy-joint-workflow.yml b/grails-testing-support/.github/workflows/groovy-joint-workflow.yml deleted file mode 100644 index 9f1f56b6..00000000 --- a/grails-testing-support/.github/workflows/groovy-joint-workflow.yml +++ /dev/null @@ -1,146 +0,0 @@ -name: "Groovy Joint Validation Build" -on: - push: - branches: - - '[3-9]+.[0-9]+.x' - pull_request: - branches: - - '[3-9]+.[0-9]+.x' - workflow_dispatch: -permissions: - contents: read -jobs: - build_groovy: - runs-on: ubuntu-latest - outputs: - groovyVersion: ${{ steps.groovy-version.outputs.value }} - steps: - - name: "☕ïļ Setup JDK" - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: 17 - - name: "🗄ïļ Cache local Maven repository" - uses: actions/cache@v4 - with: - path: ~/.m2/repository - key: cache-local-maven-${{ github.sha }} - - name: "ðŸ“Ĩ Checkout Grails Testing Support to fetch Gradle Plugin versions it uses" - uses: actions/checkout@v4 - with: - sparse-checkout-cone-mode: false - sparse-checkout: settings.gradle - - name: "📝 Store the Gradle Plugin versions used in Grails Testing Support" - id: gradle-plugin-versions - run: | - DEVELOCITY_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.develocity\"\|'"'com.gradle.develocity'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:]) - COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.common-custom-user-data-gradle-plugin\"\|'"'com.gradle.common-custom-user-data-gradle-plugin'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:]) - echo "Project uses Develocity Plugin version: $DEVELOCITY_PLUGIN_VERSION" - echo "Project uses Common Custom User Data Plugin version: $COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" - echo "develocity_plugin_version=$DEVELOCITY_PLUGIN_VERSION" >> $GITHUB_OUTPUT - echo "common_custom_user_data_plugin_version=$COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT - rm settings.gradle - - name: "ðŸ“Ĩ Checkout Groovy 4_0_X (Grails 7 and later)" - run: git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch - - name: "🐘 Setup Gradle" - uses: gradle/actions/setup-gradle@v4 - with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - name: "📝 Store Groovy version to use when building Grails Testing Support" - id: groovy-version - run: | - cd groovy - GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]') - echo "Groovy version $GROOVY_VERSION stored" - echo "value=$GROOVY_VERSION" >> $GITHUB_OUTPUT - - name: "🐘 Configure Gradle Plugins (Step 1/3)" - id: develocity-conf-1 - run: | - echo "VALUE<> $GITHUB_OUTPUT - echo "plugins { " >> $GITHUB_OUTPUT - echo " id 'com.gradle.develocity' version '${{ steps.gradle-plugin-versions.outputs.develocity_plugin_version }}'" >> $GITHUB_OUTPUT - echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle-plugin-versions.outputs.common_custom_user_data_plugin_version }}'" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - name: "🐘 Configure Gradle Plugins (Step 2/3)" - id: develocity-conf-2 - run: | - echo "VALUE<> $GITHUB_OUTPUT - echo "def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null" >> $GITHUB_OUTPUT - echo "def isBuildCacheAuthenticated =" >> $GITHUB_OUTPUT - echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null &&" >> $GITHUB_OUTPUT - echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null" >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "develocity {" >> $GITHUB_OUTPUT - echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT - echo " buildScan {" >> $GITHUB_OUTPUT - echo " publishing.onlyIf { isAuthenticated }" >> $GITHUB_OUTPUT - echo " uploadInBackground = false" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "buildCache {" >> $GITHUB_OUTPUT - echo " local { enabled = false }" >> $GITHUB_OUTPUT - echo " remote(develocity.buildCache) {" >> $GITHUB_OUTPUT - echo " push = isBuildCacheAuthenticated" >> $GITHUB_OUTPUT - echo " enabled = true" >> $GITHUB_OUTPUT - echo " usernameAndPassword(" >> $GITHUB_OUTPUT - echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: ''," >> $GITHUB_OUTPUT - echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: ''" >> $GITHUB_OUTPUT - echo " )" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - name: "🐘 Configure Gradle Plugins (step 3/3)" - run: | - cd groovy - # Delete existing plugins from settings.gradle file - sed -i '32,37d' settings.gradle - # Add Develocity setup related configuration after line no 31 in settings.gradle - echo "${{ steps.develocity-conf-1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle - # Delete existing buildCache configuration from gradle/build-scans.gradle file - sed -i '23,46d' gradle/build-scans.gradle - # Add Develocity setup related configuration after line no 22 in gradle/build-scans.gradle - echo "${{ steps.develocity-conf-2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle - - name: "ðŸ”Ļ Publish Groovy to local maven repository (no docs)" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - run: | - cd groovy - ./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK - - build_grails_testing_support: - needs: [build_groovy] - runs-on: ubuntu-latest - steps: - - name: "ðŸ“Ĩ Checkout project" - uses: actions/checkout@v4 - - name: "☕ïļ Setup JDK" - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: 17 - - name: "🐘 Setup Gradle" - uses: gradle/actions/setup-gradle@v4 - with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - name: "🗄ïļ Restore local Maven repository from cache" - uses: actions/cache@v4 - with: - path: ~/.m2/repository - key: cache-local-maven-${{ github.sha }} - - name: "ðŸŠķ Add mavenLocal repository to build" - run: sed -i 's|// mavenLocal() // Keep|mavenLocal() // Keep|' build.gradle - - name: "ðŸ”Ļ Build and test Grails Testing Support using the locally built Groovy snapshot" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - run: > - ./gradlew build - -PgroovyVersion=${{needs.build_groovy.outputs.groovyVersion}} - -x groovydoc diff --git a/grails-testing-support/.github/workflows/release-notes.yml b/grails-testing-support/.github/workflows/release-notes.yml deleted file mode 100644 index 28022186..00000000 --- a/grails-testing-support/.github/workflows/release-notes.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Changelog -on: - issues: - types: [closed,reopened] - push: - branches: - - master - - '[2-9]+.[1-9]+.x' - - '[3-9]+.[0-9]+.x' - pull_request: - types: [opened, reopened, synchronize] - pull_request_target: - types: [opened, reopened, synchronize] - workflow_dispatch: -jobs: - release_notes: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Check if it has release drafter config file - id: check_release_drafter - run: | - has_release_drafter=$([ -f .github/release-drafter.yml ] && echo "true" || echo "false") - echo "has_release_drafter=${has_release_drafter}" >> $GITHUB_OUTPUT - - name: Extract branch name - id: extract_branch - run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT - # If it has release drafter: - - uses: release-drafter/release-drafter@v6 - if: steps.check_release_drafter.outputs.has_release_drafter == 'true' - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - # Otherwise: - - name: Export Gradle Properties - if: steps.check_release_drafter.outputs.has_release_drafter == 'false' - uses: grails/github-actions/export-gradle-properties@main - - uses: grails/github-actions/release-notes@main - if: steps.check_release_drafter.outputs.has_release_drafter == 'false' - id: release_notes - with: - token: ${{ secrets.GH_TOKEN }} - - uses: ncipollo/release-action@v1 - if: steps.check_release_drafter.outputs.has_release_drafter == 'false' && steps.release_notes.outputs.generated_changelog == 'true' - with: - allowUpdates: true - commit: ${{ steps.release_notes.outputs.current_branch }} - draft: true - name: ${{ env.title }} ${{ steps.release_notes.outputs.next_version }} - tag: v${{ steps.release_notes.outputs.next_version }} - bodyFile: CHANGELOG.md - token: ${{ secrets.GH_TOKEN }} diff --git a/grails-testing-support/.github/workflows/release.yml b/grails-testing-support/.github/workflows/release.yml deleted file mode 100644 index fe97a817..00000000 --- a/grails-testing-support/.github/workflows/release.yml +++ /dev/null @@ -1,145 +0,0 @@ -name: Release -on: - release: - types: [published] -env: - GIT_USER_NAME: 'grails-build' - GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' -jobs: - publish: - outputs: - release_version: ${{ steps.release_version.outputs.value }} - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_TOKEN }} - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - name: Set the current release version - id: release_version - run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT - - name: Run pre-release - uses: grails/github-actions/pre-release@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run Assemble - if: success() - id: assemble - uses: gradle/gradle-build-action@v3 - with: - arguments: assemble - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - - name: Upload Distribution - if: success() - uses: actions/upload-artifact@v4 - with: - name: testing-support-${{ steps.release_version.outputs.value }}.zip - path: ./**/build/libs/* - - name: Generate secring file - env: - SECRING_FILE: ${{ secrets.SECRING_FILE }} - run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg - - name: Publish to Sonatype OSSRH - id: publish - uses: gradle/gradle-build-action@v3 - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} - SECRING_FILE: ${{ secrets.SECRING_FILE }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - with: - arguments: | - -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg - publishToSonatype - closeSonaTypeStagingRepository - release: - needs: publish - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_TOKEN }} - ref: v${{ needs.publish.outputs.release_version }} - - name: Nexus Staging Close And Release - uses: gradle/gradle-build-action@v3 - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - with: - arguments: | - findSonatypeStagingRepository - releaseSonatypeStagingRepository - - name: Run post-release - if: success() - uses: grails/github-actions/post-release@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - env: - SNAPSHOT_SUFFIX: -SNAPSHOT - docs: - needs: publish - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_TOKEN }} - ref: v${{ needs.publish.outputs.release_version }} - - name: Publish Documentation - id: docs - if: steps.publish.outcome == 'success' - uses: gradle/gradle-build-action@v3 - env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - with: - arguments: docs - - name: Publish to Github Pages - if: steps.docs.outcome == 'success' - uses: grails/github-pages-deploy-action@v2 - env: - SKIP_SNAPSHOT: ${{ contains(needs.publish.outputs.release_version, 'M') }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} - BRANCH: gh-pages - FOLDER: build/docs - VERSION: ${{ needs.publish.outputs.release_version }} - COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }} - COMMIT_NAME: ${{ env.GIT_USER_NAME }} diff --git a/grails-testing-support/.gitignore b/grails-testing-support/.gitignore deleted file mode 100755 index 61410188..00000000 --- a/grails-testing-support/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -build -classes -.idea -.gradle -*.iml -*.db -**/out diff --git a/grails-testing-support/LICENSE b/grails-testing-support/LICENSE deleted file mode 100644 index 3f80fdb2..00000000 --- a/grails-testing-support/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2015 original authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/grails-testing-support/README.adoc b/grails-testing-support/README.adoc deleted file mode 100644 index 0afdb7d7..00000000 --- a/grails-testing-support/README.adoc +++ /dev/null @@ -1,25 +0,0 @@ -# Grails Testing Support - -image:https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A["Revved up by Develocity", link=https://ge.grails.org/scans] -image:https://github.com/grails/grails-testing-support/actions/workflows/gradle.yml/badge.svg?event=push["Java CI", link=https://github.com/grails/grails-testing-support/actions/workflows/gradle.yml] -image:https://github.com/grails/grails-testing-support/actions/workflows/groovy-joint-workflow.yml/badge.svg?event=push["Groovy Joint Validation Build", link=https://github.com/grails/grails-testing-support/actions/workflows/groovy-joint-workflow.yml] - -Documentation is available at link:https://testing.grails.org[https://testing.grails.org/] - -Documentation SNAPSHOT is available at link:https://testing.grails.org/snapshot/guide/index.html[https://testing.grails.org/snapshot/guide/index.html] - -Grails 7.0 branch is https://github.com/grails/grails-testing-support/tree/4.0.x[4.0.x] - -Grails 6.2 branch is https://github.com/grails/grails-testing-support/tree/3.2.x[3.2.x] - -Grails 6.1 branch is https://github.com/grails/grails-testing-support/tree/3.1.x[3.1.x] - -Grails 6 branch is https://github.com/grails/grails-testing-support/tree/3.0.x[3.0.x] - -Grails 5 branch is https://github.com/grails/grails-testing-support/tree/2.4.x[2.4.x] which includes support for Groovy 3. - -Grails 4.0.x branch is https://github.com/grails/grails-testing-support/tree/2.1.x[2.1.x]. - -Grails 3.x branch is https://github.com/grails/grails-testing-support/tree/1.1.x[1.1.x]. - -Please see https://github.com/grails/grails-testing-support/releases[release notes] for more information. diff --git a/grails-testing-support/build.gradle b/grails-testing-support/build.gradle deleted file mode 100644 index 000b463f..00000000 --- a/grails-testing-support/build.gradle +++ /dev/null @@ -1,452 +0,0 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "org.grails:grails-docs:${project.ext.properties.grailsDocsVersion ?: grailsVersion}" - classpath "org.grails.plugins:views-gradle:$jsonViewsVersion" - classpath "io.github.gradle-nexus:publish-plugin:$gradleNexusPublishPluginVersion" - classpath "org.asciidoctor:asciidoctor-gradle-jvm:$asciidoctorJvmVersion" - } -} - -group = "org.grails" -version project.projectVersion - -apply plugin: 'java-library' -apply plugin: 'groovy' - -ext { - - isSnapshot = project.projectVersion.endsWith('-SNAPSHOT') - isReleaseVersion = !isSnapshot -} - -ext."signing.keyId" = project.findProperty("signing.keyId") ?: System.getenv('SIGNING_KEY') -ext."signing.secretKeyRingFile" = project.findProperty("signing.secretKeyRingFile") ?: "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg" -ext."signing.password" = project.findProperty("signing.password") ?: System.getenv('SIGNING_PASSPHRASE') - -allprojects { - configurations.configureEach { - - // FORCE UPGRADE OF GROOVY IN DEPENDENCIES TO GROOVY 4 - resolutionStrategy.eachDependency { DependencyResolveDetails details -> - if (details.requested.group == 'org.codehaus.groovy') { - details.useTarget(group: 'org.apache.groovy', name: details.requested.name, version: groovyVersion) - } - } - } - - repositories { - maven { url "https://repo.grails.org/grails/core" } - mavenCentral() - // mavenLocal() // Keep, this will be uncommented and used by CI (groovy-joint-workflow) - if (groovyVersion && groovyVersion.endsWith('-SNAPSHOT')) { - maven { - name = 'ASF Snapshot repo' - url = 'https://repository.apache.org/content/repositories/snapshots' - } - } - - if (System.getenv("GITHUB_MAVEN_PASSWORD") && !grailsVersion.endsWith('-SNAPSHOT')) { - System.out.println("Adding Grails Core Repo") - maven { - url = 'https://maven.pkg.github.com/grails/grails-core' - credentials { - username = 'DOES_NOT_MATTER' - password = System.getenv("GITHUB_MAVEN_PASSWORD") - } - } - } - } -} - -subprojects { project -> - - version rootProject.projectVersion - - ext['groovyVersion'] = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion - - ext { - userOrg = "grails" - isGrailsPlugin = name.startsWith('grails-plugin') - isBuildSnapshot = version.toString().endsWith("-SNAPSHOT") - } - - if (isGrailsPlugin) { - group "org.grails.plugins" - } else { - group "org.grails" - } - - apply plugin: "groovy" - if (project.name.startsWith("examples")) { - apply plugin: "org.grails.grails-web" - apply plugin: "org.grails.plugins.views-json" - } else { - apply plugin: "java-library" - if (isGrailsPlugin) { - apply plugin: "org.grails.grails-plugin" - } else { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - - configurations { - documentation - } - - dependencies { - api "org.apache.groovy:groovy:$groovyVersion" - api "org.slf4j:slf4j-api" - - testImplementation "org.spockframework:spock-core", { - exclude module: 'groovy-all' - } - testRuntimeOnly "net.bytebuddy:byte-buddy:$bytebuddyVersion" - testRuntimeOnly "org.objenesis:objenesis:$objenesisVersion" - - documentation "org.fusesource.jansi:jansi" - - } - - test { - testLogging { - events "passed", "skipped", "failed", "standardOut", "standardError" - } - } - - groovydoc.classpath += (configurations.documentation + configurations.compileClasspath) - } - } - - compileJava.options.release = 17 - - dependencies { - implementation platform("org.grails:grails-bom:$grailsVersion") - implementation "com.github.javaparser:javaparser-core" - compileOnly "jakarta.servlet:jakarta.servlet-api" - - testImplementation "jakarta.servlet:jakarta.servlet-api" - testImplementation "org.apache.groovy:groovy-test-junit5" - testImplementation "org.junit.jupiter:junit-jupiter-api" - testImplementation "org.junit.platform:junit-platform-runner" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine" - testRuntimeOnly "org.junit.platform:junit-platform-commons" - } - - tasks.withType(Test) { - useJUnitPlatform() - } -} - -subprojects { subproject -> - ext { - isExample = subproject.name.startsWith('example') - isGrailsPlugin = subproject.name.startsWith('grails-plugin') - pomInfo = { - delegate.name subproject.title - delegate.description subproject.projectDesc - delegate.url projectUrl - - delegate.licenses { - delegate.license { - delegate.name 'The Apache Software License, Version 2.0' - delegate.url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - delegate.distribution 'repo' - } - } - - delegate.scm { - delegate.url "scm:git@github.com:${githubSlug}.git" - delegate.connection "scm:git@github.com:${githubSlug}.git" - delegate.developerConnection "scm:git@github.com:${githubSlug}.git" - } - - if (developers) { - delegate.developers { - for (dev in developers.split(',')) { - delegate.developer { - delegate.id dev.toLowerCase().replace(' ', '') - delegate.name dev - } - } - } - } - } - } - - if (!isExample) { - - apply plugin: 'maven-publish' - apply plugin: 'signing' - - Task sourcesJar = subproject.tasks.findByName("sourcesJar") - if (!sourcesJar) { - sourcesJar = tasks.create("sourcesJar", Jar) { - archiveClassifier = 'sources' - group = BasePlugin.BUILD_GROUP - description = 'Assembles a jar archive containing the main sources of this project.' - from subproject.sourceSets.main.allSource - } - } - - Task javadocJar = subproject.tasks.findByName("javadocJar") - if (!javadocJar) { - javadocJar = tasks.create("javadocJar", Jar) { - archiveClassifier = 'javadoc' - group = BasePlugin.BUILD_GROUP - description = 'Assembles a jar archive containing the generated Javadoc API documentation of this project.' - from subproject.plugins.hasPlugin(GroovyPlugin) ? subproject.tasks.getByName(GroovyPlugin.GROOVYDOC_TASK_NAME) : subproject.tasks.getByName(JavaPlugin.JAVADOC_TASK_NAME) - } - } - tasks.findByName("assemble").finalizedBy(sourcesJar, javadocJar) - - publishing { - if (isSnapshot) { - repositories { - maven { - credentials { - def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.findProperty("artifactoryPublishUsername") ?: '' - def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.findProperty("artifactoryPublishPassword") ?: '' - username = u - password = p - } - if (isGrailsPlugin) { - url "https://repo.grails.org/grails/plugins3-snapshots-local" - } else { - url "https://repo.grails.org/grails/libs-snapshots-local" - } - } - } - } - - publications { - maven(MavenPublication) { - if (isGrailsPlugin) { - artifactId(subproject.name - 'grails-plugin-') - } else if (subproject.name.contains('/')) { - artifactId(subproject.name.substring(subproject.name.indexOf('/') + 1)) - } - - from components.java - - artifact sourcesJar - artifact javadocJar - - if (isGrailsPlugin) { - artifact source: "${subproject.buildDir}/classes/groovy/main/META-INF/grails-plugin.xml", - classifier: "plugin", - extension: 'xml' - } - pom.withXml { - def xml = asNode() - - xml.children().last() + pomInfo - // dependency management shouldn't be included - def n = xml.get("dependencyManagement") - if (n) xml.remove(n) - } - - } - } - } - - subproject.afterEvaluate { - signing { - required { isReleaseVersion } - sign publishing.publications.maven - } - } - - tasks.withType(Sign) { - onlyIf { isReleaseVersion } - } - - //do not generate extra load on Nexus with new staging repository if signing fails - tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach { - shouldRunAfter(tasks.withType(Sign)) - } - } - apply plugin: "org.asciidoctor.jvm.convert" - - configurations { - documentation.extendsFrom compileClasspath - } - - dependencies { - if (configurations.find { it.name == 'documentation' }) { - documentation "org.fusesource.jansi:jansi" - documentation "jline:jline" - documentation "com.github.javaparser:javaparser-core" - documentation "org.apache.groovy:groovy:${groovyVersion}" - documentation "org.apache.groovy:groovy-templates:${groovyVersion}" - documentation "org.apache.groovy:groovy-ant:$groovyVersion" - documentation "org.apache.groovy:groovy-dateutil:$groovyVersion" - documentation "org.apache.groovy:groovy-cli-picocli:$groovyVersion" - } - } - - groovydoc.classpath += configurations.documentation -} - -if (isReleaseVersion) { - apply plugin: 'maven-publish' - apply plugin: "io.github.gradle-nexus.publish-plugin" - - nexusPublishing { - repositories { - sonatype { - def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.findProperty("sonatypeOssUsername") ?: '' - def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.findProperty("sonatypeOssPassword") ?: '' - def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.findProperty("sonatypeOssStagingProfileId") ?: '' - nexusUrl = uri("https://s01.oss.sonatype.org/service/local/") - username = ossUser - password = ossPass - stagingProfileId = ossStagingProfileId - } - } - transitionCheckOptions { - maxRetries.set(40) - delayBetween.set(java.time.Duration.ofMillis(2000)) - } - } -} - -def DOCUMENTATION_GROUP = 'Documentation' - -def commonGithubOrg = 'grails' -def commonGithubSlug = 'grails-common-build' -def commonBranch = 'master' -def docResourcesDir = "${buildDir}/resources/${commonGithubSlug}-${commonBranch}/src/main/resources" - -task prepareDocResources { - group = DOCUMENTATION_GROUP - description = 'Downloads common documentation resoruces and unzips them to build folder' - doLast { - ant.mkdir(dir: buildDir) - ant.get(src: "https://github.com/${commonGithubOrg}/${commonGithubSlug}/archive/${commonBranch}.zip", dest: "${buildDir}/resources.zip") - ant.unzip(src: "${buildDir}/resources.zip", dest: "${buildDir}/resources") - } -} - -task copyLocalDocResources(type: Copy, dependsOn: prepareDocResources) { - group = DOCUMENTATION_GROUP - description = 'Copy local resources to build folder' - mustRunAfter prepareDocResources - from('src/main/docs/resources') - into docResourcesDir -} - -configurations { - documentation -} - -dependencies { - if (configurations.find { it.name == 'documentation' }) { - documentation platform("org.grails:grails-bom:$grailsVersion") - documentation "info.picocli:picocli:$picocliVersion" - documentation "org.fusesource.jansi:jansi" - documentation "jline:jline" - documentation "com.github.javaparser:javaparser-core" - documentation "org.apache.groovy:groovy:$groovyVersion" - documentation "org.apache.groovy:groovy-templates:$groovyVersion" - documentation "org.apache.groovy:groovy-ant:$groovyVersion" - documentation "org.apache.groovy:groovy-cli-picocli:$groovyVersion" - } -} - -def cleanTask = project.tasks.findByName("clean") -if (cleanTask == null) { - task clean(type: Delete) { - delete(buildDir) - } -} else { - cleanTask.doLast { - ant.delete(dir: "build/docs") - } -} - -tasks.withType(Groovydoc) { - group = DOCUMENTATION_GROUP - docTitle = "${project.title} - ${project.version}" - destinationDir = project.file("build/docs/api") - def files = [] - project.rootProject.subprojects - .findAll { it.name != 'docs' && !it.name.startsWith('examples') } - .each { subproject -> - if (subproject.file('src/main/groovy').exists()) { - files += subproject.files("src/main/groovy") - } - } - if (project.file('src/main/groovy').exists()) { - files += project.files("src/main/groovy") - } - source = files - classpath += configurations.documentation -} - -tasks.withType(org.gradle.api.tasks.javadoc.Groovydoc) { - configure { - access = GroovydocAccess.PRIVATE - processScripts = false - includeMainForScripts = false - includeAuthor = true - groovyClasspath = configurations.documentation - } -} - -task publishGuide(type: grails.doc.gradle.PublishGuide) { - group = DOCUMENTATION_GROUP - description = 'Generate Guide' - dependsOn copyLocalDocResources, compileGroovy, compileJava, groovydoc, processResources - - targetDir = project.file("${buildDir}/docs") - sourceRepo = "https://github.com/${githubSlug}/edit/${githubBranch}/src/main/docs" - sourceDir = new File(projectDir, "src/main/docs") - propertiesFiles = [new File(rootProject.projectDir, "gradle.properties")] - asciidoc = true - resourcesDir = project.file(docResourcesDir) - properties = ['safe' : 'UNSAFE', - 'version' : project.version, - 'subtitle' : project.projectDesc, - 'api' : '../api', - 'sourceDir': rootProject.projectDir.absolutePath, - 'sourcedir': rootProject.projectDir.absolutePath, - 'javaee' : 'https://docs.oracle.com/javaee/7/api/', - 'jakartaee': 'https://jakarta.ee/specifications/platform/10/apidocs/', - 'javase' : 'https://docs.oracle.com/en/java/javase/17/docs/api/index.html', - 'groovyapi': 'http://docs.groovy-lang.org/latest/html/gapi/', - 'grailsapi': 'http://docs.grails.org/latest/api/', - 'gormapi' : 'http://gorm.grails.org/latest/api/', - 'springapi': 'https://docs.spring.io/spring/docs/current/javadoc-api/'] - doLast { - ant.move(file: "${project.buildDir}/docs/guide/single.html", - tofile: "${project.buildDir}/docs/guide/index.html", overwrite: true) - new File(project.buildDir, "docs/index.html").text = ''' - - - - - - - - -''' - } -} - -task docs(dependsOn: [groovydoc, publishGuide]) { - group = DOCUMENTATION_GROUP -} - -def assembleTask = project.tasks.findByName("assemble") -if (assembleTask == null) { - task assemble(dependsOn: docs, type: Zip) { - archiveFileName = "${project.name}-${project.version}.zip" - destinationDirectory = new File(project.buildDir, "distributions") - from project.files("${buildDir}/docs") - } -} diff --git a/grails-testing-support/gradle.properties b/grails-testing-support/gradle.properties deleted file mode 100644 index faa2d86c..00000000 --- a/grails-testing-support/gradle.properties +++ /dev/null @@ -1,27 +0,0 @@ -projectVersion=4.0.0-SNAPSHOT -title=Grails Testing Support -authors=Jeff Brown,James Kleeh -projectDesc=Support for writing concise expressive tests for Grails artifacts -projectUrl=https://github.com/grails/grails-testing-support -githubSlug=grails/grails-testing-support -githubBranch=4.0.x -developers=Jeff Brown,James Kleeh - -#4.0.2-4.0.3 breaks org.ysb33r.gradle:grolifant for chromedriver due to switching to org.ysb33r.gradle:grolifant-rawhide:3.0.0 -asciidoctorJvmVersion=4.0.1 -bytebuddyVersion=1.15.3 -grailsGradlePluginVersion=7.0.0-SNAPSHOT -grailsVersion=7.0.0-SNAPSHOT -grailsDocsVersion=7.0.0-SNAPSHOT -groovyVersion=4.0.24 -gradleNexusPublishPluginVersion=2.0.0 -javassistVersion=3.30.2-GA -jsonViewsVersion=4.0.0-SNAPSHOT -objenesisVersion=3.4 -picocliVersion=4.7.6 -servletApiVersion=6.0.0 - -org.gradle.caching=true -org.gradle.parallel=true -org.gradle.daemon=true -org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1536M -XX:MaxMetaspaceSize=512M diff --git a/grails-testing-support/gradle/wrapper/gradle-wrapper.jar b/grails-testing-support/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index a4b76b95..00000000 Binary files a/grails-testing-support/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/grails-testing-support/gradle/wrapper/gradle-wrapper.properties b/grails-testing-support/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e2847c82..00000000 --- a/grails-testing-support/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/grails-testing-support/gradlew b/grails-testing-support/gradlew deleted file mode 100755 index f5feea6d..00000000 --- a/grails-testing-support/gradlew +++ /dev/null @@ -1,252 +0,0 @@ -#!/bin/sh - -# -# Copyright ÂĐ 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions ÂŦ$varÂŧ, ÂŦ${var}Âŧ, ÂŦ${var:-default}Âŧ, ÂŦ${var+SET}Âŧ, -# ÂŦ${var#prefix}Âŧ, ÂŦ${var%suffix}Âŧ, and ÂŦ$( cmd )Âŧ; -# * compound commands having a testable exit status, especially ÂŦcaseÂŧ; -# * various built-in commands including ÂŦcommandÂŧ, ÂŦsetÂŧ, and ÂŦulimitÂŧ. -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -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 - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/grails-testing-support/gradlew.bat b/grails-testing-support/gradlew.bat deleted file mode 100755 index 9b42019c..00000000 --- a/grails-testing-support/gradlew.bat +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/grails-testing-support/grails-gorm-testing-support/build.gradle b/grails-testing-support/grails-gorm-testing-support/build.gradle deleted file mode 100755 index 1204a736..00000000 --- a/grails-testing-support/grails-gorm-testing-support/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -dependencies { - api "org.grails:grails-plugin-domain-class" - api "org.grails:grails-datastore-gorm-test" - - api project(':grails-testing-support') -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/grails/testing/gorm/DataTest.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/grails/testing/gorm/DataTest.groovy deleted file mode 100644 index 992f34f7..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/grails/testing/gorm/DataTest.groovy +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.gorm - -import grails.core.GrailsClass -import grails.gorm.validation.PersistentEntityValidator -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import org.grails.core.artefact.DomainClassArtefactHandler -import org.grails.datastore.gorm.GormEnhancer -import org.grails.datastore.mapping.config.Settings -import org.grails.datastore.mapping.core.AbstractDatastore -import org.grails.datastore.mapping.core.Session -import org.grails.datastore.mapping.model.PersistentEntity -import org.grails.datastore.mapping.model.lifecycle.Initializable -import org.grails.datastore.mapping.services.Service -import org.grails.testing.GrailsUnitTest -import org.grails.testing.gorm.MockCascadingDomainClassValidator -import org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor -import org.grails.validation.ConstraintEvalUtils -import org.springframework.transaction.PlatformTransactionManager -import org.springframework.validation.Validator - -import java.beans.Introspector - -@CompileStatic -trait DataTest extends GrailsUnitTest { - - boolean domainsHaveBeenMocked = false - Session currentSession - - Class[] getDomainClassesToMock() { - [] as Class[] - } - - boolean getFailOnError() { - config.getProperty(Settings.SETTING_FAIL_ON_ERROR, Boolean, false) - } - - /** - * Mocks a domain class providing the equivalent GORM behavior but against an in-memory - * concurrent hash map instead of a database - * - * @param domainClassToMock The domain class to mock - * @param domains Optional. The list of domains to save - */ - void mockDomain(Class domainClassToMock, List domains = []) { - mockDomains(domainClassToMock) - PersistentEntity entity = datastore.mappingContext.getPersistentEntity(domainClassToMock.name) - if (domains) { - saveDomainList(entity, domains) - } - } - - /** - * Mocks domain classes providing the equivalent GORM behavior but against an in-memory - * concurrent hash map instead of a database - * - * @param domainClassesToMock The list of domain classes to mock - */ - void mockDomains(Class... domainClassesToMock) { - initialMockDomainSetup() - Collection entities = datastore.mappingContext.addPersistentEntities(domainClassesToMock) - for (PersistentEntity entity in entities) { - registerGrailsDomainClass(entity.javaClass) - - Validator validator = registerDomainClassValidator(entity) - datastore.mappingContext.addEntityValidator(entity, validator) - } - new GormEnhancer(datastore, transactionManager, getFailOnError()) - - initializeMappingContext() - } - - /** - * Called by the ServiceUnitTest class (via reflection) to create a data service - * - * @param serviceClass The data service abstract class or interface - */ - void mockDataService(Class serviceClass) { - Service service = (Service) datastore.getService(serviceClass) - String serviceName = Introspector.decapitalize(serviceClass.simpleName) - if (!applicationContext.containsBean(serviceName)) { - applicationContext.beanFactory.autowireBean(service) - service.setDatastore(datastore) - applicationContext.beanFactory.registerSingleton(serviceName, service) - } - } - - /** - * @deprecated as of v2.1.0 because of of consistency in the method name with - * other GORM projects. It is recommended to use {@link #getDatastore()} instead. - * - * @return The{@link AbstractDatastore} - */ - @Deprecated - AbstractDatastore getDataStore() { - getDatastore() - } - - AbstractDatastore getDatastore() { - applicationContext.getBean(AbstractDatastore) - } - - PlatformTransactionManager getTransactionManager() { - applicationContext.getBean('transactionManager', PlatformTransactionManager) - } - - private void registerGrailsDomainClass(Class domainClassToMock) { - grailsApplication.addArtefact(DomainClassArtefactHandler.TYPE, domainClassToMock) - } - - @CompileDynamic - private Validator registerDomainClassValidator(PersistentEntity domain) { - String validationBeanName = "${domain.javaClass.name}Validator" - defineBeans { - "${domain.javaClass.name}"(domain.javaClass) { bean -> - bean.singleton = false - bean.autowire = "byName" - } - - if (DataTestSetupSpecInterceptor.IS_OLD_SETUP) { - GrailsClass grailsDomain = grailsApplication.getArtefact(DomainClassArtefactHandler.TYPE, domain.javaClass.name) - - "$validationBeanName"(MockCascadingDomainClassValidator) { bean -> - getDelegate().messageSource = ref("messageSource") - bean.lazyInit = true - getDelegate().domainClass = grailsDomain - getDelegate().grailsApplication = grailsApplication - } - } else { - "$validationBeanName"(PersistentEntityValidator, domain, ref("messageSource"), ref(DataTestSetupSpecInterceptor.BEAN_NAME)) - } - - } - - applicationContext.getBean(validationBeanName, Validator) - } - - private void initialMockDomainSetup() { - ConstraintEvalUtils.clearDefaultConstraints() - ((DomainClassArtefactHandler) grailsApplication.getArtefactHandler(DomainClassArtefactHandler.TYPE)).setGrailsApplication(grailsApplication) - } - - private void initializeMappingContext() { - def context = datastore.mappingContext - if (context instanceof Initializable) { - context.initialize() - } - } - - @CompileStatic(TypeCheckingMode.SKIP) - private void saveDomainList(PersistentEntity entity, List domains) { - for (obj in domains) { - if (obj instanceof Map) { - entity.javaClass.newInstance(obj).save() - } else if (entity.isInstance(obj)) { - obj.save() - } - } - } -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/grails/testing/gorm/DomainUnitTest.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/grails/testing/gorm/DomainUnitTest.groovy deleted file mode 100644 index b65da49d..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/grails/testing/gorm/DomainUnitTest.groovy +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.gorm - -import groovy.transform.CompileStatic - -import java.lang.reflect.ParameterizedType - -@CompileStatic -trait DomainUnitTest implements DataTest { - - private T domainInstance - private static Class domainClass - - Class[] getDomainClassesToMock() { - [getDomainUnderTest()].toArray(Class) - } - - /** - * @return An instance of the domain class - */ - T getDomain() { - if (domainInstance == null) { - domainInstance = getDomainUnderTest().newInstance() - } - domainInstance - } - - private Class getDomainUnderTest() { - if (domainClass == null) { - ParameterizedType parameterizedType = (ParameterizedType)getClass().genericInterfaces.find { genericInterface -> - genericInterface instanceof ParameterizedType && - DomainUnitTest.isAssignableFrom((Class)((ParameterizedType)genericInterface).rawType) - } - - domainClass = (Class)parameterizedType?.actualTypeArguments[0] - } - domainClass - } - -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/MockCascadingDomainClassValidator.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/MockCascadingDomainClassValidator.groovy deleted file mode 100644 index 30ce3f04..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/MockCascadingDomainClassValidator.groovy +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.grails.testing.gorm - -import grails.gorm.validation.CascadingValidator -import grails.gorm.validation.PersistentEntityValidator -import groovy.transform.CompileStatic -import org.grails.datastore.gorm.validation.constraints.eval.ConstraintsEvaluator -import org.grails.datastore.mapping.model.PersistentEntity -import org.springframework.context.MessageSource - -@CompileStatic -class MockCascadingDomainClassValidator extends PersistentEntityValidator implements CascadingValidator { - MockCascadingDomainClassValidator(PersistentEntity entity, MessageSource messageSource, ConstraintsEvaluator constraintsEvaluator) { - super(entity, messageSource, constraintsEvaluator) - } -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestCleanupInterceptor.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestCleanupInterceptor.groovy deleted file mode 100644 index 4aa648e6..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestCleanupInterceptor.groovy +++ /dev/null @@ -1,27 +0,0 @@ -package org.grails.testing.gorm.spock - -import grails.testing.gorm.DataTest -import groovy.transform.CompileStatic -import org.grails.datastore.mapping.core.DatastoreUtils -import org.grails.datastore.mapping.simple.SimpleMapDatastore -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class DataTestCleanupInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - cleanupDataTest((DataTest)invocation.instance) - invocation.proceed() - } - - void cleanupDataTest(DataTest testInstance) { - if (testInstance.currentSession != null) { - testInstance.currentSession.disconnect() - DatastoreUtils.unbindSession(testInstance.currentSession) - } - SimpleMapDatastore simpleDatastore = testInstance.applicationContext.getBean(SimpleMapDatastore) - simpleDatastore.clearData() - } -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestCleanupSpecInterceptor.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestCleanupSpecInterceptor.groovy deleted file mode 100644 index bc7d84d5..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestCleanupSpecInterceptor.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.grails.testing.gorm.spock - -import groovy.transform.CompileStatic -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class DataTestCleanupSpecInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - invocation.proceed() - } -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestSetupInterceptor.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestSetupInterceptor.groovy deleted file mode 100644 index 269bbffb..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestSetupInterceptor.groovy +++ /dev/null @@ -1,21 +0,0 @@ -package org.grails.testing.gorm.spock - -import grails.testing.gorm.DataTest -import groovy.transform.CompileStatic -import org.grails.datastore.mapping.core.DatastoreUtils -import org.grails.datastore.mapping.simple.SimpleMapDatastore -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class DataTestSetupInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - DataTest test = (DataTest)invocation.instance - SimpleMapDatastore simpleDatastore = test.applicationContext.getBean(SimpleMapDatastore) - test.currentSession = simpleDatastore.connect() - DatastoreUtils.bindSession(test.currentSession) - invocation.proceed() - } -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestSetupSpecInterceptor.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestSetupSpecInterceptor.groovy deleted file mode 100644 index c2334532..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/DataTestSetupSpecInterceptor.groovy +++ /dev/null @@ -1,79 +0,0 @@ -package org.grails.testing.gorm.spock - -import grails.testing.gorm.DataTest -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import org.grails.datastore.gorm.validation.constraints.builtin.UniqueConstraint -import org.grails.datastore.gorm.validation.constraints.eval.DefaultConstraintEvaluator -import org.grails.datastore.gorm.validation.constraints.registry.ConstraintRegistry -import org.grails.datastore.gorm.validation.constraints.registry.DefaultConstraintRegistry -import org.grails.datastore.mapping.core.DatastoreUtils -import org.grails.datastore.mapping.model.MappingContext -import org.grails.datastore.mapping.reflect.ClassUtils -import org.grails.datastore.mapping.simple.SimpleMapDatastore -import org.grails.datastore.mapping.transactions.DatastoreTransactionManager -import org.grails.validation.ConstraintEvalUtils -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.core.convert.converter.Converter -import org.springframework.core.convert.support.ConfigurableConversionService - -@CompileStatic -class DataTestSetupSpecInterceptor implements IMethodInterceptor { - - public static Boolean IS_OLD_SETUP = false - public static final BEAN_NAME = "validateableConstraintsEvaluator" - private static Class constraintsEvaluator = DefaultConstraintEvaluator - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - configureDataTest((DataTest)invocation.instance) - invocation.proceed() - } - - @CompileDynamic - void setupDataTestBeans(DataTest testInstance) { - - testInstance.defineBeans { - ConfigurableConversionService conversionService = application.mainContext.getEnvironment().getConversionService() - conversionService.addConverter(new Converter() { - @Override - Class convert(String source) { - Class.forName(source) - } - }) - grailsDatastore SimpleMapDatastore, DatastoreUtils.createPropertyResolver(application.config), application.config?.dataSources?.keySet() ?: ([] as Set), testInstance.domainClassesToMock?: [] as Class[] - - constraintRegistry(DefaultConstraintRegistry, ref("messageSource")) - grailsDomainClassMappingContext(grailsDatastore: "getMappingContext") - - "${BEAN_NAME}"(constraintsEvaluator, constraintRegistry, grailsDomainClassMappingContext, ConstraintEvalUtils.getDefaultConstraints(application.config)) - - transactionManager(DatastoreTransactionManager) { - datastore = ref('grailsDatastore') - } - } - - if (!IS_OLD_SETUP) { - testInstance.grailsApplication.setMappingContext( - testInstance.applicationContext.getBean('grailsDomainClassMappingContext', MappingContext) - ) - } - } - - void configureDataTest(DataTest testInstance) { - setupDataTestBeans testInstance - ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext)testInstance.applicationContext - applicationContext.getBean('constraintRegistry', ConstraintRegistry).addConstraint(UniqueConstraint) - - if (!testInstance.domainsHaveBeenMocked) { - def classes = testInstance.domainClassesToMock - if (classes) { - testInstance.mockDomains classes - } - testInstance.domainsHaveBeenMocked = true - } - } - -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/GormTestingSupportExtension.groovy b/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/GormTestingSupportExtension.groovy deleted file mode 100644 index e77eabdb..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/groovy/org/grails/testing/gorm/spock/GormTestingSupportExtension.groovy +++ /dev/null @@ -1,25 +0,0 @@ -package org.grails.testing.gorm.spock - -import grails.testing.gorm.DataTest -import groovy.transform.CompileStatic -import org.spockframework.runtime.extension.AbstractGlobalExtension -import org.spockframework.runtime.model.SpecInfo - -@CompileStatic -class GormTestingSupportExtension extends AbstractGlobalExtension { - - DataTestSetupSpecInterceptor dataTestSetupSpecInterceptor = new DataTestSetupSpecInterceptor() - DataTestSetupInterceptor dataTestSetupInterceptor = new DataTestSetupInterceptor() - DataTestCleanupInterceptor dataTestCleanupInterceptor = new DataTestCleanupInterceptor() - DataTestCleanupSpecInterceptor dataTestCleanupSpecInterceptor = new DataTestCleanupSpecInterceptor() - - @Override - void visitSpec(SpecInfo spec) { - if (DataTest.isAssignableFrom(spec.reflection)) { - spec.addSetupSpecInterceptor(dataTestSetupSpecInterceptor) - spec.addSetupInterceptor(dataTestSetupInterceptor) - spec.addCleanupInterceptor(dataTestCleanupInterceptor) - spec.addCleanupSpecInterceptor(dataTestCleanupSpecInterceptor) - } - } -} diff --git a/grails-testing-support/grails-gorm-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension b/grails-testing-support/grails-gorm-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension deleted file mode 100644 index fb40a25c..00000000 --- a/grails-testing-support/grails-gorm-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension +++ /dev/null @@ -1 +0,0 @@ -org.grails.testing.gorm.spock.GormTestingSupportExtension diff --git a/grails-testing-support/grails-testing-support/build.gradle b/grails-testing-support/grails-testing-support/build.gradle deleted file mode 100755 index 48d993bb..00000000 --- a/grails-testing-support/grails-testing-support/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -dependencies { - api "org.springframework:spring-test" - api("org.grails:grails-plugin-codecs") { - exclude module: 'grails-plugin-mimetypes' - exclude module: 'grails-plugin-converters' - exclude module: 'grails-web' - } - - api "org.grails:grails-plugin-databinding" - api "org.grails:grails-datastore-gorm" - api("org.grails:grails-test") - api "org.springframework.boot:spring-boot-test" - api("org.spockframework:spock-spring") { transitive = false } - api("org.spockframework:spock-core") { transitive = false } - api "org.apache.groovy:groovy-test-junit5:$groovyVersion" - api "org.junit.jupiter:junit-jupiter-api" - api "org.junit.platform:junit-platform-runner" - runtimeOnly "org.junit.jupiter:junit-jupiter-engine" -} - diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/mixin/integration/Integration.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/mixin/integration/Integration.groovy deleted file mode 100644 index 0a9d9b79..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/mixin/integration/Integration.groovy +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package grails.testing.mixin.integration - -import org.codehaus.groovy.transform.GroovyASTTransformationClass - -import java.lang.annotation.ElementType -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy -import java.lang.annotation.Target - -/** - * Transformation to apply to integration tests - * - * @author Graeme Rocher - * @since 2.3 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target([ElementType.TYPE]) -@GroovyASTTransformationClass("org.grails.compiler.injection.testing.IntegrationTestMixinTransformation") -public @interface Integration { - - /** - * - * Specify the Application class which should be used for - * this functional test. If unspecified the test runtime - * environment will attempt to locate a class in the project - * which extends grails.boot.config.GrailsAutoConfiguration - * which can be problematic in multi project builds where - * multiple Application classes may exist. - */ - Class applicationClass() default {} -} \ No newline at end of file diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/services/ServiceUnitTest.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/services/ServiceUnitTest.groovy deleted file mode 100755 index c2d26431..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/services/ServiceUnitTest.groovy +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.services - -import grails.gorm.services.Service -import grails.util.GrailsNameUtils -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import org.grails.core.artefact.ServiceArtefactHandler -import org.grails.core.exceptions.GrailsConfigurationException -import org.grails.testing.ParameterizedGrailsUnitTest -import org.springframework.util.ClassUtils - -@CompileStatic -trait ServiceUnitTest extends ParameterizedGrailsUnitTest { - - public static final String DATATEST_CLASS = 'grails.testing.gorm.DataTest' - - private static Class dataTest - private static boolean dataTestLoaded - - private void loadDataTestClass() { - if (!dataTestLoaded) { - try { - dataTest = ClassUtils.forName(DATATEST_CLASS) - } catch (ClassNotFoundException e) {} - } - dataTestLoaded = true - } - - /** - * Mocks a service class, registering it with the application context - * - * @param serviceClass The service class - * @return An instance of the service - */ - @CompileDynamic - void mockArtefact(Class serviceClass) { - try { - final serviceArtefact = grailsApplication.addArtefact(ServiceArtefactHandler.TYPE, serviceClass) - - defineBeans { - "${serviceArtefact.propertyName}"(serviceClass) { bean -> - bean.autowire = true - } - } - } - catch (GrailsConfigurationException e) { - if (serviceClass.getAnnotation(Service) != null) { - loadDataTestClass() - if (dataTest != null && dataTest.isAssignableFrom(this.class)) { - dataTest.getMethod('mockDataService', Class).invoke(this, serviceClass) - } - else { - throw new GrailsConfigurationException("Error attempting to test ${serviceClass.name}. Data services require gorm-testing-support to be on the classpath and the test to implement ${DATATEST_CLASS}") - } - } - else { - throw e - } - } - } - - String getBeanName(Class serviceClass) { - GrailsNameUtils.getPropertyName(serviceClass) - } - - T getService() { - getArtefactInstance() - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spock/OnceBefore.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spock/OnceBefore.groovy deleted file mode 100644 index 2833aff3..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spock/OnceBefore.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package grails.testing.spock - -import groovy.transform.AnnotationCollector -import org.junit.jupiter.api.BeforeEach - -/** - * This annotation may be applied to fixture methods in a Spock Spec that should - * be run once and only once before any test methods are run. Methods marked - * with this interface will automatically be marked with @org.junit.Before and - * {@link grails.testing.spock.RunOnce}. - * - * @see org.junit.jupiter.api.BeforeEach - * @see grails.testing.spock.RunOnce - * @deprecated Use Spock native setup/cleanup/â€Ķ​ fixture methods instead. - */ -@Deprecated -@AnnotationCollector([BeforeEach, RunOnce]) -@interface OnceBefore { -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spock/RunOnce.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spock/RunOnce.groovy deleted file mode 100644 index 634e527c..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spock/RunOnce.groovy +++ /dev/null @@ -1,21 +0,0 @@ -package grails.testing.spock - -import org.grails.testing.spock.RunOnceExtension -import org.spockframework.runtime.extension.ExtensionAnnotation - -import java.lang.annotation.ElementType -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy -import java.lang.annotation.Target - -/** - * This annotation may be applied to fixture methods in a Spock Spec that should - * be run once and only. - * - * @see OnceBefore - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@ExtensionAnnotation(RunOnceExtension) -@interface RunOnce { -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spring/AutowiredTest.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spring/AutowiredTest.groovy deleted file mode 100644 index 8ba58720..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/grails/testing/spring/AutowiredTest.groovy +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.spring - -import groovy.transform.CompileStatic -import org.grails.testing.GrailsUnitTest -import org.springframework.beans.factory.config.AutowireCapableBeanFactory - -@CompileStatic -trait AutowiredTest extends GrailsUnitTest { - - void autowire() { - AutowireCapableBeanFactory beanFactory = applicationContext.autowireCapableBeanFactory - beanFactory.autowireBeanProperties this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/compiler/injection/testing/IntegrationTestMixinTransformation.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/compiler/injection/testing/IntegrationTestMixinTransformation.groovy deleted file mode 100644 index 86d74485..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/compiler/injection/testing/IntegrationTestMixinTransformation.groovy +++ /dev/null @@ -1,214 +0,0 @@ -package org.grails.compiler.injection.testing -import grails.boot.test.GrailsApplicationContextLoader -import grails.boot.config.GrailsAutoConfiguration -import grails.testing.mixin.integration.Integration -import groovy.transform.CompileStatic -import org.codehaus.groovy.ast.* -import org.codehaus.groovy.ast.expr.* -import org.codehaus.groovy.ast.stmt.* -import static org.codehaus.groovy.ast.tools.GeneralUtils.* -import org.codehaus.groovy.control.CompilePhase -import org.codehaus.groovy.control.SourceUnit -import org.codehaus.groovy.syntax.Token -import org.codehaus.groovy.syntax.Types -import org.codehaus.groovy.transform.ASTTransformation -import org.codehaus.groovy.transform.GroovyASTTransformation -import org.grails.compiler.injection.GrailsASTUtils -import org.grails.io.support.MainClassFinder -import org.grails.testing.context.junit4.GrailsJunit4ClassRunner -import org.grails.testing.context.junit4.GrailsTestConfiguration -import org.junit.runner.RunWith -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value -import org.springframework.beans.factory.config.AutowireCapableBeanFactory -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.ApplicationContext -import org.springframework.context.ApplicationContextAware -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import org.springframework.util.ClassUtils - -import java.lang.reflect.Modifier -/* - * Copyright 2014 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @author Graeme Rocher - * @since 3.0 - */ -@CompileStatic -@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION) -class IntegrationTestMixinTransformation implements ASTTransformation { - - static final ClassNode MY_TYPE = new ClassNode(Integration.class) - public static final ClassNode CONTEXT_CONFIG_ANNOTATION = ClassHelper.make(ContextConfiguration) - public static final ClassNode GRAILS_APPLICATION_CONTEXT_LOADER = ClassHelper.make(GrailsApplicationContextLoader) - public static final ClassNode WEB_APP_CONFIGURATION = ClassHelper.make(WebAppConfiguration) - public static final ClassNode INTEGRATION_TEST_CLASS_NODE = ClassHelper.make(SpringBootTest) - public static final ClassNode SPRING_APPLICATION_CONFIGURATION_CLASS_NODE = ClassHelper.make(GrailsTestConfiguration) - public static final ClassNode RUN_WITH_ANNOTATION_NODE = ClassHelper.make(RunWith) - public static final ClassNode SPRING_JUNIT4_CLASS_RUNNER = ClassHelper.make(GrailsJunit4ClassRunner) - public static final String SPEC_CLASS = "spock.lang.Specification" - - @Override - void visit(ASTNode[] astNodes, SourceUnit source) { - if (!(astNodes[0] instanceof AnnotationNode) || !(astNodes[1] instanceof AnnotatedNode)) { - throw new RuntimeException("Internal error: wrong types: ${astNodes[0].getClass()} / ${astNodes[1].getClass()}") - } - - AnnotatedNode parent = (AnnotatedNode) astNodes[1] - AnnotationNode annotationNode = (AnnotationNode) astNodes[0] - if (!MY_TYPE.equals(annotationNode.classNode) || !(parent instanceof ClassNode)) { - return - } - - ClassExpression applicationClassExpression = (ClassExpression)annotationNode.getMember('applicationClass') - - final applicationClassNode - if(applicationClassExpression) { - applicationClassNode = applicationClassExpression.getType() - if(!applicationClassNode.isDerivedFrom(ClassHelper.make(GrailsAutoConfiguration))) { - GrailsASTUtils.error(source, applicationClassExpression, "Invalid applicationClass attribute value [${applicationClassNode.getName()}]. The applicationClass attribute must specify a class which extends grails.boot.config.GrailsAutoConfiguration.", true) - } - } else { - String mainClass = MainClassFinder.searchMainClass(source.source.URI) - if(mainClass) { - applicationClassNode = ClassHelper.make(mainClass) - } else { - applicationClassNode = null - } - } - - if(applicationClassNode) { - ClassNode classNode = (ClassNode) parent - - weaveIntegrationTestMixin(classNode, applicationClassNode) - - } - - } - - public void weaveIntegrationTestMixin(ClassNode classNode, ClassNode applicationClassNode) { - if(applicationClassNode == null) return - - - enableAutowireByName(classNode) - - if (GrailsASTUtils.isSubclassOf(classNode, SPEC_CLASS)) { - // first add context configuration - // Example: @ContextConfiguration(loader = GrailsApplicationContextLoader, classes = Application) - def contextConfigAnn = new AnnotationNode(CONTEXT_CONFIG_ANNOTATION) - contextConfigAnn.addMember("loader", new ClassExpression(GRAILS_APPLICATION_CONTEXT_LOADER)) - contextConfigAnn.addMember("classes", new ClassExpression(applicationClassNode)) - classNode.addAnnotation(contextConfigAnn) - - enhanceGebSpecWithPort(classNode) - - } else { - // Must be a JUnit 4 test so add JUnit spring annotations - // @RunWith(SpringJUnit4ClassRunner) - def runWithAnnotation = new AnnotationNode(RUN_WITH_ANNOTATION_NODE) - runWithAnnotation.addMember("value", new ClassExpression(SPRING_JUNIT4_CLASS_RUNNER)) - classNode.addAnnotation(runWithAnnotation) - - // @SpringApplicationConfiguration(classes = Application) - def contextConfigAnn = new AnnotationNode(SPRING_APPLICATION_CONFIGURATION_CLASS_NODE) - contextConfigAnn.addMember("classes", new ClassExpression(applicationClassNode)) - classNode.addAnnotation(contextConfigAnn) - } - - // now add integration test annotations - // @SpringBootTest - def servletApi = null - try { - servletApi = Class.forName("jakarta.servlet.ServletContext", false, getClass().classLoader) - } - catch(Exception e) { - // ignore - } - - - if (servletApi != null) { - - if( GrailsASTUtils.findAnnotation(classNode, SpringBootTest) == null) { - AnnotationNode webIntegrationTestAnnotation = GrailsASTUtils.addAnnotationOrGetExisting(classNode, SpringBootTest) - webIntegrationTestAnnotation.addMember("webEnvironment", propX(classX(SpringBootTest.WebEnvironment.class), "RANDOM_PORT")) - if(classNode.getProperty("serverPort") == null) { - - def serverPortField = new FieldNode("serverPort", Modifier.PROTECTED, ClassHelper.Integer_TYPE, classNode, new ConstantExpression(8080)) - def valueAnnotation = new AnnotationNode(ClassHelper.make(Value)) - valueAnnotation.setMember("value", new ConstantExpression('${local.server.port}')) - serverPortField.addAnnotation(valueAnnotation) - - classNode.addProperty(new PropertyNode(serverPortField, Modifier.PUBLIC, null, null )) - } - } - } else { - classNode.addAnnotation(new AnnotationNode(INTEGRATION_TEST_CLASS_NODE)) - } - } - - protected void enableAutowireByName(ClassNode classNode) { - classNode.addInterface(ClassHelper.make(ApplicationContextAware)) - - def body = new BlockStatement() - - def ctxClass = ClassHelper.make(ApplicationContext) - def p = new Parameter(ctxClass, "ctx") - - def getBeanFactoryMethodCall = new MethodCallExpression(new VariableExpression(p), "getAutowireCapableBeanFactory", GrailsASTUtils.ZERO_ARGUMENTS) - - def args = new ArgumentListExpression(new VariableExpression("this"), new ConstantExpression(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME), new ConstantExpression(Boolean.FALSE)) - def autoMethodCall = new MethodCallExpression(getBeanFactoryMethodCall, "autowireBeanProperties", args) - body.addStatement(new ExpressionStatement(autoMethodCall)) - classNode.addMethod("setApplicationContext", Modifier.PUBLIC, ClassHelper.VOID_TYPE, [p] as Parameter[], null, body) - } - - protected void enhanceGebSpecWithPort(ClassNode classNode) { - if (GrailsASTUtils.isSubclassOf(classNode, "geb.spock.GebSpec")) { - def contextPathParameter = new Parameter(ClassHelper.make(String), 'serverContextPath') - def cpValueAnnotation = new AnnotationNode(ClassHelper.make(Value)) - cpValueAnnotation.setMember('value', new ConstantExpression('${server.servlet.context-path:/}')) - contextPathParameter.addAnnotation(cpValueAnnotation) - - def serverPortParameter = new Parameter(ClassHelper.make(Integer.TYPE), 'serverPort') - def spValueAnnotation = new AnnotationNode(ClassHelper.make(Value)) - spValueAnnotation.setMember('value', new ConstantExpression('${local.server.port}')) - serverPortParameter.addAnnotation(spValueAnnotation) - - Expression urlExpression = new GStringExpression('http://localhost:${serverPort}${serverContextPath}', [new ConstantExpression('http://localhost:'), new ConstantExpression(""), new ConstantExpression("")], [new VariableExpression('serverPort'), new VariableExpression('serverContextPath')] as List) - - Expression baseUrlVariableExpression = new VariableExpression('$baseUrl', ClassHelper.make(String)) - Expression declareBaseUrlExpression = new DeclarationExpression(baseUrlVariableExpression, Token.newSymbol(Types.EQUALS, 0, 0), new MethodCallExpression(urlExpression, 'toString', new ArgumentListExpression())) - - Expression constantSlashExpression = new ConstantExpression('/') - Expression endsWithMethodCall = new MethodCallExpression(baseUrlVariableExpression, 'endsWith', new ArgumentListExpression(constantSlashExpression)) - Expression appendSlashExpression = new BinaryExpression(baseUrlVariableExpression, Token.newSymbol(Types.PLUS_EQUAL, 0, 0), constantSlashExpression) - Statement ifUrlEndsWithSlashStatement = new IfStatement(new BooleanExpression(endsWithMethodCall), new EmptyStatement(), new ExpressionStatement(appendSlashExpression)) - def methodBody = new BlockStatement() - methodBody.addStatement(new ExpressionStatement(declareBaseUrlExpression)) - methodBody.addStatement(ifUrlEndsWithSlashStatement) - def systemClassExpression = new ClassExpression(ClassHelper.make(System)) - def args = new ArgumentListExpression() - args.addExpression(new ConstantExpression("geb.build.baseUrl")) - args.addExpression(baseUrlVariableExpression) - methodBody.addStatement(new ExpressionStatement(new MethodCallExpression(systemClassExpression, "setProperty", args))) - def method = new MethodNode("configureGebBaseUrl", Modifier.PUBLIC, ClassHelper.VOID_TYPE, [contextPathParameter, serverPortParameter] as Parameter[], null, methodBody) - method.addAnnotation(new AnnotationNode(ClassHelper.make(Autowired))) - classNode.addMethod(method) - } - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy deleted file mode 100644 index 9cfb50bc..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy +++ /dev/null @@ -1,241 +0,0 @@ -package org.grails.testing - -import grails.boot.config.GrailsApplicationPostProcessor -import grails.core.GrailsApplication -import grails.core.GrailsApplicationLifeCycle -import grails.core.support.proxy.DefaultProxyHandler -import grails.plugins.GrailsPluginManager -import grails.spring.BeanBuilder -import grails.util.Holders -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import jakarta.servlet.ServletContext -import org.grails.plugins.IncludingPluginFilter -import org.grails.spring.context.support.GrailsPlaceholderConfigurer -import org.grails.spring.context.support.MapBasedSmartPropertyOverrideConfigurer -import org.grails.transaction.TransactionManagerPostProcessor -import org.springframework.beans.BeansException -import org.springframework.beans.MutablePropertyValues -import org.springframework.beans.factory.config.BeanDefinition -import org.springframework.beans.factory.config.ConfigurableBeanFactory -import org.springframework.beans.factory.config.ConstructorArgumentValues -import org.springframework.beans.factory.support.BeanDefinitionRegistry -import org.springframework.beans.factory.support.DefaultListableBeanFactory -import org.springframework.beans.factory.support.RootBeanDefinition -import org.springframework.boot.autoconfigure.AutoConfiguration -import org.springframework.boot.context.annotation.ImportCandidates -import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer -import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.context.annotation.AnnotationConfigRegistry -import org.springframework.context.annotation.AnnotationConfigUtils -import org.springframework.context.support.ConversionServiceFactoryBean -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer -import org.springframework.context.support.StaticMessageSource -import org.springframework.core.Ordered -import org.springframework.util.ClassUtils - -/** - * Created by jameskleeh on 5/31/17. - */ -@CompileStatic -class GrailsApplicationBuilder { - - public static final boolean isServletApiPresent = ClassUtils.isPresent('jakarta.servlet.ServletContext', GrailsApplicationBuilder.classLoader) - - static final Set DEFAULT_INCLUDED_PLUGINS = ['core', 'eventBus'] as Set - - Closure doWithSpring - Closure doWithConfig - Set includePlugins - boolean loadExternalBeans - boolean localOverride = false - - GrailsApplication grailsApplication - Object servletContext - - @CompileDynamic - GrailsApplicationBuilder build() { - - servletContext = createServletContext() - def mainContext = createMainContext(servletContext) - - if (isServletApiPresent) { - // NOTE: The following dynamic class loading hack is temporary so the - // compile time dependency on the servlet api can be removed from this - // sub project. This whole GrailsApplicationTestPlugin class will soon - // be removed so rather than implement a real solution, this hack will - // do for now to keep the build healthy. - try { - def segads = Class.forName('org.grails.web.context.ServletEnvironmentGrailsApplicationDiscoveryStrategy') - Holders.addApplicationDiscoveryStrategy(segads.newInstance(servletContext)) - } - catch (Throwable ignored) {} - - try { - def gcu = Class.forName('org.grails.web.servlet.context.GrailsConfigUtils') - gcu.configureServletContextAttributes(servletContext, grailsApplication, mainContext.getBean(GrailsPluginManager.BEAN_NAME, GrailsPluginManager), mainContext) - } - catch (Throwable ignored) {} - } - - grailsApplication = mainContext.getBean('grailsApplication') as GrailsApplication - - if (!grailsApplication.isInitialised()) { - grailsApplication.initialise() - } - - return this - } - - protected Object createServletContext() { - - def context = null - - if (isServletApiPresent) { - context = ClassUtils.forName('org.springframework.mock.web.MockServletContext').getDeclaredConstructor().newInstance() - Holders.setServletContext(context) - } - - return context - } - - protected ConfigurableApplicationContext createMainContext(Object servletContext) { - ConfigurableApplicationContext context - if (isServletApiPresent && servletContext != null) { - context = (AnnotationConfigServletWebApplicationContext) ClassUtils.forName('org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext').getDeclaredConstructor().newInstance() - ((AnnotationConfigServletWebApplicationContext) context).setServletContext((ServletContext) servletContext) - } else { - context = (ConfigurableApplicationContext) ClassUtils.forName('org.springframework.context.annotation.AnnotationConfigApplicationContext').getDeclaredConstructor().newInstance() - } - - def classLoader = this.class.classLoader - ImportCandidates.load(AutoConfiguration, classLoader).asList().findAll { - it.startsWith("org.grails") - && !it.contains("UrlMappingsAutoConfiguration") // this currently is causing an issue with tests - }.each { - ((AnnotationConfigRegistry) context).register(ClassUtils.forName(it, classLoader)) - } - - def beanFactory = context.getBeanFactory() - (beanFactory as DefaultListableBeanFactory).with { - setAllowBeanDefinitionOverriding(true) - setAllowCircularReferences(true) - } - prepareContext(context, beanFactory) - context.refresh() - context.registerShutdownHook() - return context - } - - protected void prepareContext(ConfigurableApplicationContext applicationContext, ConfigurableBeanFactory beanFactory) { - registerGrailsAppPostProcessorBean(beanFactory) - AnnotationConfigUtils.registerAnnotationConfigProcessors((BeanDefinitionRegistry) beanFactory) - new ConfigDataApplicationContextInitializer().initialize(applicationContext) - } - - void executeDoWithSpringCallback(GrailsApplication grailsApplication) { - if (!doWithSpring) return - defineBeans(grailsApplication, doWithSpring) - } - - void defineBeans(Closure callable) { - defineBeans(grailsApplication, callable) - } - - void defineBeans(GrailsApplication grailsApplication, Closure callable) { - def binding = new Binding() - def bb = new BeanBuilder(null, null, grailsApplication.getClassLoader()) - binding.setVariable('application', grailsApplication) - bb.setBinding(binding) - bb.beans(callable) - bb.registerBeans((BeanDefinitionRegistry) grailsApplication.getMainContext()) - } - - @CompileDynamic - void registerBeans(GrailsApplication grailsApplication) { - - defineBeans(grailsApplication) { -> - - conversionService(ConversionServiceFactoryBean) - - xmlns context: "http://www.springframework.org/schema/context" - // adds AutowiredAnnotationBeanPostProcessor, CommonAnnotationBeanPostProcessor and others - // see org.springframework.context.annotation.AnnotationConfigUtils.registerAnnotationConfigProcessors method - context.'annotation-config'() - - proxyHandler(DefaultProxyHandler) - messageSource(StaticMessageSource) - transactionManagerAwarePostProcessor(TransactionManagerPostProcessor) - grailsPlaceholderConfigurer(GrailsPlaceholderConfigurer, '${', grailsApplication.config.toProperties()) - mapBasedSmartPropertyOverrideConfigurer(MapBasedSmartPropertyOverrideConfigurer) { - setGrailsApplication(grailsApplication) - } - } - } - - protected void registerGrailsAppPostProcessorBean(ConfigurableBeanFactory beanFactory) { - - GrailsApplication grailsApp - - Closure doWithSpringClosure = { - registerBeans(grailsApp) - executeDoWithSpringCallback(grailsApp) - } - - Closure customizeGrailsApplicationClosure = { GrailsApplication grailsApplication -> - grailsApp = grailsApplication - if (doWithConfig) { - doWithConfig.call(grailsApplication.config) - // reset flatConfig - grailsApplication.configChanged() - } - Holders.config = grailsApplication.config - } - - def constructorArgumentValues = new ConstructorArgumentValues() - constructorArgumentValues.addIndexedArgumentValue(0, doWithSpringClosure) - constructorArgumentValues.addIndexedArgumentValue(1, includePlugins ?: DEFAULT_INCLUDED_PLUGINS) - - def values = new MutablePropertyValues() - values.add('localOverride', localOverride) - values.add('loadExternalBeans', loadExternalBeans) - values.add('customizeGrailsApplicationClosure', customizeGrailsApplicationClosure) - - def beanDef = new RootBeanDefinition(TestRuntimeGrailsApplicationPostProcessor, constructorArgumentValues, values) - beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE) - (beanFactory as BeanDefinitionRegistry).registerBeanDefinition('grailsApplicationPostProcessor', beanDef) - } - - static class TestRuntimeGrailsApplicationPostProcessor extends GrailsApplicationPostProcessor { - - Closure customizeGrailsApplicationClosure - Set includedPlugins - boolean localOverride = false - - TestRuntimeGrailsApplicationPostProcessor(Closure doWithSpringClosure, Set includedPlugins) { - super([doWithSpring: { -> doWithSpringClosure }] as GrailsApplicationLifeCycle, null, null) - loadExternalBeans = false - reloadingEnabled = false - this.includedPlugins = includedPlugins - } - - @Override - protected void customizePluginManager(GrailsPluginManager grailsApplication) { - pluginManager.pluginFilter = new IncludingPluginFilter(includedPlugins) - } - - @Override - protected void customizeGrailsApplication(GrailsApplication grailsApplication) { - customizeGrailsApplicationClosure?.call(grailsApplication) - } - - @Override - void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { - super.postProcessBeanDefinitionRegistry(registry) - PropertySourcesPlaceholderConfigurer propertySourcePlaceholderConfigurer = (PropertySourcesPlaceholderConfigurer) grailsApplication.mainContext.getBean('grailsPlaceholderConfigurer') - propertySourcePlaceholderConfigurer.order = Ordered.HIGHEST_PRECEDENCE - propertySourcePlaceholderConfigurer.setLocalOverride(localOverride) - } - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/GrailsUnitTest.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/GrailsUnitTest.groovy deleted file mode 100644 index 70b56121..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/GrailsUnitTest.groovy +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.grails.testing - -import grails.config.Config -import grails.core.DefaultGrailsApplication -import grails.core.GrailsApplication -import grails.spring.BeanBuilder -import grails.util.Holders -import grails.validation.DeferredBindingActions -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import org.grails.core.lifecycle.ShutdownOperations -import org.springframework.beans.factory.support.BeanDefinitionRegistry -import org.springframework.context.ApplicationContext -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.context.MessageSource -import org.springframework.util.ClassUtils - -import java.lang.reflect.Method - -@CompileStatic -trait GrailsUnitTest { - - private static GrailsApplication _grailsApplication - private static Object _servletContext - - boolean getLocalOverride() { - false - } - - /** - * @return the servlet context - */ - Object getOptionalServletContext() { - _servletContext - } - - /** - * - * @return grailsApplication.mainContext - */ - ConfigurableApplicationContext getApplicationContext() { - (ConfigurableApplicationContext) grailsApplication.mainContext - } - - /** - * - * @return The GrailsApplication instance - */ - GrailsApplication getGrailsApplication() { - if (_grailsApplication == null) { - def builder = new GrailsApplicationBuilder( - doWithSpring: doWithSpring(), - doWithConfig: doWithConfig(), - includePlugins: getIncludePlugins(), - loadExternalBeans: loadExternalBeans(), - localOverride: localOverride - ).build() - _grailsApplication = builder.grailsApplication - _servletContext = builder.servletContext - } - _grailsApplication - } - - /** - * - * @return grailsApplication.config - */ - Config getConfig() { - grailsApplication.config - } - - /** - * - * @return the MessageSource bean from the application context - */ - MessageSource getMessageSource() { - applicationContext.getBean("messageSource", MessageSource) - } - - void defineBeans(Closure closure) { - def binding = new Binding() - def bb = new BeanBuilder(null, null, grailsApplication.getClassLoader()) - binding.setVariable "application", grailsApplication - bb.setBinding binding - bb.beans(closure) - bb.registerBeans((BeanDefinitionRegistry)applicationContext) - applicationContext.beanFactory.preInstantiateSingletons() - } - - void defineBeans(Object plugin) { - Class clazz = plugin.getClass() - try { - Method doWithSpringMethod = clazz.getMethod('doWithSpring') - Closure config = (Closure)doWithSpringMethod.invoke(plugin) - if (config != null) { - defineBeans(config) - return - } - } catch (NoSuchMethodException e) {} - - try { - Method doWithSpringField = clazz.getMethod('getDoWithSpring') - defineBeans((Closure)doWithSpringField.invoke(plugin)) - } catch (NoSuchFieldException e) {} - } - - Closure doWithSpring() { - null - } - - Closure doWithConfig() { - null - } - - Set getIncludePlugins() { - new HashSet() - } - - boolean loadExternalBeans() { - false - } - - void cleanupGrailsApplication() { - if (_grailsApplication != null) { - if (_grailsApplication instanceof DefaultGrailsApplication) { - ((DefaultGrailsApplication)_grailsApplication).clear() - } - - ApplicationContext applicationContext = grailsApplication.getParentContext() - - if (applicationContext instanceof ConfigurableApplicationContext) { - if (((ConfigurableApplicationContext) applicationContext).isActive()) { - if(grailsApplication.mainContext instanceof Closeable) { - ((Closeable)grailsApplication.mainContext).close() - } - if (applicationContext instanceof Closeable) { - ((Closeable)applicationContext).close() - } - } - } - - ShutdownOperations.runOperations() - DeferredBindingActions.clear() - - this._grailsApplication = null - cleanupPromiseFactory() - Holders.clear() - } - } - - @CompileDynamic - private void cleanupPromiseFactory() { - ClassLoader classLoader = getClass().classLoader - if (ClassUtils.isPresent("grails.async.Promises", classLoader)) { - getClass().classLoader.loadClass("grails.async.Promises")['promiseFactory'] = null - } - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/ParameterizedGrailsUnitTest.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/ParameterizedGrailsUnitTest.groovy deleted file mode 100755 index 64c240bb..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/ParameterizedGrailsUnitTest.groovy +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.grails.testing - -import groovy.transform.CompileStatic -import org.springframework.beans.factory.config.AutowireCapableBeanFactory - -import java.lang.reflect.ParameterizedType - -@CompileStatic -trait ParameterizedGrailsUnitTest extends GrailsUnitTest { - - private T _artefactInstance - - Class getTypeUnderTest() { - ParameterizedType parameterizedType = (ParameterizedType)getClass().genericInterfaces.find { genericInterface -> - genericInterface instanceof ParameterizedType && - ParameterizedGrailsUnitTest.isAssignableFrom((Class)((ParameterizedType)genericInterface).rawType) - } - - if (parameterizedType?.actualTypeArguments != null) { - parameterizedType.actualTypeArguments[0] - } else { - null - } - } - - T getArtefactInstance() { - if (_artefactInstance == null && applicationContext != null) { - def cutType = getTypeUnderTest() - if (cutType != null) { - mockArtefact(cutType) - final String beanName = getBeanName(cutType) - if (beanName != null && applicationContext.containsBean(beanName)) { - _artefactInstance = applicationContext.getBean(beanName, T) - } else { - _artefactInstance = cutType.newInstance() - applicationContext.autowireCapableBeanFactory.autowireBeanProperties _artefactInstance, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false - } - } - } - _artefactInstance - } - - abstract void mockArtefact(Class artefactClass) - - abstract String getBeanName(Class artefactClass) -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/context/junit4/GrailsJunit4ClassRunner.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/context/junit4/GrailsJunit4ClassRunner.groovy deleted file mode 100644 index ee9f7341..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/context/junit4/GrailsJunit4ClassRunner.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package org.grails.testing.context.junit4 - -import grails.boot.test.GrailsApplicationContextLoader -import groovy.transform.CompileStatic -import groovy.transform.InheritConstructors -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner - -/* - * Copyright 2014 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @author Graeme Rocher - * @since 3.0 - */ -@InheritConstructors -@CompileStatic -class GrailsJunit4ClassRunner extends SpringJUnit4ClassRunner { - - protected String getDefaultContextLoaderClassName(Class clazz) { - return GrailsApplicationContextLoader.name - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/context/junit4/GrailsTestConfiguration.java b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/context/junit4/GrailsTestConfiguration.java deleted file mode 100644 index 232d81f4..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/context/junit4/GrailsTestConfiguration.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.grails.testing.context.junit4;/* - * Copyright 2014 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import grails.boot.test.GrailsApplicationContextLoader; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.test.context.ContextConfiguration; - -import java.lang.annotation.*; - -/** - * @author Graeme Rocher - * @since 3.0 - */ -@ContextConfiguration(loader = GrailsApplicationContextLoader.class) -@Documented -@Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface GrailsTestConfiguration { - - /** - * @see ContextConfiguration#locations() - */ - String[] locations() default {}; - - /** - * @see ContextConfiguration#classes() - */ - Class[] classes() default {}; - - /** - * @see ContextConfiguration#initializers() - */ - Class>[] initializers() default {}; - - /** - * @see ContextConfiguration#inheritLocations() - */ - boolean inheritLocations() default true; - - /** - * @see ContextConfiguration#inheritInitializers() - */ - boolean inheritInitializers() default true; - - /** - * @see ContextConfiguration#name() - */ - String name() default ""; - -} \ No newline at end of file diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/AutowiredInterceptor.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/AutowiredInterceptor.groovy deleted file mode 100644 index dbc5963b..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/AutowiredInterceptor.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.spring.AutowiredTest -import groovy.transform.CompileStatic -import groovy.util.logging.Slf4j -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@Slf4j -@CompileStatic -class AutowiredInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - ((AutowiredTest)invocation.instance).autowire() - invocation.proceed() - } -} \ No newline at end of file diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/CleanupContextInterceptor.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/CleanupContextInterceptor.groovy deleted file mode 100644 index 6ee730e4..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/CleanupContextInterceptor.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package org.grails.testing.spock - -import groovy.transform.CompileStatic -import org.grails.testing.GrailsUnitTest -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class CleanupContextInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - ((GrailsUnitTest)invocation.instance).cleanupGrailsApplication() - invocation.proceed() - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/RunOnceExtension.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/RunOnceExtension.groovy deleted file mode 100644 index 5ceace0e..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/RunOnceExtension.groovy +++ /dev/null @@ -1,15 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.spock.RunOnce -import groovy.transform.CompileStatic -import org.spockframework.runtime.extension.AbstractAnnotationDrivenExtension -import org.spockframework.runtime.model.MethodInfo - -@CompileStatic -class RunOnceExtension extends AbstractAnnotationDrivenExtension { - - @Override - void visitFixtureAnnotation(RunOnce annotation, MethodInfo fixtureMethod) { - fixtureMethod.addInterceptor new RunOnceInterceptor() - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/RunOnceInterceptor.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/RunOnceInterceptor.groovy deleted file mode 100644 index ed995f31..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/RunOnceInterceptor.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package org.grails.testing.spock - -import groovy.transform.CompileStatic -import org.spockframework.runtime.extension.AbstractMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class RunOnceInterceptor extends AbstractMethodInterceptor { - boolean hasRun = false - - @Override - void interceptSetupMethod(IMethodInvocation invocation) throws Throwable { - if(!hasRun) { - hasRun = true - invocation.proceed() - } - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/TestingSupportExtension.groovy b/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/TestingSupportExtension.groovy deleted file mode 100644 index a34657f6..00000000 --- a/grails-testing-support/grails-testing-support/src/main/groovy/org/grails/testing/spock/TestingSupportExtension.groovy +++ /dev/null @@ -1,78 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.spring.AutowiredTest -import groovy.transform.CompileStatic -import org.grails.testing.GrailsUnitTest -import org.junit.jupiter.api.AfterAll -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.BeforeEach -import org.spockframework.runtime.extension.IGlobalExtension -import org.spockframework.runtime.model.MethodInfo -import org.spockframework.runtime.model.MethodKind -import org.spockframework.runtime.model.SpecInfo - -import java.lang.annotation.Annotation -import java.lang.reflect.Method -import java.lang.reflect.Modifier - -@CompileStatic -class TestingSupportExtension implements IGlobalExtension { - - AutowiredInterceptor autowiredInterceptor = new AutowiredInterceptor() - CleanupContextInterceptor cleanupContextInterceptor = new CleanupContextInterceptor() - - @Override - void visitSpec(SpecInfo spec) { - if (AutowiredTest.isAssignableFrom(spec.reflection)) { - spec.addSetupInterceptor(autowiredInterceptor) - } - if (GrailsUnitTest.isAssignableFrom(spec.reflection)) { - spec.addCleanupSpecInterceptor(cleanupContextInterceptor) - } - for (Method method : (spec.getReflection().declaredMethods)) { - if (method.isAnnotationPresent(BeforeEach.class)) { - spec.setupMethods.add(0, createJUnitFixtureMethod(spec, method, MethodKind.SETUP, BeforeEach.class)) - } - if (method.isAnnotationPresent(AfterEach.class)) { - spec.addCleanupMethod(createJUnitFixtureMethod(spec, method, MethodKind.CLEANUP, AfterEach.class)) - } - if (method.isAnnotationPresent(BeforeAll.class)) { - spec.setupSpecMethods.add(0, createJUnitFixtureMethod(spec, method, MethodKind.SETUP_SPEC, BeforeAll.class)) - } - if (method.isAnnotationPresent(AfterAll.class)) { - spec.addCleanupSpecMethod(createJUnitFixtureMethod(spec, method, MethodKind.CLEANUP_SPEC, AfterAll.class)) - } - } - } - - private static MethodInfo createMethod(SpecInfo specInfo, Method method, MethodKind kind, String name) { - MethodInfo methodInfo = new MethodInfo() - methodInfo.parent = specInfo - methodInfo.name = name - methodInfo.reflection = method - methodInfo.kind = kind - return methodInfo - } - - private static MethodInfo createJUnitFixtureMethod(SpecInfo specInfo, Method method, MethodKind kind, Class annotation) { - MethodInfo methodInfo = createMethod(specInfo, method, kind, method.name) - methodInfo.excluded = isOverriddenJUnitFixtureMethod(specInfo, method, annotation) - return methodInfo - } - - private static boolean isOverriddenJUnitFixtureMethod(SpecInfo specInfo, Method method, Class annotation) { - if (Modifier.isPrivate(method.modifiers)) return false - - for (Class currClass = specInfo.class; currClass != specInfo.class.superclass; currClass = currClass.superclass) { - for (Method currMethod : currClass.declaredMethods) { - if (!currMethod.isAnnotationPresent(annotation)) continue - if (currMethod.name != method.name) continue - if (!Arrays.deepEquals(currMethod.parameterTypes, method.parameterTypes)) continue - return true - } - } - - return false - } -} diff --git a/grails-testing-support/grails-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension b/grails-testing-support/grails-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension deleted file mode 100644 index 41355544..00000000 --- a/grails-testing-support/grails-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension +++ /dev/null @@ -1 +0,0 @@ -org.grails.testing.spock.TestingSupportExtension diff --git a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/InherittedSpec.groovy b/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/InherittedSpec.groovy deleted file mode 100644 index 9907d385..00000000 --- a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/InherittedSpec.groovy +++ /dev/null @@ -1,30 +0,0 @@ -package grails.testing.spock - -import spock.lang.Specification - -class InherittedSpec extends ParentSpec { - void setup() { - System.out.println("child") - } - - def "test"() { - expect: - true - } -} - -abstract class ParentSpec extends GrandParentSpec { - void setup() { - System.out.println("parent") - } -} - -abstract class GrandParentSpec extends Specification implements SomeTrait { - void setup() { - System.out.println("grand parent") - } -} - -trait SomeTrait { - -} \ No newline at end of file diff --git a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/JUnitAnnotationSpec.groovy b/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/JUnitAnnotationSpec.groovy deleted file mode 100644 index 3ce09aaa..00000000 --- a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/JUnitAnnotationSpec.groovy +++ /dev/null @@ -1,57 +0,0 @@ -package grails.testing.spock - -import org.junit.jupiter.api.AfterAll -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.BeforeEach -import spock.lang.Shared -import spock.lang.Specification -import spock.lang.Stepwise - -@Stepwise -class JUnitAnnotationSpec extends Specification { - @Shared - static List methodOrder = [] - - void setupSpec() { - methodOrder << "setupSpec" - } - - void setup() { - methodOrder << "setup" - } - - void cleanup() { - methodOrder << "cleanup" - } - - void cleanupSpec() { - methodOrder << "cleanupSpec" - } - - @BeforeEach - void beforeEach() { - methodOrder << "beforeEach" - } - - @AfterEach - void afterEach() { - methodOrder << "afterEach" - } - - @BeforeAll - static void beforeAll() { - methodOrder << "beforeAll" - } - - @AfterAll - static void afterAll() { - methodOrder << "afterAll" - assert methodOrder == ["beforeAll", "setupSpec", "beforeEach", "setup", "cleanup", "afterEach", "cleanupSpec", "afterAll"] - } - - void 'junit 5 annotated methods are called in correct order prior to this test'() { - expect: - methodOrder == ["beforeAll", "setupSpec", "beforeEach", "setup"] - } -} diff --git a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/OnceBeforeSpec.groovy b/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/OnceBeforeSpec.groovy deleted file mode 100644 index 04acb656..00000000 --- a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/OnceBeforeSpec.groovy +++ /dev/null @@ -1,63 +0,0 @@ -package grails.testing.spock - -import spock.lang.Shared -import spock.lang.Specification -import spock.lang.Stepwise - -@Stepwise -class OnceBeforeSpec extends Specification { - - @Shared - int setupSpecCounter = 0 - - @Shared - int setupCounter = 0 - - @Shared - int onceBeforeCounter = 0 - - @Shared - int anotherOnceBeforeCounter = 0 - - void setupSpec() { - setupSpecCounter++ - } - - void setup() { - setupCounter++ - } - - @OnceBefore - void someOnceBeforeMethod() { - onceBeforeCounter++ - } - - @OnceBefore - void someOtherOnceBeforeMethod() { - anotherOnceBeforeCounter++ - } - - void 'first test'() { - expect: - setupSpecCounter == 1 - setupCounter == 1 - onceBeforeCounter == 1 - anotherOnceBeforeCounter == 1 - } - - void 'second test'() { - expect: - setupSpecCounter == 1 - setupCounter == 2 - onceBeforeCounter == 1 - anotherOnceBeforeCounter == 1 - } - - void 'third test'() { - expect: - setupSpecCounter == 1 - setupCounter == 3 - onceBeforeCounter == 1 - anotherOnceBeforeCounter == 1 - } -} diff --git a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/RunOnceSpec.groovy b/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/RunOnceSpec.groovy deleted file mode 100644 index cabfc493..00000000 --- a/grails-testing-support/grails-testing-support/src/test/groovy/grails/testing/spock/RunOnceSpec.groovy +++ /dev/null @@ -1,66 +0,0 @@ -package grails.testing.spock - -import org.junit.jupiter.api.BeforeEach -import spock.lang.Shared -import spock.lang.Specification -import spock.lang.Stepwise - -@Stepwise -class RunOnceSpec extends Specification { - - @Shared - int setupSpecCounter = 0 - - @Shared - int setupCounter = 0 - - @Shared - int onceBeforeCounter = 0 - - @Shared - int anotherOnceBeforeCounter = 0 - - void setupSpec() { - setupSpecCounter++ - } - - void setup() { - setupCounter++ - } - - @BeforeEach - @RunOnce - void someOnceBeforeMethod() { - onceBeforeCounter++ - } - - @BeforeEach - @RunOnce - void someOtherOnceBeforeMethod() { - anotherOnceBeforeCounter++ - } - - void 'first test'() { - expect: - setupSpecCounter == 1 - setupCounter == 1 - onceBeforeCounter == 1 - anotherOnceBeforeCounter == 1 - } - - void 'second test'() { - expect: - setupSpecCounter == 1 - setupCounter == 2 - onceBeforeCounter == 1 - anotherOnceBeforeCounter == 1 - } - - void 'third test'() { - expect: - setupSpecCounter == 1 - setupCounter == 3 - onceBeforeCounter == 1 - anotherOnceBeforeCounter == 1 - } -} diff --git a/grails-testing-support/grails-web-testing-support/build.gradle b/grails-testing-support/grails-web-testing-support/build.gradle deleted file mode 100755 index 0fa56d65..00000000 --- a/grails-testing-support/grails-web-testing-support/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -dependencies { - api "org.grails.plugins:gsp" - api "org.grails:grails-plugin-rest" - api "org.grails:grails-plugin-interceptors" - api "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" - - api project(':grails-testing-support') - api "org.javassist:javassist:$javassistVersion" -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/GrailsWebUnitTest.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/GrailsWebUnitTest.groovy deleted file mode 100644 index 9a0dc738..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/GrailsWebUnitTest.groovy +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.web - -import grails.artefact.TagLibrary -import grails.core.GrailsClass -import grails.core.GrailsControllerClass -import grails.core.gsp.GrailsTagLibClass -import grails.util.GrailsNameUtils -import grails.web.mvc.FlashScope -import grails.web.servlet.mvc.GrailsParameterMap -import groovy.text.Template -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import groovy.util.logging.Slf4j -import org.grails.buffer.GrailsPrintWriter -import org.grails.commons.CodecArtefactHandler -import org.grails.commons.DefaultGrailsCodecClass -import org.grails.core.artefact.ControllerArtefactHandler -import org.grails.core.artefact.gsp.TagLibArtefactHandler -import org.grails.gsp.GroovyPagesTemplateEngine -import org.grails.plugins.codecs.DefaultCodecLookup -import org.grails.plugins.testing.GrailsMockHttpServletRequest -import org.grails.plugins.testing.GrailsMockHttpServletResponse -import org.grails.taglib.TagLibraryLookup -import org.grails.testing.GrailsUnitTest -import org.grails.web.servlet.mvc.GrailsWebRequest -import org.grails.web.util.GrailsApplicationAttributes -import org.springframework.mock.web.MockHttpSession -import org.springframework.mock.web.MockServletContext - -@CompileStatic -@Slf4j -trait GrailsWebUnitTest implements GrailsUnitTest { - - private Set loadedCodecs = new HashSet() - static Map groovyPages = [:] - GrailsWebRequest webRequest - - GrailsMockHttpServletRequest getRequest() { - return (GrailsMockHttpServletRequest) getWebRequest().getCurrentRequest() - } - - GrailsMockHttpServletResponse getResponse() { - return (GrailsMockHttpServletResponse) getWebRequest().getCurrentResponse() - } - - MockServletContext getServletContext() { - (MockServletContext)optionalServletContext - } - - Map getViews() { - groovyPages - } - - /** - * The {@link org.springframework.mock.web.MockHttpSession} instance - */ - MockHttpSession getSession() { - (MockHttpSession) request.session - } - - /** - * @return The status code of the response - */ - int getStatus() { - response.status - } - - /** - * The Grails 'params' object which is an instance of {@link grails.web.servlet.mvc.GrailsParameterMap} - */ - GrailsParameterMap getParams() { - webRequest.getParams() - } - - /** - * The Grails 'flash' object - * @return - */ - FlashScope getFlash() { - webRequest.getFlashScope() - } - - @CompileDynamic - Object mockTagLib(Class tagLibClass) { - GrailsTagLibClass tagLib = grailsApplication.addArtefact(TagLibArtefactHandler.TYPE, tagLibClass) - final tagLookup = applicationContext.getBean(TagLibraryLookup) - - - defineBeans { - "${tagLib.fullName}"(tagLibClass) { bean -> - bean.autowire = true - } - } - - tagLookup.registerTagLib(tagLib) - - def taglibObject = applicationContext.getBean(tagLib.fullName) - if(taglibObject instanceof TagLibrary) { - ((TagLibrary)taglibObject).setTagLibraryLookup(tagLookup) - } - taglibObject - } - - @CompileDynamic - Object mockController(Class controllerClass) { - createAndEnhanceController(controllerClass) - defineBeans { - "$controllerClass.name"(controllerClass) { bean -> - bean.scope = 'prototype' - bean.autowire = true - } - } - - def controller = applicationContext.getBean(controllerClass.name) - - if (webRequest == null) { - throw new IllegalAccessException("Cannot access the controller outside of a request. Is the controller referenced in a where: block?") - } - - webRequest.request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controller) - webRequest.controllerName = GrailsNameUtils.getLogicalPropertyName(controller.class.name, ControllerArtefactHandler.TYPE) - - controller - } - - private GrailsClass createAndEnhanceController(Class controllerClass) { - final GrailsControllerClass controllerArtefact = (GrailsControllerClass) grailsApplication.addArtefact(ControllerArtefactHandler.TYPE, controllerClass) - controllerArtefact.initialize() - return controllerArtefact - } - - - void mockTagLibs(Class... tagLibClasses) { - for(Class c : tagLibClasses) { - mockTagLib c - } - } - - void mockCodec(Class codecClass, boolean reinitialize = true) { - if (loadedCodecs.contains(codecClass)) { - return - } - loadedCodecs << codecClass - DefaultGrailsCodecClass grailsCodecClass = new DefaultGrailsCodecClass(codecClass) - grailsCodecClass.configureCodecMethods() - grailsApplication.addArtefact(CodecArtefactHandler.TYPE, grailsCodecClass) - if (reinitialize) { - applicationContext.getBean(DefaultCodecLookup).reInitialize() - } - } - - /** - * Mimics the behavior of the render method in controllers but returns the rendered contents directly - * - * @param args The same arguments as the controller render method accepts - * @return The resulting rendering GSP - */ - String render(Map args) { - String uri = null - Map model - if (args.containsKey('model')) { - model = (Map)args.model - } else { - model = [:] - } - final attributes = webRequest.attributes - if (args.template) { - uri = attributes.getTemplateUri(args.template as String, request) - } - else if (args.view) { - uri = attributes.getViewUri(args.view as String, request) - } - if (uri != null) { - GroovyPagesTemplateEngine engine = applicationContext.getBean(GroovyPagesTemplateEngine) - final Template t = engine.createTemplate(uri) - if (t != null) { - def sw = new StringWriter() - renderTemplateToStringWriter(sw, t, model) - return sw.toString() - } - } - return null - } - - /** - * Renders a template for the given contents and model - * - * @param contents The contents - * @param model The model - * @return The rendered template - */ - String applyTemplate(String contents, Map model = [:]) { - def sw = new StringWriter() - applyTemplate sw, contents, model - return sw.toString() - } - - /** - * Renders a template for the given contents and model to the provided writer - * - * @param sw The write to write the rendered template to - * @param contents The contents - * @param model The model - */ - void applyTemplate(StringWriter sw, String template, Map params = [:]) { - def engine = applicationContext.getBean(GroovyPagesTemplateEngine) - - def t = engine.createTemplate(template, "test_" + System.currentTimeMillis()) - renderTemplateToStringWriter(sw, t, params) - } - - private renderTemplateToStringWriter(StringWriter sw, Template t, Map params) { - if (!webRequest.controllerName) { - webRequest.controllerName = 'test' - } - if (!webRequest.actionName) { - webRequest.actionName = 'index' - } - def w = t.make(params) - def previousOut = webRequest.out - try { - def out = new GrailsPrintWriter(sw) - webRequest.out = out - w.writeTo(out) - - } - finally { - webRequest.out = previousOut - } - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/UrlMappingsUnitTest.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/UrlMappingsUnitTest.groovy deleted file mode 100644 index deb88af5..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/UrlMappingsUnitTest.groovy +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.web - -import grails.core.GrailsControllerClass -import grails.web.UrlConverter -import grails.web.mapping.UrlCreator -import grails.web.mapping.UrlMappingInfo -import grails.web.mapping.UrlMappingsHolder -import groovy.transform.CompileDynamic -import junit.framework.AssertionFailedError -import org.grails.core.artefact.ControllerArtefactHandler -import org.grails.core.artefact.UrlMappingsArtefactHandler -import org.grails.gsp.GroovyPagesTemplateEngine -import org.grails.testing.ParameterizedGrailsUnitTest -import org.grails.web.mapping.UrlMappingsHolderFactoryBean -import org.grails.web.mapping.mvc.GrailsControllerUrlMappingInfo -import junit.framework.ComparisonFailure - -import static junit.framework.Assert.assertEquals -import static junit.framework.Assert.assertNotNull - -trait UrlMappingsUnitTest implements ParameterizedGrailsUnitTest, GrailsWebUnitTest { - - public static final String KEY_EXCEPTION = 'exception' - private final List assertionKeys = ["controller", "action", "view"] - - Class[] getControllersToMock() { - [] - } - - void configuredMockedControllers() { - for(Class c : controllersToMock) { - final GrailsControllerClass controllerArtefact = (GrailsControllerClass)grailsApplication.addArtefact(ControllerArtefactHandler.TYPE, c) - controllerArtefact.initialize() - defineBeans { - "$controllerArtefact.name"(c) { bean -> - bean.scope = 'prototype' - bean.autowire = true - } - } - } - getArtefactInstance() - } - - /** - * @return The {@link UrlMappingsHolder} bean - */ - UrlMappingsHolder getUrlMappingsHolder() { - applicationContext.getBean("grailsUrlMappingsHolder", UrlMappingsHolder) - } - - /** - * Maps a URI and returns the appropriate controller instance - * - * @param uri The URI to map - * @return The controller instance - */ - Object mapURI(String uri) { - UrlMappingsHolder mappingsHolder = getUrlMappingsHolder() - - UrlMappingInfo[] mappingInfos = mappingsHolder.matchAll(uri, request.method) - for (UrlMappingInfo info in mappingInfos) { - def backupParams = new HashMap(webRequest.params) - info.configure(webRequest) - - webRequest.params.putAll(backupParams) - if (info.viewName == null && info.URI == null) { - if(info instanceof GrailsControllerUrlMappingInfo) { - def controller = info.controllerClass - if (controller != null) { - return applicationContext.getBean(controller.name) - } - } - } - } - } - - private boolean checkController(String controller, boolean throwEx) { - final controllerClass = getControllerClass(controller) - if (!controllerClass && throwEx) { - throw new AssertionFailedError("Url mapping assertion failed, '$controller' is not a valid controller") - } - return controllerClass != null - } - - /** - * asserts a controller exists for the specified name and url - * - * @param controller The controller name - * @param url The url - */ - void assertController(String controller) { - checkController(controller, true) - } - - /** - * @param controller The controller name - * @param url The url - * @return true If a controller exists for the specified name and url - */ - boolean verifyController(String controller) { - checkController(controller, false) - } - - private boolean checkAction(String controller, String action, boolean throwEx) { - final controllerClass = getControllerClass(controller) - boolean valid = controllerClass?.mapsToURI("/$controller/$action") - if (!valid && throwEx) { - throw new AssertionFailedError("Url mapping assertion failed, '$action' is not a valid action of controller '$controller'") - } - valid - } - - /** - * Asserts an action exists for the specified controller name, action name and url - * - * @param controller The controller name - * @param action The action name - */ - void assertAction(String controller, String action) { - checkAction(controller, action, true) - } - - /** - * @param controller The controller name - * @param action The action name - * @return true If an action exists for the specified controller name and action name - */ - boolean verifyAction(String controller, String action) { - checkAction(controller, action, false) - } - - private boolean checkView(String controller, String view, boolean throwEx) { - def pathPattern = ((controller) ? "$controller/" : "") + "${view}.gsp" - if (!pathPattern.startsWith('/')) { - pathPattern = "/$pathPattern" - } - GroovyPagesTemplateEngine templateEngine = applicationContext.getBean("groovyPagesTemplateEngine", GroovyPagesTemplateEngine) - - def t = templateEngine.createTemplate(pathPattern) - if (!t && throwEx) { - throw new AssertionFailedError( - (controller) ? "Url mapping assertion failed, '$view' is not a valid view of controller '$controller'" : "Url mapping assertion failed, '$view' is not a valid view") - } - t != null - } - - /** - * Asserts a view exists for the specified controller name and view name - * - * @param controller The controller name - * @param view The view name - */ - void assertView(String controller, String view) { - checkView(controller, view, true) - } - - /** - * - * @param controller The controller name - * @param view The view name - * @param url The url - * @return true If a view exists for the specified controller and view - */ - boolean verifyView(String controller, String view) { - checkView(controller, view, false) - } - - - /** - * Asserts a URL mapping maps to the specified controller, action, and optionally also parameters. Example: - * - *
-     * 
-     *           assertUrlMapping("/action1", controller: "grailsUrlMappingsTestCaseFake", action: "action1") {
-     *              param1 = "value1"
-     *              param2 = "value2"
-     *           }
-     * 
-     * 
- * @param assertions The assertions as named parameters - * @param url The URL as a string - * @param paramAssertions The parameters to assert defined in the body of the closure - */ - void assertUrlMapping(Map assertions, String url, Closure paramAssertions = null) { - assertForwardUrlMapping(assertions, url, paramAssertions) - if (assertions.controller && !(url instanceof Integer)) { - assertReverseUrlMapping(assertions, url, paramAssertions) - } - } - - /** - * Verifies a URL mapping maps to the specified controller, action, and optionally also parameters. Example: - * - *
-     * 
-     *           verifyUrlMapping("/action1", controller: "grailsUrlMappingsTestCaseFake", action: "action1") {
-     *              param1 = "value1"
-     *              param2 = "value2"
-     *           }
-     * 
-     * 
- * @param assertions The assertions as named parameters - * @param url The URL as a string - * @param paramAssertions The parameters to assert defined in the body of the closure - * - * @return True if the url matches the assertions - */ - boolean verifyUrlMapping(Map assertions, String url, Closure paramAssertions = null) { - boolean returnValue = verifyForwardUrlMapping(assertions, url, paramAssertions) - if (assertions.controller && !(url instanceof Integer)) { - returnValue = returnValue && verifyReverseUrlMapping(assertions, url, paramAssertions) - } - returnValue - } - - private boolean checkForwardUrlMapping(Map assertions, Object url, Closure paramAssertions, boolean throwEx) { - - UrlMappingsHolder mappingsHolder = getUrlMappingsHolder() - if (assertions.action && !assertions.controller) { - throw new IllegalArgumentException("Cannot assert action for url mapping without asserting controller") - } - - if (assertions.controller) { - if (!checkController((String)assertions.controller, throwEx)) { - return false - } - } - if (assertions.action) { - if (!checkAction((String)assertions.controller, (String)assertions.action, throwEx)) { - return false - } - } - if (assertions.view) { - if (!checkView((String) assertions.controller, (String) assertions.view, throwEx)) { - return false - } - } - - List mappingInfos - if (url instanceof Integer) { - mappingInfos = [] - def mapping - if (assertions."$KEY_EXCEPTION") { - mapping = mappingsHolder.matchStatusCode(url, assertions."$KEY_EXCEPTION" as Throwable) - } else { - mapping = mappingsHolder.matchStatusCode(url) - } - if (mapping) mappingInfos << mapping - } - else { - mappingInfos = mappingsHolder.matchAll((String)url, request.method).toList() - } - - if (mappingInfos.size() == 0) { - if (throwEx) { - throw new AssertionFailedError("url '$url' did not match any mappings") - } else { - return false - } - } - - boolean returnVal = true - - def mappingMatched = mappingInfos.any {mapping -> - mapping.configure(webRequest) - for (key in assertionKeys) { - if (assertions.containsKey(key)) { - String expected = (String)assertions[key] - String actual = mapping."${key}Name" - - switch (key) { - case "controller": - if (actual && !getControllerClass(actual)) return false - break - case "view": - if (actual[0] == "/") actual = actual.substring(1) - if (expected[0] == "/") expected = expected.substring(1) - break - case "action": - if (key == "action" && actual == null) { - final controllerClass = getControllerClass(assertions.controller) - actual = controllerClass?.defaultAction - } - break - } - - if (expected != actual) { - if (throwEx) { - throw new ComparisonFailure("Url mapping $key assertion for '$url' failed".toString(), expected, actual) - } else { - returnVal = false - } - } - } - } - if (paramAssertions) { - def params = [:] - paramAssertions.delegate = params - paramAssertions.resolveStrategy = Closure.DELEGATE_ONLY - paramAssertions.call() - params.each {name, value -> - String actual = mapping.parameters[name] - String expected = value - - if (expected != actual) { - if (throwEx) { - throw new ComparisonFailure("Url mapping $name assertion for '$url' failed".toString(), expected, actual) - } else { - returnVal = false - } - } - } - } - - return true - } - - if (!mappingMatched) throw new IllegalArgumentException("url '$url' did not match any mappings") - - returnVal - } - - void assertForwardUrlMapping(Map assertions, Object url, Closure paramAssertions = null) { - checkForwardUrlMapping(assertions, url, paramAssertions, true) - } - - boolean verifyForwardUrlMapping(Map assertions, Object url, Closure paramAssertions = null) { - checkForwardUrlMapping(assertions, url, paramAssertions, false) - } - - - private boolean checkReverseUrlMapping(Map assertions, String url, Closure paramAssertions, boolean throwEx) { - UrlMappingsHolder mappingsHolder = applicationContext.getBean("grailsUrlMappingsHolder", UrlMappingsHolder) - UrlConverter urlConverter = applicationContext.getBean(UrlConverter.BEAN_NAME, UrlConverter) - def controller = assertions.controller - def action = assertions.action - def method = assertions.method - def plugin = assertions.plugin - def namespace = assertions.namespace - - String convertedControllerName = null, convertedActionName = null - - if(controller) convertedControllerName = urlConverter.toUrlElement(controller) ?: controller - if(action) convertedActionName = urlConverter.toUrlElement(action) ?: action - - def params = [:] - if (paramAssertions) { - paramAssertions.delegate = params - paramAssertions.resolveStrategy = Closure.DELEGATE_ONLY - paramAssertions.call() - } - UrlCreator urlCreator = mappingsHolder.getReverseMapping(controller, action, namespace, plugin, method, params) - if (urlCreator == null) { - if (throwEx) { - throw new AssertionFailedError("could not create reverse mapping of '$url' for {controller = $controller, action = $action, params = $params}") - } else { - return false - } - } - String createdUrl = urlCreator.createRelativeURL(convertedControllerName, convertedActionName, params, "UTF-8") - - if (url != createdUrl) { - if (throwEx) { - throw new ComparisonFailure("reverse mapping assertion for {controller = $controller, action = $action, params = $params}", url, createdUrl) - } else { - return false - } - } - true - } - - /** - * Asserts the given controller and action produce the given reverse URL mapping - * - *
-     * 
-     *           assertReverseUrlMapping("/action1", controller: "grailsUrlMappingsTestCaseFake", action: "action1")
-     * 
-     * 
- * @param assertions The assertions as named parameters - * @param url The URL as a string - * @param paramAssertions The parameters to assert defined in the body of the closure - */ - void assertReverseUrlMapping(Map assertions, String url, Closure paramAssertions = null) { - checkReverseUrlMapping(assertions, url, paramAssertions, true) - } - - /** - * Asserts the given controller and action produce the given reverse URL mapping - * - *
-     * 
-     *           verifyReverseUrlMapping("/action1", controller: "grailsUrlMappingsTestCaseFake", action: "action1")
-     * 
-     * 
- * @param assertions The assertions as named parameters - * @param url The URL as a string - * @param paramAssertions The parameters to assert defined in the body of the closure - * - * @return True if the url matches the assertions - */ - boolean verifyReverseUrlMapping(Map assertions, String url, Closure paramAssertions = null) { - checkReverseUrlMapping(assertions, url, paramAssertions, false) - } - - GrailsControllerClass getControllerClass(String controller) { - (GrailsControllerClass)grailsApplication.getArtefactByLogicalPropertyName(ControllerArtefactHandler.TYPE, controller) - } - - @CompileDynamic - void mockArtefact(Class urlMappingsClass) { - grailsApplication.addArtefact(UrlMappingsArtefactHandler.TYPE, urlMappingsClass) - - defineBeans { - grailsUrlMappingsHolder(UrlMappingsHolderFactoryBean) { - getDelegate().grailsApplication = grailsApplication - } - } - } - - String getBeanName(Class urlMappingsClass) { - null - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/controllers/ControllerUnitTest.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/controllers/ControllerUnitTest.groovy deleted file mode 100755 index 06bca801..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/controllers/ControllerUnitTest.groovy +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.web.controllers - -import grails.testing.web.GrailsWebUnitTest -import grails.web.mime.MimeType -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import org.grails.testing.ParameterizedGrailsUnitTest -import org.grails.web.pages.GroovyPagesUriSupport -import org.grails.web.servlet.mvc.GrailsWebRequest -import org.grails.web.util.GrailsApplicationAttributes -import javassist.util.proxy.ProxyFactory -import org.grails.testing.runtime.support.ActionSettingMethodHandler - -@CompileStatic -trait ControllerUnitTest implements ParameterizedGrailsUnitTest, GrailsWebUnitTest { - - static String FORM_CONTENT_TYPE = MimeType.FORM.name - static String MULTIPART_FORM_CONTENT_TYPE = MimeType.MULTIPART_FORM.name - static String ALL_CONTENT_TYPE = MimeType.ALL.name - static String HTML_CONTENT_TYPE = MimeType.HTML.name - static String XHTML_CONTENT_TYPE = MimeType.XHTML.name - static String XML_CONTENT_TYPE = MimeType.XML.name - static String JSON_CONTENT_TYPE = MimeType.JSON.name - static String TEXT_XML_CONTENT_TYPE = MimeType.TEXT_XML.name - static String TEXT_JSON_CONTENT_TYPE = MimeType.TEXT_JSON.name - static String HAL_JSON_CONTENT_TYPE = MimeType.HAL_JSON.name - static String HAL_XML_CONTENT_TYPE = MimeType.HAL_XML.name - static String ATOM_XML_CONTENT_TYPE = MimeType.ATOM_XML.name - - private T _proxyInstance - - /** - * @return The model of the current controller - */ - @CompileStatic(TypeCheckingMode.SKIP) - Map getModel() { - Map model = request.getAttribute(GrailsApplicationAttributes.CONTROLLER)?.modelAndView?.model - if (model == null) { - model = request.getAttribute(GrailsApplicationAttributes.TEMPLATE_MODEL) - } - return model ?: [:] - } - - /** - * @return The view of the current controller - */ - @CompileStatic(TypeCheckingMode.SKIP) - String getView() { - final controller = request.getAttribute(GrailsApplicationAttributes.CONTROLLER) - - final viewName = controller?.modelAndView?.viewName - if (viewName != null) { - return viewName - } - - if (webRequest.controllerName && webRequest.actionName) { - new GroovyPagesUriSupport().getViewURI(webRequest.controllerName, webRequest.actionName) - } else { - return null - } - } - - /** - * Mocks a Grails controller class, providing the needed behavior and defining it in the ApplicationContext - * - * @param controllerClass The controller class - * @return An instance of the controller - */ - void mockArtefact(Class controllerClass) { - mockController(controllerClass) - } - - String getBeanName(Class controllerClass) { - controllerClass.name - } - - boolean disableControllerProxy() { - false - } - - T getController() { - if (disableControllerProxy()) { - getArtefactInstance() - } - else { - if (_proxyInstance == null) { - T artefact = getArtefactInstance() - ProxyFactory factory = new ProxyFactory() - factory.setSuperclass(getTypeUnderTest()) - _proxyInstance = (T)factory.create(new Class[0], new Object[0], new ActionSettingMethodHandler(artefact, getWebRequest())) - } - _proxyInstance - } - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/interceptor/InterceptorUnitTest.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/interceptor/InterceptorUnitTest.groovy deleted file mode 100644 index af981c20..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/interceptor/InterceptorUnitTest.groovy +++ /dev/null @@ -1,138 +0,0 @@ -package grails.testing.web.interceptor - -import grails.artefact.Interceptor -import grails.core.GrailsClass -import grails.testing.web.GrailsWebUnitTest -import grails.util.GrailsNameUtils -import grails.web.mapping.UrlMappingInfo -import groovy.transform.CompileDynamic -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import org.grails.plugins.web.interceptors.GrailsInterceptorHandlerInterceptorAdapter -import org.grails.plugins.web.interceptors.InterceptorArtefactHandler -import org.grails.testing.ParameterizedGrailsUnitTest -import org.grails.web.mapping.ForwardUrlMappingInfo -import org.grails.web.mapping.mvc.UrlMappingsHandlerMapping -import org.grails.web.util.GrailsApplicationAttributes -import org.springframework.web.servlet.ModelAndView - -import java.lang.reflect.ParameterizedType - -@CompileStatic -trait InterceptorUnitTest implements ParameterizedGrailsUnitTest, GrailsWebUnitTest { - - private boolean hasBeenMocked = false - - /** - * Mock the interceptor for the given name - * - * @param interceptorClass The interceptor class - * @return The mocked interceptor - */ - @CompileDynamic - Interceptor mockInterceptor(Class interceptorClass) { - GrailsClass artefact = grailsApplication.addArtefact(InterceptorArtefactHandler.TYPE, interceptorClass) - defineBeans { - "${artefact.propertyName}"(artefact.clazz) { bean -> - bean.autowire = true - } - } - getHandlerInterceptor() - .setInterceptors( applicationContext.getBeansOfType(Interceptor).values() as Interceptor[] ) - (Interceptor)applicationContext.getBean(artefact.propertyName, interceptorClass) - } - - /** - * Execute the given request with the registered interceptors - * - * @param arguments The arguments - * @param callable A callable containing an invocation of a controller action - * @return The result of the callable execution - */ - Object withInterceptors(Map arguments, Closure callable) { - ensureInterceptorHasBeenMocked() - UrlMappingInfo info = withRequest(arguments) - - def hi = getHandlerInterceptor() - - try { - if( hi.preHandle(request, response, this) ) { - def result = callable.call() - ModelAndView modelAndView = null - def modelAndViewObject = request.getAttribute(GrailsApplicationAttributes.MODEL_AND_VIEW) - if(modelAndViewObject instanceof ModelAndView) { - modelAndView = (ModelAndView) modelAndViewObject - } - else if(result instanceof Map) { - modelAndView = new ModelAndView(info?.actionName ?: 'index', new HashMap((Map)result)) - } - else if(result instanceof ModelAndView) { - return (ModelAndView) result - } - hi.postHandle(request, response,this, modelAndView) - return result - } - } catch (Exception e) { - hi.afterCompletion(request, response, this, e) - } - } - - /** - * Allows testing of the interceptor directly by setting up an incoming request that can be matched prior to invoking the - * interceptor - * - * @param arguments Named arguments specifying the controller/action or URI that interceptor should match - * - * @return The {@link UrlMappingInfo} object - */ - @CompileStatic(TypeCheckingMode.SKIP) - UrlMappingInfo withRequest(Map arguments) { - ensureInterceptorHasBeenMocked() - UrlMappingInfo info = null - if (arguments.uri) { - request.requestURI = arguments.uri.toString() - } else { - info = new ForwardUrlMappingInfo(arguments) - request.setAttribute(UrlMappingsHandlerMapping.MATCHED_REQUEST, info) - } - - for(String name in request.attributeNames.findAll() { String n -> n.endsWith(InterceptorArtefactHandler.MATCH_SUFFIX)}) { - request.removeAttribute(name) - } - info - } - - private GrailsInterceptorHandlerInterceptorAdapter getHandlerInterceptor() { - applicationContext.getBean(GrailsInterceptorHandlerInterceptorAdapter) - } - - void mockArtefact(Class interceptorClass) { - mockInterceptor((Class)interceptorClass) - } - - String getBeanName(Class interceptorClass) { - GrailsNameUtils.getPropertyName(interceptorClass) - } - - private Class getInterceptorTypeUnderTest() { - ParameterizedType parameterizedType = (ParameterizedType)getClass().genericInterfaces.find { genericInterface -> - genericInterface instanceof ParameterizedType && - InterceptorUnitTest.isAssignableFrom((Class)((ParameterizedType)genericInterface).rawType) - } - - parameterizedType?.actualTypeArguments[0] - } - - T getInterceptor() { - ensureInterceptorHasBeenMocked() - getArtefactInstance() - } - - - private void ensureInterceptorHasBeenMocked() { - if(!hasBeenMocked) { - mockInterceptor getInterceptorTypeUnderTest() - hasBeenMocked = true - } - } -} \ No newline at end of file diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/taglib/TagLibUnitTest.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/taglib/TagLibUnitTest.groovy deleted file mode 100644 index eec8a2c5..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/grails/testing/web/taglib/TagLibUnitTest.groovy +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package grails.testing.web.taglib - -import grails.testing.web.GrailsWebUnitTest -import groovy.transform.CompileStatic -import org.grails.testing.ParameterizedGrailsUnitTest - -import java.lang.reflect.ParameterizedType - -@CompileStatic -trait TagLibUnitTest implements ParameterizedGrailsUnitTest, GrailsWebUnitTest { - - private boolean hasBeenMocked = false - - /** - * Renders a template for the given contents and model - * - * @param contents The contents - * @param model The model - * @return The rendered template - */ - String applyTemplate(String contents, Map model = [:]) { - ensureTaglibHasBeenMocked() - super.applyTemplate(contents, model) - } - - void applyTemplate(StringWriter sw, String template, Map params = [:]) { - ensureTaglibHasBeenMocked() - super.applyTemplate(sw, template, params) - } - - /** - * Mocks a tag library, making it available to subsequent calls to controllers mocked via - * {@link #mockArtefact(Class) } and GSPs rendered via {@link #applyTemplate(String, Map) } - * - * @param tagLibClass The tag library class - * @return The tag library instance - */ - void mockArtefact(Class tagLibClass) { - mockTagLib tagLibClass - } - - String getBeanName(Class tagLibClass) { - tagLibClass.name - } - - private Class getTagLibTypeUnderTest() { - ParameterizedType parameterizedType = (ParameterizedType)getClass().genericInterfaces.find { genericInterface -> - genericInterface instanceof ParameterizedType && - TagLibUnitTest.isAssignableFrom((Class)((ParameterizedType)genericInterface).rawType) - } - - parameterizedType?.actualTypeArguments[0] - } - - T getTagLib() { - ensureTaglibHasBeenMocked() - getArtefactInstance() - } - - - private void ensureTaglibHasBeenMocked() { - if(!hasBeenMocked) { - mockTagLib getTagLibTypeUnderTest() - hasBeenMocked = true - } - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/ActionSettingMethodHandler.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/ActionSettingMethodHandler.groovy deleted file mode 100644 index a01a141e..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/ActionSettingMethodHandler.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package org.grails.testing.runtime.support - -import grails.web.Action -import groovy.transform.CompileStatic -import javassist.util.proxy.MethodHandler -import org.grails.web.servlet.mvc.GrailsWebRequest - -import java.lang.reflect.InvocationTargetException -import java.lang.reflect.Method - -@CompileStatic -class ActionSettingMethodHandler implements MethodHandler { - - GrailsWebRequest request - Object controller - - ActionSettingMethodHandler(Object controller, GrailsWebRequest request) { - this.request = request - this.controller = controller - } - - @Override - Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { - if (thisMethod.getAnnotation(Action) != null) { - request.setActionName(thisMethod.name) - } - try { - thisMethod.accessible = true - thisMethod.invoke(controller, args) - } catch (InvocationTargetException e) { - throw e.cause ?: e - } - } -} \ No newline at end of file diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/GroovyPageUnitTestResourceLoader.java b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/GroovyPageUnitTestResourceLoader.java deleted file mode 100644 index 7c396b5e..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/GroovyPageUnitTestResourceLoader.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.grails.testing.runtime.support; - -import grails.config.Config; -import grails.config.Settings; -import grails.core.GrailsApplication; -import grails.core.support.GrailsApplicationAware; -import grails.util.BuildSettings; -import groovy.transform.CompileStatic; -import org.grails.io.support.GrailsResourceUtils; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.io.ByteArrayResource; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * A {@link org.springframework.core.io.ResourceLoader} implementation - * that loads GSP views relative to the project base directory for unit tests. - * - */ -@CompileStatic -public class GroovyPageUnitTestResourceLoader extends DefaultResourceLoader implements GrailsApplicationAware, InitializingBean { - - public static final String WEB_INF_PREFIX = "/WEB-INF/grails-app/views"; - private Map groovyPages = new ConcurrentHashMap(); - private String basePath; - private GrailsApplication grailsApplication; - - public GroovyPageUnitTestResourceLoader(Map groovyPages) { - this.groovyPages = groovyPages; - } - - @Override - public Resource getResource(String location) { - - if (location.startsWith(WEB_INF_PREFIX)) { - location = location.substring(WEB_INF_PREFIX.length()); - } - if (groovyPages.containsKey(location)) { - return new ByteArrayResource(groovyPages.get(location).getBytes(StandardCharsets.UTF_8), location); - } - - if(basePath == null) { - String basedir = BuildSettings.BASE_DIR.getAbsolutePath(); - basePath = basedir + File.separatorChar + GrailsResourceUtils.VIEWS_DIR_PATH; - } - - String path = basePath + location; - path = makeCanonical(path); - return new FileSystemResource(path); - } - - private String makeCanonical(String path) { - try { - return new File(path).getCanonicalPath(); - } catch (IOException e) { - return path; - } - } - - @Override - public void setGrailsApplication(GrailsApplication grailsApplication) { - this.grailsApplication = grailsApplication; - } - - @Override - public void afterPropertiesSet() throws Exception { - if(grailsApplication != null) { - Config config = grailsApplication.getConfig(); - String viewDir = config.getProperty(Settings.GSP_VIEWS_DIR); - if(viewDir != null) { - basePath = viewDir; - } - } - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/LazyTagLibraryLookup.java b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/LazyTagLibraryLookup.java deleted file mode 100644 index c164867d..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/runtime/support/LazyTagLibraryLookup.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.grails.testing.runtime.support; - -import grails.core.GrailsTagLibClass; -import groovy.lang.GroovyObject; -import org.grails.plugins.web.GroovyPagesGrailsPlugin; -import org.grails.taglib.TagLibraryLookup; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.GenericBeanDefinition; -import org.springframework.context.support.GenericApplicationContext; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Lazy implementation of the tag library lookup class designed for testing purposes. - * - */ -@SuppressWarnings({"unchecked", "rawtypes"}) -public class LazyTagLibraryLookup extends TagLibraryLookup { - List tagLibClasses = (List) new GroovyPagesGrailsPlugin().getProvidedArtefacts(); - private Map lazyLoadableTagLibs = new HashMap(); - - @Override - protected void registerTagLibraries() { - super.registerTagLibraries(); - for (Class providedArtefact : tagLibClasses) { - registerLazyLoadableTagLibClass(providedArtefact); - } - } - - public void registerLazyLoadableTagLibClass(Class tagLibClass) { - Class defaultTagLibClass = null; - GrailsTagLibClass grailsTagLibClass = null; - try { - defaultTagLibClass = Class.forName("org.grails.core.gsp.DefaultGrailsTagLibClass"); - } catch (ClassNotFoundException e) { - try { - defaultTagLibClass = Class.forName("org.grails.core.DefaultGrailsTagLibClass"); - } catch (ClassNotFoundException f) { - } - } - - try { - grailsTagLibClass = (GrailsTagLibClass)defaultTagLibClass.getConstructor(Class.class).newInstance(tagLibClass); - } catch (Exception e) { - } - - if (!hasNamespace(grailsTagLibClass.getNamespace())) { - registerNamespaceDispatcher(grailsTagLibClass.getNamespace()); - } - for (String tagName : grailsTagLibClass.getTagNames()) { - String tagKey = tagNameKey(grailsTagLibClass.getNamespace(), tagName); - lazyLoadableTagLibs.put(tagKey, grailsTagLibClass); - } - } - - @Override - public GroovyObject lookupTagLibrary(String namespace, String tagName) { - GroovyObject tagLibrary = super.lookupTagLibrary(namespace, tagName); - if (tagLibrary == null) { - String tagKey = tagNameKey(namespace, tagName); - GrailsTagLibClass taglibClass = lazyLoadableTagLibs.get(tagKey); - if (taglibClass != null) { - if (!applicationContext.containsBean(taglibClass.getFullName())) { - GenericBeanDefinition bd = new GenericBeanDefinition(); - bd.setBeanClass(taglibClass.getClazz()); - bd.setAutowireCandidate(true); - bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME); - ((GenericApplicationContext) applicationContext).getDefaultListableBeanFactory().registerBeanDefinition(taglibClass.getFullName(), bd); - } - registerTagLib(taglibClass); - tagLibrary = super.lookupTagLibrary(namespace, tagName); - } - } - return tagLibrary; - } - - protected String tagNameKey(String namespace, String tagName) { - return namespace + ':' + tagName; - } - - @Override - protected void putTagLib(Map tags, String name, grails.core.GrailsTagLibClass taglib) { - if (applicationContext.containsBean(taglib.getFullName())) { - super.putTagLib(tags, name, taglib); - } - } -} \ No newline at end of file diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/InterceptorSetupSpecInterceptor.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/InterceptorSetupSpecInterceptor.groovy deleted file mode 100644 index 8883037d..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/InterceptorSetupSpecInterceptor.groovy +++ /dev/null @@ -1,26 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.web.interceptor.InterceptorUnitTest -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import org.grails.plugins.web.interceptors.GrailsInterceptorHandlerInterceptorAdapter -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class InterceptorSetupSpecInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - InterceptorUnitTest test = (InterceptorUnitTest)invocation.instance - setup(test) - invocation.proceed() - } - - @CompileStatic(TypeCheckingMode.SKIP) - void setup(InterceptorUnitTest test) { - test.defineBeans { - grailsInterceptorHandlerInterceptorAdapter(GrailsInterceptorHandlerInterceptorAdapter) - } - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/UrlMappingSetupSpecInterceptor.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/UrlMappingSetupSpecInterceptor.groovy deleted file mode 100644 index 42f82e7f..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/UrlMappingSetupSpecInterceptor.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.web.UrlMappingsUnitTest -import groovy.transform.CompileStatic -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class UrlMappingSetupSpecInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - ((UrlMappingsUnitTest)invocation.instance).configuredMockedControllers() - invocation.proceed() - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebCleanupInterceptor.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebCleanupInterceptor.groovy deleted file mode 100644 index 40c38ebc..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebCleanupInterceptor.groovy +++ /dev/null @@ -1,38 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.web.GrailsWebUnitTest -import groovy.transform.CompileStatic -import org.grails.gsp.GroovyPagesTemplateEngine -import org.grails.web.gsp.GroovyPagesTemplateRenderer -import org.grails.web.servlet.mvc.GrailsWebRequest -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation -import org.springframework.web.context.request.RequestContextHolder - -@CompileStatic -class WebCleanupInterceptor implements IMethodInterceptor { - - public static final String GROOVY_PAGES_TEMPLATE_ENGINE = "groovyPagesTemplateEngine" - public static final String GROOVY_PAGES_TEMPLATE_RENDERER = "groovyPagesTemplateRenderer" - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - GrailsWebUnitTest test = (GrailsWebUnitTest)invocation.instance - cleanup(test) - invocation.proceed() - } - - void cleanup(GrailsWebUnitTest test) { - test.views.clear() - RequestContextHolder.resetRequestAttributes() - GrailsWebRequest webRequest = test.webRequest - def ctx = webRequest?.applicationContext - if (ctx?.containsBean(GROOVY_PAGES_TEMPLATE_ENGINE)) { - ctx.getBean(GROOVY_PAGES_TEMPLATE_ENGINE, GroovyPagesTemplateEngine).clearPageCache() - } - if (ctx?.containsBean(GROOVY_PAGES_TEMPLATE_RENDERER)) { - ctx.getBean(GROOVY_PAGES_TEMPLATE_RENDERER, GroovyPagesTemplateRenderer).clearCache() - } - test.webRequest = null - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebCleanupSpecInterceptor.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebCleanupSpecInterceptor.groovy deleted file mode 100644 index a8d3a4c7..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebCleanupSpecInterceptor.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package org.grails.testing.spock - -import groovy.transform.CompileStatic -import org.grails.web.converters.configuration.ConvertersConfigurationHolder -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -@CompileStatic -class WebCleanupSpecInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - ConvertersConfigurationHolder.clear() - invocation.proceed() - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupInterceptor.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupInterceptor.groovy deleted file mode 100644 index 6d5efa7f..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupInterceptor.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.web.GrailsWebUnitTest -import grails.util.GrailsWebMockUtil -import groovy.transform.CompileStatic -import org.grails.plugins.testing.GrailsMockHttpServletRequest -import org.grails.plugins.testing.GrailsMockHttpServletResponse -import org.grails.web.servlet.mvc.GrailsWebRequest -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation -import org.springframework.web.servlet.DispatcherServlet - -import jakarta.servlet.ServletContext - -@CompileStatic -class WebSetupInterceptor implements IMethodInterceptor { - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - GrailsWebUnitTest test = (GrailsWebUnitTest)invocation.instance - setup(test) - invocation.proceed() - } - - void setup(GrailsWebUnitTest test) { - def applicationContext = test.applicationContext - GrailsMockHttpServletRequest request = new GrailsMockHttpServletRequest((ServletContext)test.servletContext) - request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, applicationContext.getBean('localeResolver')) - request.method = 'GET' - GrailsMockHttpServletResponse response = new GrailsMockHttpServletResponse() - GrailsWebRequest webRequest = GrailsWebMockUtil.bindMockWebRequest(applicationContext, request, response) - test.webRequest = webRequest - } - - -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupSpecInterceptor.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupSpecInterceptor.groovy deleted file mode 100644 index dfc5e834..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebSetupSpecInterceptor.groovy +++ /dev/null @@ -1,150 +0,0 @@ -package org.grails.testing.spock - -import grails.config.Settings -import grails.core.GrailsApplication -import grails.testing.web.GrailsWebUnitTest -import grails.testing.web.controllers.ControllerUnitTest -import grails.web.CamelCaseUrlConverter -import grails.web.HyphenatedUrlConverter -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import org.grails.core.artefact.UrlMappingsArtefactHandler -import org.grails.datastore.gorm.validation.constraints.eval.DefaultConstraintEvaluator -import org.grails.datastore.gorm.validation.constraints.registry.DefaultConstraintRegistry -import org.grails.datastore.mapping.keyvalue.mapping.config.KeyValueMappingContext -import org.grails.gsp.GroovyPagesTemplateEngine -import org.grails.gsp.jsp.TagLibraryResolverImpl -import org.grails.plugins.CodecsGrailsPlugin -import org.grails.plugins.codecs.DefaultCodecLookup -import org.grails.plugins.converters.ConvertersGrailsPlugin -import org.grails.plugins.web.rest.render.DefaultRendererRegistry -import org.grails.testing.runtime.support.GroovyPageUnitTestResourceLoader -import org.grails.testing.runtime.support.LazyTagLibraryLookup -import org.grails.validation.ConstraintEvalUtils -import org.grails.web.gsp.GroovyPagesTemplateRenderer -import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator -import org.grails.web.mapping.DefaultLinkGenerator -import org.grails.web.mapping.UrlMappingsHolderFactoryBean -import org.grails.web.pages.FilteringCodecsByContentTypeSettings -import org.grails.web.servlet.view.CompositeViewResolver -import org.grails.web.servlet.view.GroovyPageViewResolver -import org.grails.web.util.GrailsApplicationAttributes -import org.spockframework.runtime.extension.IMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation -import org.springframework.util.ClassUtils -import org.springframework.web.multipart.support.StandardServletMultipartResolver -import org.springframework.web.servlet.i18n.SessionLocaleResolver - -@CompileStatic -class WebSetupSpecInterceptor implements IMethodInterceptor { - - @Override - void intercept(IMethodInvocation invocation) throws Throwable { - GrailsWebUnitTest test = (GrailsWebUnitTest)invocation.instance - setup(test) - invocation.proceed() - } - - @CompileStatic(TypeCheckingMode.SKIP) - protected void setup(GrailsWebUnitTest test) { - - GrailsApplication grailsApplication = test.grailsApplication - Map groovyPages = test.views - - test.defineBeans(new ConvertersGrailsPlugin()) - - def config = grailsApplication.config - test.defineBeans { - - final classLoader = ControllerUnitTest.class.getClassLoader() - - boolean registerConstraintEvaluator - if (ClassUtils.isPresent("grails.testing.gorm.DataTest", classLoader)) { - Class clazz = classLoader.loadClass("grails.testing.gorm.DataTest") - registerConstraintEvaluator = !clazz.isAssignableFrom(test.class) - } else { - registerConstraintEvaluator = true - } - - if (registerConstraintEvaluator) { - constraintRegistry(DefaultConstraintRegistry, ref("messageSource")) - - "org.grails.beans.ConstraintsEvaluator"(DefaultConstraintEvaluator, constraintRegistry, new KeyValueMappingContext("test"), ConstraintEvalUtils.getDefaultConstraints(grailsApplication.config)) - } - - rendererRegistry(DefaultRendererRegistry) { - modelSuffix = config.getProperty('grails.scaffolding.templates.domainSuffix', '') - } - String urlConverterType = config.getProperty(Settings.WEB_URL_CONVERTER) - "${grails.web.UrlConverter.BEAN_NAME}"('hyphenated' == urlConverterType ? HyphenatedUrlConverter : CamelCaseUrlConverter) - - grailsLinkGenerator(DefaultLinkGenerator, config?.grails?.serverURL ?: "http://localhost:8080") - - if (ClassUtils.isPresent("UrlMappings", classLoader)) { - grailsApplication.addArtefact(UrlMappingsArtefactHandler.TYPE, classLoader.loadClass("UrlMappings")) - } - - def urlMappingsClass = "${config.getProperty('grails.codegen.defaultPackage', 'null')}.UrlMappings" - if (ClassUtils.isPresent(urlMappingsClass, classLoader)) { - grailsApplication.addArtefact(UrlMappingsArtefactHandler.TYPE, classLoader.loadClass(urlMappingsClass)) - } - - try { - Class viewResolver = classLoader.loadClass('grails.plugin.json.view.mvc.JsonViewResolver') - jsonSmartViewResolver(viewResolver) - } catch (ClassNotFoundException e) { } - - localeResolver(SessionLocaleResolver) - multipartResolver(StandardServletMultipartResolver) - grailsUrlMappingsHolder(UrlMappingsHolderFactoryBean) { - grailsApplication = grailsApplication - } - - "${CompositeViewResolver.BEAN_NAME}"(CompositeViewResolver) - - if(ClassUtils.isPresent("org.grails.plugins.web.GroovyPagesGrailsPlugin", classLoader)) { - def lazyBean = { bean -> - bean.lazyInit = true - } - jspTagLibraryResolver(TagLibraryResolverImpl, lazyBean) - gspTagLibraryLookup(LazyTagLibraryLookup, lazyBean) - groovyPageUnitTestResourceLoader(GroovyPageUnitTestResourceLoader, groovyPages) - groovyPageLocator(GrailsConventionGroovyPageLocator) { - resourceLoader = ref('groovyPageUnitTestResourceLoader') - } - groovyPagesTemplateEngine(GroovyPagesTemplateEngine) { bean -> - bean.lazyInit = true - tagLibraryLookup = ref("gspTagLibraryLookup") - jspTagLibraryResolver = ref("jspTagLibraryResolver") - groovyPageLocator = ref("groovyPageLocator") - } - - groovyPagesTemplateRenderer(GroovyPagesTemplateRenderer) { bean -> - bean.lazyInit = true - groovyPageLocator = ref("groovyPageLocator") - groovyPagesTemplateEngine = ref("groovyPagesTemplateEngine") - } - - // Configure a Spring MVC view resolver - jspViewResolver(GroovyPageViewResolver) { bean -> - prefix = GrailsApplicationAttributes.PATH_TO_VIEWS - suffix = GroovyPageViewResolver.GSP_SUFFIX - templateEngine = groovyPagesTemplateEngine - groovyPageLocator = groovyPageLocator - } - } - filteringCodecsByContentTypeSettings(FilteringCodecsByContentTypeSettings, grailsApplication) - localeResolver(SessionLocaleResolver) - } - - CodecsGrailsPlugin codecsGrailsPlugin = new CodecsGrailsPlugin() - test.defineBeans(codecsGrailsPlugin) - - codecsGrailsPlugin.providedArtefacts.each { Class codecClass -> - test.mockCodec(codecClass, false) - } - - grailsApplication.mainContext.getBean(DefaultCodecLookup).reInitialize() - } - -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebTestingSupportExtension.groovy b/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebTestingSupportExtension.groovy deleted file mode 100644 index 365e3da5..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/groovy/org/grails/testing/spock/WebTestingSupportExtension.groovy +++ /dev/null @@ -1,36 +0,0 @@ -package org.grails.testing.spock - -import grails.testing.web.GrailsWebUnitTest -import grails.testing.web.UrlMappingsUnitTest -import grails.testing.web.interceptor.InterceptorUnitTest -import groovy.transform.CompileStatic -import org.spockframework.runtime.extension.AbstractGlobalExtension -import org.spockframework.runtime.model.SpecInfo - -@CompileStatic -class WebTestingSupportExtension extends AbstractGlobalExtension { - - WebSetupSpecInterceptor webSetupSpecInterceptor = new WebSetupSpecInterceptor() - WebSetupInterceptor webSetupInterceptor = new WebSetupInterceptor() - WebCleanupInterceptor webCleanupInterceptor = new WebCleanupInterceptor() - WebCleanupSpecInterceptor webCleanupSpecInterceptor = new WebCleanupSpecInterceptor() - UrlMappingSetupSpecInterceptor urlMappingSetupSpecInterceptor = new UrlMappingSetupSpecInterceptor() - InterceptorSetupSpecInterceptor interceptorSetupSpecInterceptor = new InterceptorSetupSpecInterceptor() - - void visitSpec(SpecInfo spec) { - if (GrailsWebUnitTest.isAssignableFrom(spec.reflection)) { - spec.addSetupSpecInterceptor(webSetupSpecInterceptor) - spec.addSetupInterceptor(webSetupInterceptor) - spec.addCleanupInterceptor(webCleanupInterceptor) - spec.addCleanupSpecInterceptor(webCleanupSpecInterceptor) - } - - if (UrlMappingsUnitTest.isAssignableFrom(spec.reflection)) { - spec.addSetupSpecInterceptor(urlMappingSetupSpecInterceptor) - } - - if (InterceptorUnitTest.isAssignableFrom(spec.reflection)) { - spec.addSetupSpecInterceptor(interceptorSetupSpecInterceptor) - } - } -} diff --git a/grails-testing-support/grails-web-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension b/grails-testing-support/grails-web-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension deleted file mode 100644 index 07024e74..00000000 --- a/grails-testing-support/grails-web-testing-support/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension +++ /dev/null @@ -1 +0,0 @@ -org.grails.testing.spock.WebTestingSupportExtension diff --git a/grails-testing-support/grails-wrapper.jar b/grails-testing-support/grails-wrapper.jar deleted file mode 100644 index b9bd249f..00000000 Binary files a/grails-testing-support/grails-wrapper.jar and /dev/null differ diff --git a/grails-testing-support/settings.gradle b/grails-testing-support/settings.gradle deleted file mode 100755 index 72edf698..00000000 --- a/grails-testing-support/settings.gradle +++ /dev/null @@ -1,41 +0,0 @@ -plugins { - id 'com.gradle.develocity' version '3.18.1' - id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2' -} - -def isCI = System.getenv('CI') != null -def isLocal = !isCI -def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null -def isBuildCacheAuthenticated = - System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null && - System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null - -develocity { - server = 'https://ge.grails.org' - buildScan { - publishing.onlyIf { isAuthenticated } - uploadInBackground = isLocal - } -} - -buildCache { - local { enabled = isLocal } - remote(develocity.buildCache) { - push = isCI && isBuildCacheAuthenticated - enabled = true - usernameAndPassword( - System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: '', - System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: '' - ) - } -} - -rootProject.name = 'testing-support' - -include 'grails-testing-support', - 'grails-web-testing-support', - 'grails-gorm-testing-support' - -include 'examples-demo33' - project(":examples-demo33").projectDir = new File(settingsDir, "examples/demo33") - diff --git a/grails-testing-support/src/main/docs/guide/APIDocs.adoc b/grails-testing-support/src/main/docs/guide/APIDocs.adoc deleted file mode 100644 index e0e72e4a..00000000 --- a/grails-testing-support/src/main/docs/guide/APIDocs.adoc +++ /dev/null @@ -1 +0,0 @@ -Click link:../api/index.html[here] to view the API Documentation. \ No newline at end of file diff --git a/grails-testing-support/src/main/docs/guide/installation.adoc b/grails-testing-support/src/main/docs/guide/installation.adoc deleted file mode 100644 index c377bf4a..00000000 --- a/grails-testing-support/src/main/docs/guide/installation.adoc +++ /dev/null @@ -1,8 +0,0 @@ -To install the testing support library add the following dependency to the -`dependencies` block of your `build.gradle` in a Grails application or plugin: - -[source,groovy,subs="attributes"] -testCompile "org.grails:grails-gorm-testing-support:{version}" -testCompile "org.grails:grails-web-testing-support:{version}" - -NOTE: The dependencies are optional. If you are not unit testing domain activity, you may not need the GORM testing support library. diff --git a/grails-testing-support/src/main/docs/guide/introduction.adoc b/grails-testing-support/src/main/docs/guide/introduction.adoc deleted file mode 100644 index 1ec06d94..00000000 --- a/grails-testing-support/src/main/docs/guide/introduction.adoc +++ /dev/null @@ -1 +0,0 @@ -The Grails Testing Support library provides support for writing concise expressive tests for Grails artifacts with simple, easy to use traits and supporting classes. The use of Traits makes functionality woven into the test class at compile time, which allows developers to explicitly view and explore the code. In addition, the Grails Testing Support library makes testing more IDE-friendly so developers can take advantage of auto-completion and click through navigation. diff --git a/grails-testing-support/src/main/docs/guide/toc.yml b/grails-testing-support/src/main/docs/guide/toc.yml deleted file mode 100644 index 0f7a35ec..00000000 --- a/grails-testing-support/src/main/docs/guide/toc.yml +++ /dev/null @@ -1,14 +0,0 @@ -introduction: Introduction -installation: Installation -upgrading: Upgrading From The Mixin Framework -unitTesting: - title: Unit Testing - unitTestingControllers: Unit Testing Controllers - unitTestingDomainClasses: Unit Testing Domain Classes - unitTestingServices: Unit Testing Services - unitTestingTagLibraries: Unit Testing Tag Libraries - unitTestingInterceptors: Unit Testing Interceptors - unitTestingUrlMappings: Unit Testing Url Mappings - annotations: Annotations - usefulProperties: Useful Properties -APIDocs: API Docs \ No newline at end of file diff --git a/grails-testing-support/src/main/docs/guide/unitTesting.adoc b/grails-testing-support/src/main/docs/guide/unitTesting.adoc deleted file mode 100644 index 4b2af7de..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting.adoc +++ /dev/null @@ -1,90 +0,0 @@ -By implementing Grails Testing Support traits, unit tests inherit functionality that make writing tests concise and simple. - -The following functionality is available to all tests - -=== Modifying the Application Context - -Any modifications to the context will be specific to that test class. A new context is created for each test class. Artifacts under test are subjected to dependency injection just like they are in the running application. The unit testing environment does not spin up the entire Spring application context with all of the beans that would normally be configured in the running application. Unit tests may register any beans necessary to carry out the test in a number of different ways. - -==== doWithSpring - -To provide or replace beans in the context, you can override the `doWithSpring` method in your test. - -[source,groovy] ----- -Closure doWithSpring() {{ -> - someService(SomeService) -}} ----- - -NOTE: The syntax available in this closure is the same syntax that may be used in `grails-app/conf/spring/resources.groovy` for defining bean definitions. - -==== resources.groovy - -If you want your application's resources file to be loaded into the context, override the `loadExternalBeans` method. - -[source,groovy] ----- -boolean loadExternalBeans() { - true -} ----- - -==== Spring configuration from plugins - -If you would like the `doWithSpring` configuration of any loaded plugins to be invoked for your tests, override the `getIncludePlugins` method and return a list of strings representing the plugin names. - -[source,groovy] ----- -Set getIncludePlugins() { - ["springSecurityCore"].toSet() -} ----- - -WARNING: If you override this method, the default plugins will not be included. The default plugins are `core` and `eventBus`. If you want to add a plugin in addition to the defaults, add the defaults to your list. - -==== Other Spring configuration - -At any time during your tests, you can also directly call the `defineBeans` method. The `defineBeans` method can either take a closure, or an instance of a plugin. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/DefineBeansSpec.groovy[tags=test_declaration,indent=0] ----- - -If you pass a plugin instance to the method, the `doWithSpring` will be executed. - -[source,groovy] ----- -void testSomething() { - given: - defineBeans(new MyCustomPlugin()) - - expect: - applicationContext.containsBean('someBeanAddedByDoWithSpring') -} ----- - -==== Autowiring The Test - -It is possible to set up the test class itself for autowiring. Simply implement the link:../api/grails/testing/spring/AutowiredTest.html[`AutowiredTest`] trait, and beans will be injected into the test class. - -For Example: - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/AutowiredTestSpec.groovy[tags=test_declaration,indent=0] ----- - -=== Manipulating Configuration - -To change configuration for the context of your test class, override the `doWithConfig` method. - -[source,groovy] ----- -Closure doWithConfig() {{ config -> - config['foo.bar'] = "x" -}} ----- - -NOTE: A test only needs to implement the link:../api/org/grails/testing/GrailsUnitTest.html[`GrailsUnitTest`] trait to get the above functionality. All of the other testing traits extend `GrailsUnitTest`, so implementing it directly is uncommon. diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/annotations.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/annotations.adoc deleted file mode 100644 index e6ca73ef..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/annotations.adoc +++ /dev/null @@ -1,43 +0,0 @@ - -=== @RunOnce - -The `grails.testing.spock.RunOnce` annotation may be applied to any Spock test -fixture method that you wish to be executed only once. This is useful when -applied in conjunction with a fixture annnotation like `@Before` as shown below. - -[source,groovy] -.src/test/groovy/grails/testing/spock/RunOnceSpec.groovy ----- -include::{sourceDir}/grails-testing-support/src/test/groovy/grails/testing/spock/RunOnceSpec.groovy[indent=0] ----- - -Applying both the `@RunOnce` and `@Before` annotations to a method will yield -behavior similar to the behavior associated with Spock's `setupSpec` method but -an important difference is that `setupSpec` is run before the test instance is -subjected to dependency injection while `@Before` methods are run after the -test instance is subjected to dependency injection. This means that the -`setupSpec` method will not have access to injected variables but methods marked -with `@Before` will have access to injected variables. If a test has some one -time setup logic that needs to be executed after dependency injection happens, -the `RunOnce` annotation can help accomplish that. - -=== @OnceBefore - -The `grails.testing.spock.OnceBefore` annotation is a shorthand way of -accomplishing the same behavior that would be accomplished by applying both the -`@RunOnce` and `@Before` annotations to a fixture method. - -[source,groovy] -.src/test/groovy/grails/testing/spock/OnceBeforeSpec.groovy ----- -include::{sourceDir}/grails-testing-support/src/test/groovy/grails/testing/spock/OnceBeforeSpec.groovy[indent=0] ----- - -This is useful in the context of an integration test which wants to reference -dependency injected values during setup as shown below. - -[source,groovy] -.src/integration-test/groovy/demo/DependencyInjectionSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/integration-test/groovy/demo/DependencyInjectionSpec.groovy[indent=0] ----- diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingControllers.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingControllers.adoc deleted file mode 100644 index 18c04c38..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingControllers.adoc +++ /dev/null @@ -1,62 +0,0 @@ - -Use the `grails.testing.web.controllers.ControllerUnitTest` trait to unit -test controllers. - -[source,groovy] -.src/test/groovy/demo/DemoControllerSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/DemoControllerSpec.groovy[tags=basic_declaration,indent=0] ----- - -To test the simplest "Hello World"-style example you can do the following: - -[source,groovy] -.grails-app/controllers/demo/DemoController.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/controllers/demo/DemoController.groovy[tags=basic_declaration;render_hello,indent=0] ----- - -[source,groovy] -.src/test/groovy/demo/DemoControllerSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/DemoControllerSpec.groovy[tags=basic_declaration;test_render,indent=0] ----- -<1> The `controller` property will be an instance of `DemoController` -<2> The `status` property will contain the value of the response status -<3> The `response` property will be a reference to the HTTP response object - -See the link:../api/grails/testing/web/controllers/ControllerUnitTest.html[`ControllerUnitTest`] -docs for information on all of the available properties. - -NOTE: In an effort to make testing controllers that render JSON views easy, a change was made that required the controller variable used in the test code to be a proxy that delegates to the real controller instance. If for some reason that causes an issue with your test, it is possible to disable the creation of a proxy by overriding a method. - -[source,groovy] ----- -class DemoControllerSpec implements ControllerUnitTest { - - boolean disableControllerProxy() { - true - } -} ----- - -By doing so, JSON views will not be rendered by default. To enable JSON views to render automatically as before, it is necessary to inform the `webRequest` object which action you are invoking. - -[source,groovy] ----- -class DemoControllerSpec implements ControllerUnitTest { - - void "test index"() { - when: - webRequest.actionName = 'index' - controller.index() - - then: - ... - } - - boolean disableControllerProxy() { - true - } -} ----- diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingDomainClasses.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingDomainClasses.adoc deleted file mode 100644 index 915ba5de..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingDomainClasses.adoc +++ /dev/null @@ -1,46 +0,0 @@ -Use the link:../api/grails/testing/gorm/DomainUnitTest.html[`grails.testing.gorm.DomainUnitTest`] -trait to unit test single domain class. - -[source,groovy] -.grails-app/domain/demo/Person.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/domain/demo/Person.groovy[indent=0] ----- - -[source,groovy] -.src/test/groovy/demo/PersonSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/PersonSpec.groovy[indent=0] ----- - -Alternatively, the link:../api/grails/testing/gorm/DataTest.html[`grails.testing.gorm.DataTest`] -trait may be used. When using `DataTest`, an explicit call to the -link:../api/grails/testing/gorm/DataTest.html#mockDomain(Class)[mockDomain] or -link:../api/grails/testing/gorm/DataTest.html#mockDomains(Class)[mockDomains] -method may be used to specify which domain class(es) should be mocked for this -test. This is useful when mocking more than one Domain class at a time to test persistence. - -[source,groovy] -.src/test/groovy/demo/DataTestTraitSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/DataTestTraitSpec.groovy[indent=0] ----- - -Another way to express which domain classes should be mocked for this test is -to provide a `Class[] getDomainClassesToMock()` method in the test. - -[source,groovy] -.src/test/groovy/demo/GetDomainClassesToMockMethodSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/GetDomainClassesToMockMethodSpec.groovy[indent=0] ----- - -When mocking domain classes in a test for another artifact type (like a -`ControllerUnitTest` test, for example), the test must implement the `DataTest` -trait in order to mock the related domain classes. - -[source,groovy] -.src/test/groovy/demo/PersonControllerSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/PersonControllerSpec.groovy[indent=0] ----- diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingInterceptors.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingInterceptors.adoc deleted file mode 100644 index 7fb9ec6d..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingInterceptors.adoc +++ /dev/null @@ -1,40 +0,0 @@ -Use the link:../api/grails/testing/web/interceptor/InterceptorUnitTest.html[`InterceptorUnitTest`] trait to unit test interceptors. - -The interceptor unit test trait provides methods to make testing interceptors easy. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/grails-app/controllers/demo/TestInterceptor.groovy[tags=declaration,indent=0] ----- - -==== withRequest - -You can use the `withRequest` method in combination with `interceptor.doesMatch()` to verify whether or not your interceptor matches the request. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/TestInterceptorSpec.groovy[tags=with_request,indent=0] ----- - -==== withInterceptors - -You can use the `withInterceptors` method to execute code within the context of interceptor execution. This is typically done to call controller actions that rely on behavior from interceptors. - -Given this controller action: - -[source,groovy] -.grails-app/controllers/demo/TestController.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/controllers/demo/TestController.groovy[tags=render_attribute,indent=0] ----- - -Here is how the action might be tested with `withInterceptors`: - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/TestInterceptorSpec.groovy[tags=with_interceptors,indent=0] ----- - - -Adding the `InterceptorUnitTest` trait to a test causes a new `interceptor` property to -be automatically created for the Interceptor class under test. \ No newline at end of file diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingServices.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingServices.adoc deleted file mode 100644 index f4a0c83c..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingServices.adoc +++ /dev/null @@ -1,17 +0,0 @@ -Use the `grails.testing.services.ServiceUnitTest` trait to unit -test services. - -[source,groovy] -.grails-app/services/demo/HelperService.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/services/demo/HelperService.groovy[tags=basic_declaration,indent=0] ----- - -[source,groovy] -.src/test/groovy/demo/HelperServiceSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/HelperServiceSpec.groovy[tags=basic_declaration,indent=0] ----- - -Adding the `ServiceUnitTest` trait to a test causes a new `service` property to -be automatically created for the Service class under test. \ No newline at end of file diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingTagLibraries.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingTagLibraries.adoc deleted file mode 100644 index cdda9da6..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingTagLibraries.adoc +++ /dev/null @@ -1,93 +0,0 @@ - -=== The Basics - -Tag libraries and GSP pages can be tested with the -`grails.testing.web.taglib.TagLibUnitTest` trait. - -[source,groovy] -.grails-app/taglib/demo/SampleTagLib.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/taglib/demo/SampleTagLib.groovy[tags=basic_declaration;hello_world,indent=0] ----- - -[source,groovy] -.src/test/groovy/demo/SampleTagLibSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/SampleTagLibSpec.groovy[tags=basic_declaration;test_simple_tag_as_method,indent=0] ----- - -Adding the `TagLibUnitTest` trait to a test causes a new `tagLib` field to be -automatically created for the TagLib class under test. The `tagLib` property can -be used to test calling tags as function calls. The return value of a function -call is either a `org.grails.buffer,StreamCharBuffer` -instance or the object returned from the tag closure when -`returnObjectForTags` feature is used. - -To test a tag which accepts parameters, specify the parameter values as named -arguments to the method call. - -[source,groovy] -.grails-app/taglib/demo/SampleTagLib.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/taglib/demo/SampleTagLib.groovy[tags=basic_declaration;say_hello,indent=0] ----- -[source,groovy] -.src/test/groovy/demo/SampleTagLibSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/SampleTagLibSpec.groovy[tags=basic_declaration;test_tag_as_method_with_parameters,indent=0] ----- - -Alternatively, tags may be tested with the `applyTemplate` method which accepts -a `String` parameter that will be evaluated as if it were source code in a GSP. - -[source,groovy] -.src/test/groovy/demo/SampleTagLibSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/SampleTagLibSpec.groovy[tags=basic_declaration;test_simple_tag_with_applyTemplate,indent=0] ----- - -The `applyTemplate` method accepts an optional second argument which is a `Map` -containing model variables which may be accessed in the GSP snippet that is -past as the first argument to `applyTemplate` as shown below. - -[source,groovy] -.grails-app/taglib/demo/SampleTagLib.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/taglib/demo/SampleTagLib.groovy[tags=basic_declaration;render_some_number,indent=0] ----- -[source,groovy] -.src/test/groovy/demo/SampleTagLibSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/SampleTagLibSpec.groovy[tags=basic_declaration;test_with_model,indent=0] ----- - -NOTE: The String being passed as the first argument to `applyTemplate` includes -a Groovy String expression (`"${x + y}"`) that needs to be evaluated when the GSP snippet is -evaluated, not when the code in the test is evaluated. Because of that it is -important that the containing String be surrounded by single quotes, not double -quotes. `''` works. -`""` would not. - -=== Mocking Tag Libraries - -In order to test a tag library which invokes tags from another tag library, -the second tag library needs to be explicitly mocked by invoking the -`mockTagLib` method. - -[source,groovy] -.grails-app/taglib/demo/FirstTagLib.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/taglib/demo/FirstTagLib.groovy[tags=basic_declaration,indent=0] ----- - -[source,groovy] -.grails-app/taglib/demo/SecondTagLib.groovy ----- -include::{sourcedir}/examples/demo33/grails-app/taglib/demo/SecondTagLib.groovy[tags=basic_declaration,indent=0] ----- - -[source,groovy] -.src/test/groovy/demo/FirstTagLibSpec.groovy ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/FirstTagLibSpec.groovy[tags=basic_declaration,indent=0] ----- diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingUrlMappings.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingUrlMappings.adoc deleted file mode 100644 index cf49c694..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/unitTestingUrlMappings.adoc +++ /dev/null @@ -1,106 +0,0 @@ -Use the link:../api/grails/testing/web/UrlMappingsUnitTest.html[`UrlMappingsUnitTest`] trait to unit test url mappings. Testing url mappings also requires controllers to be mocked to match the mappings to. - -NOTE: Controllers can not be mocked in `setupSpec` due to the nature of the request being created and reset for each test. The request is not available until the `setup` method, therefore controllers can not be mocked until then. - -All of the methods that check the url mappings come in 2 forms, `assert` and `verify`. The `assert` versions will throw AssertionFailed exceptions, similar to the `assert` keyword in Groovy. The `verify` methods will simply return true or false depending on whether the url mapping was found and is valid for the expectations. - -The examples assume the following mappings are being used. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/grails-app/controllers/demo/UrlMappings.groovy[indent=0] ----- - -=== Getting Started - -To get started, implement the `UrlMappingsUnitTest` in your test class and mock controllers you would like to test against. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=setup,indent=0] ----- - -It is also possible call the `mockController` method in the given blocks of your feature methods if different controllers need to be tested in different test methods. - -=== Forward Url Mapping Test - -Tests whether a URL mapping is forwarded for the given controller class - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=forward,indent=0] ----- - -=== Reverse Url Mapping Test - -Test whether the given URL is produced when reverse mapping a link to a given controller and action - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=reverse,indent=0] ----- - -NOTE: Url mappings for HTTP status codes can not be reversed because it doesn't make sense to "link" to a status code. - -=== Combined - -Tests whether a URL mapping is valid for the given URL. This combines the forward and reverse methods. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=combined,indent=0] ----- - -NOTE: When calling `verifyUrlMapping`, then reverse mapping will only be checked if a controller is supplied and the first parameter is not an HTTP status code. - -=== HTTP Methods - -When testing HTTP methods on reverse URL mapping it is necessary to specify the HTTP method in the test. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=httpMethodsReverse,indent=0] ----- - -When testing HTTP methods on forward URL mapping it is necessary to specify the HTTP method in the request. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=httpMethodsForward,indent=0] ----- - -When testing HTTP methods on both forward and reverse URL mapping combined it is necessary to specify the HTTP method in both the request and in the test. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=httpMethodsCombined,indent=0] ----- - -=== Other Helpful Methods - -==== Controller Check - -Use the `verifyController` method to check whether or not the given controller name exists. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=controller,indent=0] ----- - -==== Action Check - -Use the `verifyAction` method to verify if an action exists for a controller. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=action,indent=0] ----- - -==== View Check - -User the `verifyView` method to check if a GSP exists for a controller. - -[source,groovy] ----- -include::{sourcedir}/examples/demo33/src/test/groovy/demo/UrlMappingsSpec.groovy[tags=view,indent=0] ----- \ No newline at end of file diff --git a/grails-testing-support/src/main/docs/guide/unitTesting/usefulProperties.adoc b/grails-testing-support/src/main/docs/guide/unitTesting/usefulProperties.adoc deleted file mode 100644 index 2b1b7eaa..00000000 --- a/grails-testing-support/src/main/docs/guide/unitTesting/usefulProperties.adoc +++ /dev/null @@ -1,43 +0,0 @@ -The testing framework provides and initializes a number of properties that -are directly accessible unit tests. The link:../api/index.html[javadocs] for the -various traits describe those properties. Some particular properties of interest: - -== Properties Available In All Unit Tests - -- link:../api/org/grails/testing/GrailsUnitTest.html#getMessageSource()[messageSource] -- link:../api/org/grails/testing/GrailsUnitTest.html#getGrailsApplication()[grailsApplication] -- link:../api/org/grails/testing/GrailsUnitTest.html#getApplicationContext()[applicationContext] -- link:../api/org/grails/testing/GrailsUnitTest.html#getConfig()[config] - -== Properties Available In All Web Unit Tests (Controller, Interceptor, Taglib, UrlMappings) - -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getRequest()[request] -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getResponse()[response] -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getServletContext()[servletContext] -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getViews()[views] -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getSession()[session] -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getStatus()[status] -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getParams()[params] -- link:../api/grails/testing/web/GrailsWebUnitTest.html#getFlash()[flash] - -== Controller Unit Test Properties - -- link:../api/grails/testing/web/controllers/ControllerUnitTest.html#getController()[controller] -- link:../api/grails/testing/web/controllers/ControllerUnitTest.html#getView()[view] -- link:../api/grails/testing/web/controllers/ControllerUnitTest.html#getModel()[model] - -== Interceptor Unit Test Properties - -- link:../api/grails/testing/web/interceptor/InterceptorUnitTest.html#getInterceptor()[interceptor] - -== Service Unit Test Properties - -- link:../api/grails/testing/services/ServiceUnitTest.html#getService()[service] - -== Tag Library Unit Test Properties - -- link:../api/grails/testing/web/taglib/TagLibUnitTest.html#getTagLib()[tagLib] - -== Domain Class Unit Test Properties - -- link:../api/grails/testing/gorm/DomainUnitTest.html#getDomain()[domain] diff --git a/grails-testing-support/src/main/docs/guide/upgrading.adoc b/grails-testing-support/src/main/docs/guide/upgrading.adoc deleted file mode 100644 index 51c3beb9..00000000 --- a/grails-testing-support/src/main/docs/guide/upgrading.adoc +++ /dev/null @@ -1,51 +0,0 @@ -This library was designed to be compatible with the old mixin approach. There are some slight differences that you may encounter, however any required changes should be minimal. - -=== FreshRuntime Removed - -The `@FreshRuntime` annotation was removed due to the design of the new framework. The annotation allowed any metaclass changes to be sandboxed either at the method or class level. Spock provides a similar annotation to do the same thing, link:http://spockframework.org/spock/docs/1.1/all_in_one.html#_confinemetaclasschanges[@ConfineMetaClassChanges]. - -In addition, the annotation caused the application context to be refreshed. Because the application context is refreshed between test classes automatically, the annotation is no longer necessary. - -=== Integration Tests - -The `@Integration` annotation was copied to this library so a dependency on the old framework is no longer necessary. The package has changed from `grails.test.mixin.integration.Integration` to `grails.testing.mixin.integration.Integration`. Everything about integration tests should work the same as before. - -=== Example Converted Test - -Here is an example test that may look like something in your project. - -[source,groovy] ----- -@TestFor(AuthorController) -@Mock(Author) -class AuthorControllerTests { - - @Test - void testIndex() { - controller.index() - assert response.text == 'Hello' - } -} ----- - -To convert this test to the new framework, we must update it to use Spock as well as change the annotation usages to trait usages. - -[source,groovy] ----- -import spock.lang.Specification -import grails.testing.gorm.DomainUnitTest -import grails.testing.web.controllers.ControllerUnitTest - -class AuthorControllerTests extends Specification implements ControllerUnitTest, DomainUnitTest { - - void testIndex() { - when: - controller.index() - - then: - response.text == 'Hello' - } -} ----- - -Obviously there are many use cases you may want to convert and it would be impossible to cover them all in this documentation. As a part of the testing of this new framework, all of the usages of the old framework were replaced in Grails core. You can view those changes by looking at link:https://github.com/grails/grails-core/commit/8c4f07743108bf1e4e5f69dbb57695cce0b2518d[this commit] to see the vast majority of examples you will need. \ No newline at end of file diff --git a/grails-testing-support/src/main/docs/resources/style/.gitkeep b/grails-testing-support/src/main/docs/resources/style/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/settings.gradle b/settings.gradle index a1a8d474..3c65850b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -33,6 +33,7 @@ include 'issue-698-domain-save-npe' include 'hyphenated' include 'issue-views-182' include 'issue-11102' +include 'demo33' //include 'micronaut' micronaut has been removed from Grails can be restored based on https://micronaut-projects.github.io/micronaut-spring/latest/guide/#springBootStarter include 'loadfirst'