Skip to content

Commit 31ad4b4

Browse files
committed
Upgrade the Grails sample to Grails 3.2.6
Closes gh-357
1 parent 722048e commit 31ad4b4

File tree

12 files changed

+48
-192
lines changed

12 files changed

+48
-192
lines changed

samples/rest-notes-grails/build.gradle

+19-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,26 @@
11
buildscript {
2-
ext {
3-
grailsVersion = project.grailsVersion
4-
}
52
repositories {
6-
mavenLocal()
73
maven { url "https://repo.grails.org/grails/core" }
8-
maven { url 'https://repo.spring.io/libs-snapshot' }
94
}
105
dependencies {
116
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
12-
classpath "org.grails.plugins:hibernate:4.3.10.5"
13-
classpath 'org.ajoberstar:gradle-git:1.1.0'
7+
classpath "org.grails.plugins:hibernate5:6.0.7"
148
}
159
}
1610

1711
plugins {
18-
id "io.spring.dependency-management" version "0.5.4.RELEASE"
1912
id 'org.asciidoctor.convert' version '1.5.3'
2013
}
2114

2215
version "0.1"
2316
group "com.example"
2417

25-
apply plugin: "spring-boot"
2618
apply plugin: "war"
27-
apply plugin: 'eclipse'
28-
apply plugin: 'idea'
19+
apply plugin: "eclipse"
20+
apply plugin: "idea"
2921
apply plugin: "org.grails.grails-web"
3022

3123
ext {
32-
grailsVersion = project.grailsVersion
33-
gradleWrapperVersion = project.gradleWrapperVersion
3424
restDocsVersion = "1.2.0.BUILD-SNAPSHOT"
3525
snippetsDir = file('src/docs/generated-snippets')
3626
}
@@ -43,12 +33,12 @@ repositories {
4333

4434
dependencyManagement {
4535
dependencies {
36+
dependency "org.springframework.restdocs:spring-restdocs-core:$restDocsVersion"
4637
dependency "org.springframework.restdocs:spring-restdocs-restassured:$restDocsVersion"
4738
dependency "org.springframework.restdocs:spring-restdocs-asciidoctor:$restDocsVersion"
4839
}
4940
imports {
5041
mavenBom "org.grails:grails-bom:$grailsVersion"
51-
mavenBom "org.springframework:spring-framework-bom:4.3.1.RELEASE"
5242
}
5343
applyMavenExclusions false
5444
}
@@ -57,34 +47,39 @@ dependencies {
5747
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor"
5848

5949
compile "org.springframework.boot:spring-boot-starter-logging"
60-
compile "org.springframework.boot:spring-boot-starter-actuator"
6150
compile "org.springframework.boot:spring-boot-autoconfigure"
51+
compile "org.springframework.boot:spring-boot-starter-actuator"
6252
compile "org.springframework.boot:spring-boot-starter-tomcat"
53+
compile "org.grails:grails-core"
6354
compile "org.grails:grails-plugin-url-mappings"
6455
compile "org.grails:grails-plugin-rest"
56+
compile "org.grails:grails-plugin-codecs"
6557
compile "org.grails:grails-plugin-interceptors"
6658
compile "org.grails:grails-plugin-services"
6759
compile "org.grails:grails-plugin-datasource"
6860
compile "org.grails:grails-plugin-databinding"
6961
compile "org.grails:grails-plugin-async"
7062
compile "org.grails:grails-web-boot"
7163
compile "org.grails:grails-logging"
72-
73-
compile "org.grails.plugins:hibernate"
7464
compile "org.grails.plugins:cache"
75-
compile "org.hibernate:hibernate-ehcache"
65+
compile "org.grails.plugins:hibernate5"
66+
compile "org.hibernate:hibernate-core:5.1.2.Final"
67+
compile "org.hibernate:hibernate-ehcache:5.1.2.Final"
68+
compile "org.grails.plugins:views-json"
69+
compile "org.grails.plugins:views-json-templates"
70+
console "org.grails:grails-console"
71+
72+
profile "org.grails.profiles:rest-api"
7673

7774
runtime "com.h2database:h2"
7875

7976
testCompile "org.grails:grails-plugin-testing"
8077
testCompile "org.grails.plugins:geb"
81-
testCompile 'org.springframework.restdocs:spring-restdocs-restassured'
82-
83-
console "org.grails:grails-console"
84-
}
78+
testCompile "org.grails:grails-datastore-rest-client"
79+
testCompile "org.springframework.restdocs:spring-restdocs-restassured"
8580

86-
task wrapper(type: Wrapper) {
87-
gradleVersion = gradleWrapperVersion
81+
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
82+
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
8883
}
8984

9085
ext {
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
grailsVersion=3.0.15
2-
gradleWrapperVersion=2.3
1+
grailsVersion=3.2.6
2+
gradleWrapperVersion=3.4

samples/rest-notes-grails/grails-app/conf/application.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
grails:
3-
profile: web-api
3+
profile: rest-api
44
codegen:
55
defaultPackage: com.example
66
info:

samples/rest-notes-grails/grails-app/controllers/com/example/IndexController.groovy

-48
This file was deleted.

samples/rest-notes-grails/grails-app/controllers/com/example/InternalServerErrorController.groovy

-28
This file was deleted.

samples/rest-notes-grails/grails-app/controllers/com/example/NotFoundController.groovy

-28
This file was deleted.

samples/rest-notes-grails/grails-app/controllers/UrlMappings.groovy renamed to samples/rest-notes-grails/grails-app/controllers/com/example/UrlMappings.groovy

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,12 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17+
package com.example
18+
1719
class UrlMappings {
1820

1921
static mappings = {
20-
"/"(controller: 'index')
21-
"500"(controller: 'InternalServerError')
22-
"404"(controller: 'NotFound')
22+
delete "/$controller/$id(.$format)?"(action:"delete")
23+
get "/$controller(.$format)?"(action:"index")
24+
get "/$controller/$id(.$format)?"(action:"show")
25+
post "/$controller(.$format)?"(action:"save")
26+
put "/$controller/$id(.$format)?"(action:"update")
27+
patch "/$controller/$id(.$format)?"(action:"patch")
28+
29+
"500"(view: '/error')
30+
"404"(view: '/notFound')
2331
}
2432

2533
}

samples/rest-notes-grails/grails-app/init/BootStrap.groovy renamed to samples/rest-notes-grails/grails-app/init/com/example/BootStrap.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import com.example.Note
17+
package com.example
1818

1919
class BootStrap {
2020

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
response.status 500
2+
3+
json {
4+
message "Internal server error"
5+
error 500
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
response.status 404
2+
3+
json {
4+
message "Not Found"
5+
error 404
6+
}

samples/rest-notes-grails/src/docs/asciidoc/index.adoc

-24
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,6 @@ use of HTTP status codes.
6262
= Resources
6363

6464

65-
[[resources-index]]
66-
== Index
67-
68-
The index provides the entry point into the service.
69-
70-
71-
72-
[[resources-index-access]]
73-
=== Accessing the index
74-
75-
A `GET` request is used to access the index
76-
77-
==== Example request
78-
79-
include::{snippets}/index-example/curl-request.adoc[]
80-
81-
==== Response structure
82-
83-
include::{snippets}/index-example/response-fields.adoc[]
84-
85-
==== Example response
86-
87-
include::{snippets}/index-example/http-response.adoc[]
88-
8965

9066
[[resources-notes]]
9167
== Notes

samples/rest-notes-grails/src/integration-test/groovy/com/example/ApiDocumentationSpec.groovy

+1-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,34 +59,6 @@ class ApiDocumentationSpec extends Specification {
5959
.build()
6060
}
6161

62-
void 'test and document get request for /index'() {
63-
expect:
64-
given(this.documentationSpec)
65-
.accept(MediaType.APPLICATION_JSON.toString())
66-
.filter(document('index-example',
67-
preprocessRequest(modifyUris()
68-
.host('api.example.com')
69-
.removePort()),
70-
preprocessResponse(prettyPrint()),
71-
responseFields(
72-
fieldWithPath('message').description('Welcome to Grails!'),
73-
fieldWithPath('environment').description("The running environment"),
74-
fieldWithPath('appversion').description('version of the app that is running'),
75-
fieldWithPath('grailsversion').description('the version of grails used in this project'),
76-
fieldWithPath('appprofile').description('the profile of grails used in this project'),
77-
fieldWithPath('groovyversion').description('the version of groovy used in this project'),
78-
fieldWithPath('jvmversion').description('the version of the jvm used in this project'),
79-
subsectionWithPath('controllers').type(JsonFieldType.ARRAY).description('the list of available controllers'),
80-
subsectionWithPath('plugins').type(JsonFieldType.ARRAY).description('the plugins active for this project'),
81-
)))
82-
.when()
83-
.port(this.serverPort)
84-
.get('/')
85-
.then()
86-
.assertThat()
87-
.statusCode(is(200))
88-
}
89-
9062
void 'test and document notes list request'() {
9163
expect:
9264
given(this.documentationSpec)
@@ -97,7 +69,6 @@ class ApiDocumentationSpec extends Specification {
9769
.removePort()),
9870
preprocessResponse(prettyPrint()),
9971
responseFields(
100-
fieldWithPath('[].class').description('the class of the resource'),
10172
fieldWithPath('[].id').description('the id of the note'),
10273
fieldWithPath('[].title').description('the title of the note'),
10374
fieldWithPath('[].body').description('the body of the note'),
@@ -127,7 +98,6 @@ class ApiDocumentationSpec extends Specification {
12798
subsectionWithPath('tags').type(JsonFieldType.ARRAY).description('a list of tags associated to the note')
12899
),
129100
responseFields(
130-
fieldWithPath('class').description('the class of the resource'),
131101
fieldWithPath('id').description('the id of the note'),
132102
fieldWithPath('title').description('the title of the note'),
133103
fieldWithPath('body').description('the body of the note'),
@@ -152,7 +122,6 @@ class ApiDocumentationSpec extends Specification {
152122
.removePort()),
153123
preprocessResponse(prettyPrint()),
154124
responseFields(
155-
fieldWithPath('class').description('the class of the resource'),
156125
fieldWithPath('id').description('the id of the note'),
157126
fieldWithPath('title').description('the title of the note'),
158127
fieldWithPath('body').description('the body of the note'),

0 commit comments

Comments
 (0)