diff --git a/build.gradle b/build.gradle index 99acdaa1..1d402ec9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,185 +1,117 @@ -buildscript { - repositories { - mavenCentral() - maven { url 'https://repo.spring.io/plugins-snapshot' } - maven { url 'https://repo.spring.io/plugins-release' } - maven { url 'https://plugins.gradle.org/m2/' } - maven { url 'https://repo.spring.io/snapshot' } - } - dependencies { - classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7' - classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2' - classpath 'io.spring.gradle:dependency-management-plugin:1.0.8.RELEASE' - classpath "io.spring.javaformat:spring-javaformat-gradle-plugin:$javaFormatVersion" - classpath 'io.spring.nohttp:nohttp-gradle:0.0.2.RELEASE' - } +plugins { + id 'io.spring.javaformat' version "$javaFormatVersion" apply false + id 'io.spring.nohttp' version '0.0.6.RELEASE' apply false } allprojects { - group = 'org.springframework.restdocs' + group = "org.springframework.restdocs" repositories { mavenCentral() - maven { url 'https://repo.spring.io/libs-snapshot' } + maven { url "https://repo.spring.io/snapshot" } } } -apply plugin: 'samples' -apply plugin: 'org.sonarqube' -apply plugin: 'io.spring.nohttp' - -sonarqube { - properties { - property 'sonar.jacoco.reportPath', "${buildDir.name}/jacoco.exec" - property 'sonar.java.coveragePlugin', 'jacoco' - property 'sonar.links.ci', 'https://build.spring.io/browse/SRD' - property 'sonar.links.homepage', 'https://github.com/spring-projects/spring-restdocs' - property 'sonar.links.issue', 'https://github.com/spring-projects/spring-restdocs' - property 'sonar.links.scm', 'https://github.com/spring-projects/spring-restdocs' - } -} +apply plugin: "samples" +apply plugin: "io.spring.nohttp" nohttp { - source.exclude 'samples/rest-notes-slate/slate/source/javascripts/lib/_jquery*.js' - source.exclude 'buildSrc/.gradle/**' - source.exclude '**/build/**' - source.exclude '**/target/**' - whitelistFile = project.file('config/nohttp/whitelist.lines') + source.exclude "samples/rest-notes-slate/slate/source/javascripts/lib/_jquery*.js" + source.exclude "buildSrc/.gradle/**" + source.exclude "**/build/**" + source.exclude "**/target/**" } ext { - springVersion = '5.0.15.RELEASE' + springVersion = "5.0.15.RELEASE" javadocLinks = [ - 'https://docs.oracle.com/javase/8/docs/api/', + "https://docs.oracle.com/javase/8/docs/api/", "https://docs.spring.io/spring-framework/docs/$springVersion/javadoc-api/", - 'https://docs.jboss.org/hibernate/stable/beanvalidation/api/', - 'https://docs.jboss.org/hibernate/stable/validator/api/' + "https://docs.jboss.org/hibernate/stable/beanvalidation/api/", + "https://docs.jboss.org/hibernate/stable/validator/api/" ] as String[] } -subprojects { - apply plugin: 'io.spring.dependency-management' - apply plugin: 'java' - apply plugin: 'eclipse' - apply plugin: 'propdeps' - apply plugin: 'propdeps-eclipse' - apply plugin: 'propdeps-maven' - apply plugin: 'maven' - apply plugin: 'matrixtest' +subprojects { subproject -> + plugins.withType(JavaPlugin) { + subproject.apply plugin: "io.spring.javaformat" + subproject.apply plugin: "checkstyle" - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = 1.8 + targetCompatibility = 1.8 - dependencyManagement { - imports { - mavenBom "org.springframework:spring-framework-bom:$springVersion" + configurations { + internal { + canBeConsumed = false + canBeResolved = false + } + compileClasspath.extendsFrom(internal) + runtimeClasspath.extendsFrom(internal) + testCompileClasspath.extendsFrom(internal) + testRuntimeClasspath.extendsFrom(internal) } + + test { + testLogging { + exceptionFormat "full" + } + } + + compileJava { + options.compilerArgs = [ "-Xlint:deprecation", "-Xlint:-options", "-Werror" ] + } + + tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + } + + tasks.withType(Test) { + maxHeapSize = "1024M" + } + + checkstyle { + configFile = rootProject.file("config/checkstyle/checkstyle.xml") + configProperties = [ "checkstyle.config.dir" : rootProject.file("config/checkstyle") ] + toolVersion = "8.22" + } + dependencies { - dependency 'com.fasterxml.jackson.core:jackson-databind:2.9.5' - dependency 'com.samskivert:jmustache:1.12' - dependency 'commons-codec:commons-codec:1.10' - dependency 'javax.servlet:javax.servlet-api:3.1.0' - dependency 'javax.validation:validation-api:2.0.0.Final' - dependency 'junit:junit:4.12' - dependency 'io.rest-assured:rest-assured:3.0.7' - dependency 'org.apache.pdfbox:pdfbox:2.0.7' - dependency 'org.assertj:assertj-core:3.11.1' - dependency 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.18' - dependency 'org.hamcrest:hamcrest-core:1.3' - dependency 'org.hamcrest:hamcrest-library:1.3' - dependency 'org.hibernate.validator:hibernate-validator:6.0.9.Final' - dependency 'org.jacoco:org.jacoco.agent:0.7.9' - dependency 'org.javamoney:moneta:1.1' - dependency 'org.jruby:jruby-complete:9.1.13.0' - dependency 'org.junit.jupiter:junit-jupiter-api:5.0.0' - dependency 'org.mockito:mockito-core:1.10.19' - dependency 'org.springframework.hateoas:spring-hateoas:0.23.0.RELEASE' - dependency 'org.synchronoss.cloud:nio-multipart-parser:1.1.0' + checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:$javaFormatVersion") } - } - test { - testLogging { - exceptionFormat "full" - } - } + plugins.withType(MavenPublishPlugin) { + subproject.apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle" - eclipseJdt { - inputFile = rootProject.file('config/eclipse/org.eclipse.jdt.core.prefs') - doLast { - project.file('.settings/org.eclipse.jdt.ui.prefs').withWriter { writer -> - writer << rootProject.file('config/eclipse/org.eclipse.jdt.ui.prefs').text + javadoc { + description = "Generates project-level javadoc for use in -javadoc jar" + options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED + options.author = true + options.header = "Spring REST Docs $version" + options.docTitle = "${options.header} API" + options.links = javadocLinks + options.addStringOption "-quiet" + options.encoding = "UTF-8" + options.source = "1.8" + } + + java { + withJavadocJar() + withSourcesJar() } } } - compileJava { - options.compilerArgs = [ '-Xlint:deprecation', '-Xlint:-options', '-Werror' ] + tasks.withType(GenerateModuleMetadata) { + enabled = false } - tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' - } - -} - -def codeProjects = subprojects - project(":docs") -configure(codeProjects) { - apply plugin: 'io.spring.javaformat' - apply plugin: 'checkstyle' - apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle" - - checkstyle { - configFile = rootProject.file('config/checkstyle/checkstyle.xml') - configProperties = [ 'checkstyle.config.dir' : rootProject.file('config/checkstyle') ] - toolVersion = '8.22' - } - - configurations { - jacoco - } - - dependencies { - checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:$javaFormatVersion" - jacoco 'org.jacoco:org.jacoco.agent::runtime' - } -} - -def publishedCodeProjects = codeProjects.findAll { codeProject -> !codeProject.name.contains('spring-restdocs-asciidoctor-')} -configure(publishedCodeProjects) { subproject -> - javadoc { - description = "Generates project-level javadoc for use in -javadoc jar" - options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED - options.author = true - options.header = "Spring REST Docs $version" - options.docTitle = "${options.header} API" - options.links = javadocLinks - options.addStringOption '-quiet' - options.encoding = 'UTF-8' - options.source = '1.8' - } - - task sourcesJar(type: Jar) { - classifier = 'sources' - from project.sourceSets.main.allSource - } - - task javadocJar(type: Jar) { - classifier = "javadoc" - from javadoc - } - - artifacts { - archives sourcesJar - archives javadocJar - } } samples { - dependOn 'spring-restdocs-core:install' - dependOn 'spring-restdocs-mockmvc:install' - dependOn 'spring-restdocs-restassured:install' - dependOn 'spring-restdocs-webtestclient:install' - dependOn 'spring-restdocs-asciidoctor:install' + dependOn "spring-restdocs-core:publishToMavenLocal" + dependOn "spring-restdocs-mockmvc:publishToMavenLocal" + dependOn "spring-restdocs-restassured:publishToMavenLocal" + dependOn "spring-restdocs-webtestclient:publishToMavenLocal" + dependOn "spring-restdocs-asciidoctor:publishToMavenLocal" restNotesSpringHateoas { workingDir "$projectDir/samples/rest-notes-spring-hateoas" @@ -215,49 +147,52 @@ samples { task api (type: Javadoc) { group = "Documentation" description = "Generates aggregated Javadoc API documentation." - dependsOn { - subprojects.collect { - it.tasks.getByName("jar") + project.rootProject.gradle.projectsEvaluated { + Set excludedProjects = ['spring-restdocs-asciidoctor'] + Set publishedProjects = rootProject.subprojects.findAll { it != project} + .findAll { it.plugins.hasPlugin(JavaPlugin) && it.plugins.hasPlugin(MavenPublishPlugin) } + .findAll { !excludedProjects.contains(it.name) } + .findAll { !it.name.startsWith('spring-boot-starter') } + dependsOn publishedProjects.javadoc + source publishedProjects.javadoc.source + classpath = project.files(publishedProjects.javadoc.classpath) + destinationDir = project.file "${buildDir}/docs/javadoc" + options { + author = true + docTitle = "Spring REST Docs ${project.version} API" + encoding = "UTF-8" + memberLevel = "protected" + outputLevel = "quiet" + source = "1.8" + splitIndex = true + stylesheetFile = file("src/main/javadoc/spring-javadoc.css") + use = true + windowTitle = "Spring REST Docs ${project.version} API" } } - options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED - options.author = true - options.header = "Spring REST Docs $version" - options.splitIndex = true - options.links = javadocLinks - options.addStringOption '-quiet' - - source publishedCodeProjects.findAll { it.name != 'spring-restdocs-asciidoctor' } - .collect { it.sourceSets.main.allJava } - - destinationDir = new File(buildDir, "api") - - doFirst { - classpath = files(subprojects.collect { it.sourceSets.main.compileClasspath }) - } } -task docsZip(type: Zip, dependsOn: [':docs:asciidoctor', ':api', ':buildSamples']) { - group = 'Distribution' - baseName = 'spring-restdocs' - classifier = 'docs' - description = "Builds -${classifier} archive containing API and reference documentation" - destinationDir = file("${project.buildDir}/distributions") +task docsZip(type: Zip, dependsOn: [":docs:asciidoctor", ":api", ":buildSamples"]) { + group = "Distribution" + archiveBaseName = "spring-restdocs" + archiveClassifier = "docs" + description = "Builds -${archiveClassifier} archive containing API and reference documentation" + destinationDirectory = file("${project.buildDir}/distributions") - from(project.tasks.findByPath(':docs:asciidoctor')) { - into 'reference' + from(project.tasks.findByPath(":docs:asciidoctor")) { + into "reference" } from(api) { - into 'api' + into "api" } - from(file('samples/rest-notes-spring-hateoas/build/asciidoc/html5')) { - into 'samples/restful-notes' + from(file("samples/rest-notes-spring-hateoas/build/asciidoc/html5")) { + into "samples/restful-notes" } - from(file('samples/rest-notes-slate/build/docs')) { - into 'samples/slate' + from(file("samples/rest-notes-slate/build/docs")) { + into "samples/slate" } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 00000000..400a425c --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,4 @@ +plugins { + id "java-gradle-plugin" + id "groovy-gradle-plugin" +} diff --git a/buildSrc/src/main/groovy/org/springframework/restdocs/build/samples/SampleBuildConfigurer.groovy b/buildSrc/src/main/groovy/org/springframework/restdocs/build/samples/SampleBuildConfigurer.groovy index b6c15f00..536b7f19 100644 --- a/buildSrc/src/main/groovy/org/springframework/restdocs/build/samples/SampleBuildConfigurer.groovy +++ b/buildSrc/src/main/groovy/org/springframework/restdocs/build/samples/SampleBuildConfigurer.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2021 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. @@ -55,7 +55,7 @@ public class SampleBuildConfigurer { sampleBuild.dependsOn gradleVersionsUpdate if (build) { Task gradleBuild = createGradleBuild(project, sampleDir, dependencies) - Task verifyIncludesTask = createVerifyIncludes(project, new File(sampleDir, 'build/asciidoc')) + Task verifyIncludesTask = createVerifyIncludes(project, new File(sampleDir, 'build/docs/asciidoc')) verifyIncludesTask.dependsOn gradleBuild sampleBuild.dependsOn verifyIncludesTask gradleBuild.dependsOn gradleVersionsUpdate @@ -161,4 +161,4 @@ public class SampleBuildConfigurer { } return verifyIncludesTask } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/java/org/springframework/restdocs/build/optional/OptionalDependenciesPlugin.java b/buildSrc/src/main/java/org/springframework/restdocs/build/optional/OptionalDependenciesPlugin.java new file mode 100644 index 00000000..9d7ab9ee --- /dev/null +++ b/buildSrc/src/main/java/org/springframework/restdocs/build/optional/OptionalDependenciesPlugin.java @@ -0,0 +1,57 @@ +/* + * Copyright 2014-2021 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 + * + * 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. + */ + +package org.springframework.restdocs.build.optional; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.attributes.Bundling; +import org.gradle.api.attributes.LibraryElements; +import org.gradle.api.attributes.Usage; +import org.gradle.api.plugins.JavaPlugin; +import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.tasks.SourceSetContainer; +import org.gradle.api.tasks.javadoc.Javadoc; + +/** + * A {@code Plugin} that adds support for Maven-style optional dependencies. Creates a new + * {@code optional} configuration. The {@code optional} configuration is part of the + * project's compile and runtime classpath's but does not affect the classpath of + * dependent projects. + * + * @author Andy Wilkinson + */ +public class OptionalDependenciesPlugin implements Plugin { + + /** + * Name of the {@code optional} configuration. + */ + public static final String OPTIONAL_CONFIGURATION_NAME = "optional"; + + @Override + public void apply(Project project) { + Configuration optional = project.getConfigurations().create(OPTIONAL_CONFIGURATION_NAME); + project.getConfigurations().getByName(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME).extendsFrom(optional); + project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(optional); + project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(optional); + project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(optional); + project.getConfigurations().getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(optional); + project.getConfigurations().getByName(JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME).extendsFrom(optional); + project.getConfigurations().getByName(JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME).extendsFrom(optional); + } + +} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/optional-dependencies.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/optional-dependencies.properties new file mode 100644 index 00000000..3a981c6f --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/optional-dependencies.properties @@ -0,0 +1 @@ +implementation-class:org.springframework.restdocs.build.optional.OptionalDependenciesPlugin diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index a84e41b8..7d1c754d 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -1,5 +1,8 @@ - + + + + diff --git a/docs/build.gradle b/docs/build.gradle index 52d22a88..db8190e7 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -1,31 +1,87 @@ plugins { - id 'org.asciidoctor.convert' version '1.5.9.2' + id "org.asciidoctor.jvm.convert" version "3.2.0" + id "java-library" } repositories { - maven { url 'https://repo.spring.io/release' } - maven { url 'https://repo.spring.io/snapshot' } + maven { url "https://repo.spring.io/release" } + maven { url "https://repo.spring.io/snapshot" } +} + +configurations { + asciidoctorExt } dependencies { - asciidoctor 'io.spring.asciidoctor:spring-asciidoctor-extensions:0.1.2.RELEASE' - testCompile project(':spring-restdocs-mockmvc') - testCompile project(':spring-restdocs-restassured') - testCompile project(':spring-restdocs-webtestclient') - testCompile 'io.rest-assured:rest-assured' - testCompile 'javax.validation:validation-api' - testCompile 'junit:junit' - testCompile 'org.testng:testng:6.9.10' - testCompile 'org.junit.jupiter:junit-jupiter-api' + asciidoctorExt("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.5.0") + + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation(project(":spring-restdocs-mockmvc")) + testImplementation(project(":spring-restdocs-restassured")) + testImplementation(project(":spring-restdocs-webtestclient")) + testImplementation("io.rest-assured:rest-assured") + testImplementation("javax.validation:validation-api") + testImplementation("junit:junit") + testImplementation("org.testng:testng:6.9.10") + testImplementation("org.junit.jupiter:junit-jupiter-api") } tasks.findByPath("artifactoryPublish")?.enabled = false +tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) { + baseDirFollowsSourceDir() +} + +jar { + enabled = false +} + +javadoc { + enabled = false +} + asciidoctor { + configurations 'asciidoctorExt' sources { - include 'index.adoc' + include "index.adoc" } - attributes 'revnumber': project.version, - 'branch-or-tag': project.version.endsWith('SNAPSHOT') ? 'main': "v${project.version}" + attributes "revnumber": project.version, + "branch-or-tag": project.version.endsWith("SNAPSHOT") ? "main": "v${project.version}" inputs.files(sourceSets.test.java) } + +task api (type: Javadoc) { + group = "Documentation" + description = "Generates aggregated Javadoc API documentation." + dependsOn { + subprojects.collect { + it.tasks.getByName("jar") + } + } + project.rootProject.gradle.projectsEvaluated { + Set excludedProjects = ['spring-restdocs-asciidoctor'] + Set publishedProjects = rootProject.subprojects.findAll { it != project} + .findAll { it.plugins.hasPlugin(JavaPlugin) && it.plugins.hasPlugin(MavenPublishPlugin) } + .findAll { !excludedProjects.contains(it.name) } + dependsOn publishedProjects.javadoc + source publishedProjects.javadoc.source + classpath = project.files(publishedProjects.javadoc.classpath) + destinationDir = project.file "${buildDir}/docs/javadoc" + options { + author = true + docTitle = "Spring REST Docs ${project.version} API" + encoding = "UTF-8" + memberLevel = "protected" + outputLevel = "quiet" + source = "1.8" + splitIndex = true + stylesheetFile = file("src/main/javadoc/spring-javadoc.css") + use = true + windowTitle = "Spring REST Docs ${project.version} API" + } + } + + destinationDir = new File(buildDir, "api") +} + diff --git a/docs/src/docs/asciidoc/getting-started.adoc b/docs/src/docs/asciidoc/getting-started.adoc index d4fbb900..7332344f 100644 --- a/docs/src/docs/asciidoc/getting-started.adoc +++ b/docs/src/docs/asciidoc/getting-started.adoc @@ -151,7 +151,7 @@ the configuration are described in the following listings: dependencies { asciidoctor 'org.springframework.restdocs:spring-restdocs-asciidoctor:{project-version}' <2> - testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc:{project-version}' <3> + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc:{project-version}' <3> } ext { <4> @@ -172,7 +172,7 @@ the configuration are described in the following listings: This will automatically configure the `snippets` attribute for use in your `.adoc` files to point to `build/generated-snippets`. It will also allow you to use the `operation` block macro. -<3> Add a dependency on `spring-restdocs-mockmvc` in the `testCompile` configuration. If +<3> Add a dependency on `spring-restdocs-mockmvc` in the `testImplementation` configuration. If you want to use `WebTestClient` or REST Assured rather than MockMvc, add a dependency on `spring-restdocs-webtestclient` or `spring-restdocs-restassured` respectively instead. diff --git a/docs/src/test/java/com/example/Hypermedia.java b/docs/src/test/java/com/example/Hypermedia.java index b10c54df..8d12791d 100644 --- a/docs/src/test/java/com/example/Hypermedia.java +++ b/docs/src/test/java/com/example/Hypermedia.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -22,12 +22,16 @@ import org.springframework.restdocs.hypermedia.LinksSnippet; import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; -public class Hypermedia { +public final class Hypermedia { + + private Hypermedia() { + + } // tag::ignore-links[] public static LinksSnippet links(LinkDescriptor... descriptors) { - return HypermediaDocumentation.links(linkWithRel("self").ignored().optional(), - linkWithRel("curies").ignored()).and(descriptors); + return HypermediaDocumentation.links(linkWithRel("self").ignored().optional(), linkWithRel("curies").ignored()) + .and(descriptors); } // end::ignore-links[] diff --git a/docs/src/test/java/com/example/Payload.java b/docs/src/test/java/com/example/Payload.java index 8d0d053f..321761a3 100644 --- a/docs/src/test/java/com/example/Payload.java +++ b/docs/src/test/java/com/example/Payload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -27,8 +27,7 @@ public class Payload { @SuppressWarnings("unused") public void bookFieldDescriptors() { // tag::book-descriptors[] - FieldDescriptor[] book = new FieldDescriptor[] { - fieldWithPath("title").description("Title of the book"), + FieldDescriptor[] book = new FieldDescriptor[] { fieldWithPath("title").description("Title of the book"), fieldWithPath("author").description("Author of the book") }; // end::book-descriptors[] } diff --git a/docs/src/test/java/com/example/SnippetReuse.java b/docs/src/test/java/com/example/SnippetReuse.java index 60685154..ca87eca0 100644 --- a/docs/src/test/java/com/example/SnippetReuse.java +++ b/docs/src/test/java/com/example/SnippetReuse.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -29,6 +29,7 @@ public class SnippetReuse { linkWithRel("last").optional().description("The last page of results"), linkWithRel("next").optional().description("The next page of results"), linkWithRel("prev").optional().description("The previous page of results")); + // end::field[] } diff --git a/docs/src/test/java/com/example/mockmvc/CustomDefaultOperationPreprocessors.java b/docs/src/test/java/com/example/mockmvc/CustomDefaultOperationPreprocessors.java index be9156b8..af890124 100644 --- a/docs/src/test/java/com/example/mockmvc/CustomDefaultOperationPreprocessors.java +++ b/docs/src/test/java/com/example/mockmvc/CustomDefaultOperationPreprocessors.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -42,8 +42,7 @@ public class CustomDefaultOperationPreprocessors { public void setup() { // tag::custom-default-operation-preprocessors[] this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation) - .operationPreprocessors() + .apply(documentationConfiguration(this.restDocumentation).operationPreprocessors() .withRequestDefaults(removeHeaders("Foo")) // <1> .withResponseDefaults(prettyPrint())) // <2> .build(); diff --git a/docs/src/test/java/com/example/mockmvc/CustomDefaultSnippets.java b/docs/src/test/java/com/example/mockmvc/CustomDefaultSnippets.java index 23e91ca0..ae9a800a 100644 --- a/docs/src/test/java/com/example/mockmvc/CustomDefaultSnippets.java +++ b/docs/src/test/java/com/example/mockmvc/CustomDefaultSnippets.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -43,8 +43,7 @@ public class CustomDefaultSnippets { public void setUp() { // tag::custom-default-snippets[] this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation).snippets() - .withDefaults(curlRequest())) + .apply(documentationConfiguration(this.restDocumentation).snippets().withDefaults(curlRequest())) .build(); // end::custom-default-snippets[] } diff --git a/docs/src/test/java/com/example/mockmvc/CustomEncoding.java b/docs/src/test/java/com/example/mockmvc/CustomEncoding.java index 118a1a46..f9ba2fba 100644 --- a/docs/src/test/java/com/example/mockmvc/CustomEncoding.java +++ b/docs/src/test/java/com/example/mockmvc/CustomEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -18,6 +18,7 @@ package com.example.mockmvc; import org.junit.Before; import org.junit.Rule; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.restdocs.JUnitRestDocumentation; import org.springframework.test.web.servlet.MockMvc; @@ -41,8 +42,7 @@ public class CustomEncoding { public void setUp() { // tag::custom-encoding[] this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation) - .snippets().withEncoding("ISO-8859-1")) + .apply(documentationConfiguration(this.restDocumentation).snippets().withEncoding("ISO-8859-1")) .build(); // end::custom-encoding[] } diff --git a/docs/src/test/java/com/example/mockmvc/CustomFormat.java b/docs/src/test/java/com/example/mockmvc/CustomFormat.java index c65cdff4..9a8b5682 100644 --- a/docs/src/test/java/com/example/mockmvc/CustomFormat.java +++ b/docs/src/test/java/com/example/mockmvc/CustomFormat.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -18,6 +18,7 @@ package com.example.mockmvc; import org.junit.Before; import org.junit.Rule; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.restdocs.JUnitRestDocumentation; import org.springframework.restdocs.templates.TemplateFormats; @@ -42,8 +43,8 @@ public class CustomFormat { public void setUp() { // tag::custom-format[] this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation) - .snippets().withTemplateFormat(TemplateFormats.markdown())) + .apply(documentationConfiguration(this.restDocumentation).snippets() + .withTemplateFormat(TemplateFormats.markdown())) .build(); // end::custom-format[] } diff --git a/docs/src/test/java/com/example/mockmvc/CustomUriConfiguration.java b/docs/src/test/java/com/example/mockmvc/CustomUriConfiguration.java index b928b622..8cc4abd7 100644 --- a/docs/src/test/java/com/example/mockmvc/CustomUriConfiguration.java +++ b/docs/src/test/java/com/example/mockmvc/CustomUriConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -18,6 +18,7 @@ package com.example.mockmvc; import org.junit.Before; import org.junit.Rule; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.restdocs.JUnitRestDocumentation; import org.springframework.test.web.servlet.MockMvc; @@ -41,10 +42,8 @@ public class CustomUriConfiguration { public void setUp() { // tag::custom-uri-configuration[] this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation).uris() - .withScheme("https") - .withHost("example.com") - .withPort(443)) + .apply(documentationConfiguration(this.restDocumentation).uris().withScheme("https") + .withHost("example.com").withPort(443)) .build(); // end::custom-uri-configuration[] } diff --git a/docs/src/test/java/com/example/mockmvc/EveryTestPreprocessing.java b/docs/src/test/java/com/example/mockmvc/EveryTestPreprocessing.java index ebd00ebe..09bd27bb 100644 --- a/docs/src/test/java/com/example/mockmvc/EveryTestPreprocessing.java +++ b/docs/src/test/java/com/example/mockmvc/EveryTestPreprocessing.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -18,6 +18,7 @@ package com.example.mockmvc; import org.junit.Before; import org.junit.Rule; + import org.springframework.restdocs.JUnitRestDocumentation; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -45,20 +46,17 @@ public class EveryTestPreprocessing { @Before public void setup() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation).operationPreprocessors() - .withRequestDefaults(removeHeaders("Foo")) // <1> - .withResponseDefaults(prettyPrint())) // <2> - .build(); + .apply(documentationConfiguration(this.restDocumentation).operationPreprocessors() + .withRequestDefaults(removeHeaders("Foo")) // <1> + .withResponseDefaults(prettyPrint())) // <2> + .build(); } // end::setup[] public void use() throws Exception { // tag::use[] - this.mockMvc.perform(get("/")) - .andExpect(status().isOk()) - .andDo(document("index", - links(linkWithRel("self").description("Canonical self link")) - )); + this.mockMvc.perform(get("/")).andExpect(status().isOk()) + .andDo(document("index", links(linkWithRel("self").description("Canonical self link")))); // end::use[] } diff --git a/docs/src/test/java/com/example/mockmvc/ExampleApplicationJUnit5Tests.java b/docs/src/test/java/com/example/mockmvc/ExampleApplicationJUnit5Tests.java index bddf113c..a2e6ccc6 100644 --- a/docs/src/test/java/com/example/mockmvc/ExampleApplicationJUnit5Tests.java +++ b/docs/src/test/java/com/example/mockmvc/ExampleApplicationJUnit5Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -35,8 +35,7 @@ public class ExampleApplicationJUnit5Tests { private MockMvc mockMvc; @BeforeEach - public void setUp(WebApplicationContext webApplicationContext, - RestDocumentationContextProvider restDocumentation) { + public void setUp(WebApplicationContext webApplicationContext, RestDocumentationContextProvider restDocumentation) { this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) .apply(documentationConfiguration(restDocumentation)) // <1> .build(); diff --git a/docs/src/test/java/com/example/mockmvc/ExampleApplicationTestNgTests.java b/docs/src/test/java/com/example/mockmvc/ExampleApplicationTestNgTests.java index c490a798..2215ac7c 100644 --- a/docs/src/test/java/com/example/mockmvc/ExampleApplicationTestNgTests.java +++ b/docs/src/test/java/com/example/mockmvc/ExampleApplicationTestNgTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -18,31 +18,32 @@ package com.example.mockmvc; import java.lang.reflect.Method; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.restdocs.ManualRestDocumentation; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; public class ExampleApplicationTestNgTests { public final ManualRestDocumentation restDocumentation = new ManualRestDocumentation(); + @SuppressWarnings("unused") // tag::setup[] private MockMvc mockMvc; - + @Autowired private WebApplicationContext context; @BeforeMethod public void setUp(Method method) { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation)) - .build(); + .apply(documentationConfiguration(this.restDocumentation)).build(); this.restDocumentation.beforeTest(getClass(), method.getName()); } diff --git a/docs/src/test/java/com/example/mockmvc/HttpHeaders.java b/docs/src/test/java/com/example/mockmvc/HttpHeaders.java index f0198430..88f2011d 100644 --- a/docs/src/test/java/com/example/mockmvc/HttpHeaders.java +++ b/docs/src/test/java/com/example/mockmvc/HttpHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -31,20 +31,17 @@ public class HttpHeaders { public void headers() throws Exception { // tag::headers[] - this.mockMvc - .perform(get("/people").header("Authorization", "Basic dXNlcjpzZWNyZXQ=")) // <1> - .andExpect(status().isOk()) - .andDo(document("headers", - requestHeaders( // <2> - headerWithName("Authorization").description( - "Basic auth credentials")), // <3> - responseHeaders( // <4> - headerWithName("X-RateLimit-Limit").description( - "The total number of requests permitted per period"), - headerWithName("X-RateLimit-Remaining").description( - "Remaining requests permitted in current period"), - headerWithName("X-RateLimit-Reset").description( - "Time at which the rate limit period will reset")))); + this.mockMvc.perform(get("/people").header("Authorization", "Basic dXNlcjpzZWNyZXQ=")) // <1> + .andExpect(status().isOk()).andDo(document("headers", requestHeaders(// <2> + headerWithName("Authorization").description("Basic auth credentials")), // <3> + responseHeaders(// <4> + headerWithName("X-RateLimit-Limit") + .description("The total number of requests permitted per period"), + headerWithName("X-RateLimit-Remaining") + .description("Remaining requests permitted in current period"), + headerWithName("X-RateLimit-Reset") + .description("Time at which the rate limit period will reset")))); // end::headers[] } + } diff --git a/docs/src/test/java/com/example/mockmvc/Hypermedia.java b/docs/src/test/java/com/example/mockmvc/Hypermedia.java index 1035c4ea..a3e93ffb 100644 --- a/docs/src/test/java/com/example/mockmvc/Hypermedia.java +++ b/docs/src/test/java/com/example/mockmvc/Hypermedia.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -16,39 +16,36 @@ package com.example.mockmvc; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; -import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links; -import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.halLinks; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; - import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; +import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.halLinks; +import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; +import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + public class Hypermedia { private MockMvc mockMvc; public void defaultExtractor() throws Exception { // tag::links[] - this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("index", links( // <1> - linkWithRel("alpha").description("Link to the alpha resource"), // <2> - linkWithRel("bravo").description("Link to the bravo resource")))); // <3> + this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("index", links(// <1> + linkWithRel("alpha").description("Link to the alpha resource"), // <2> + linkWithRel("bravo").description("Link to the bravo resource")))); // <3> // end::links[] } public void explicitExtractor() throws Exception { - this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - //tag::explicit-extractor[] - .andDo(document("index", links(halLinks(), // <1> - linkWithRel("alpha").description("Link to the alpha resource"), - linkWithRel("bravo").description("Link to the bravo resource")))); - // end::explicit-extractor[] + this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + // tag::explicit-extractor[] + .andDo(document("index", links(halLinks(), // <1> + linkWithRel("alpha").description("Link to the alpha resource"), + linkWithRel("bravo").description("Link to the bravo resource")))); + // end::explicit-extractor[] } - } diff --git a/docs/src/test/java/com/example/mockmvc/InvokeService.java b/docs/src/test/java/com/example/mockmvc/InvokeService.java index dbf3dc30..7d941b5a 100644 --- a/docs/src/test/java/com/example/mockmvc/InvokeService.java +++ b/docs/src/test/java/com/example/mockmvc/InvokeService.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -16,13 +16,13 @@ package com.example.mockmvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; - public class InvokeService { private MockMvc mockMvc; @@ -30,8 +30,8 @@ public class InvokeService { public void invokeService() throws Exception { // tag::invoke-service[] this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)) // <1> - .andExpect(status().isOk()) // <2> - .andDo(document("index")); // <3> + .andExpect(status().isOk()) // <2> + .andDo(document("index")); // <3> // end::invoke-service[] } diff --git a/docs/src/test/java/com/example/mockmvc/MockMvcSnippetReuse.java b/docs/src/test/java/com/example/mockmvc/MockMvcSnippetReuse.java index 6e863085..edddaab8 100644 --- a/docs/src/test/java/com/example/mockmvc/MockMvcSnippetReuse.java +++ b/docs/src/test/java/com/example/mockmvc/MockMvcSnippetReuse.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -32,11 +32,10 @@ public class MockMvcSnippetReuse extends SnippetReuse { public void documentation() throws Exception { // tag::use[] - this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("example", this.pagingLinks.and( // <1> - linkWithRel("alpha").description("Link to the alpha resource"), - linkWithRel("bravo").description("Link to the bravo resource")))); + this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("example", this.pagingLinks.and(// <1> + linkWithRel("alpha").description("Link to the alpha resource"), + linkWithRel("bravo").description("Link to the bravo resource")))); // end::use[] } diff --git a/docs/src/test/java/com/example/mockmvc/ParameterizedOutput.java b/docs/src/test/java/com/example/mockmvc/ParameterizedOutput.java index 4b4ee602..f5dbdac3 100644 --- a/docs/src/test/java/com/example/mockmvc/ParameterizedOutput.java +++ b/docs/src/test/java/com/example/mockmvc/ParameterizedOutput.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -18,6 +18,7 @@ package com.example.mockmvc; import org.junit.Before; import org.junit.Rule; + import org.springframework.restdocs.JUnitRestDocumentation; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -40,8 +41,8 @@ public class ParameterizedOutput { @Before public void setUp() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation)) - .alwaysDo(document("{method-name}/{step}/")).build(); + .apply(documentationConfiguration(this.restDocumentation)).alwaysDo(document("{method-name}/{step}/")) + .build(); } // end::parameterized-output[] diff --git a/docs/src/test/java/com/example/mockmvc/PathParameters.java b/docs/src/test/java/com/example/mockmvc/PathParameters.java index 44652990..cac5a304 100644 --- a/docs/src/test/java/com/example/mockmvc/PathParameters.java +++ b/docs/src/test/java/com/example/mockmvc/PathParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -16,14 +16,14 @@ package com.example.mockmvc; +import org.springframework.test.web.servlet.MockMvc; + import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.springframework.test.web.servlet.MockMvc; - public class PathParameters { private MockMvc mockMvc; @@ -31,11 +31,10 @@ public class PathParameters { public void pathParametersSnippet() throws Exception { // tag::path-parameters[] this.mockMvc.perform(get("/locations/{latitude}/{longitude}", 51.5072, 0.1275)) // <1> - .andExpect(status().isOk()) - .andDo(document("locations", pathParameters( // <2> - parameterWithName("latitude").description("The location's latitude"), // <3> - parameterWithName("longitude").description("The location's longitude") // <4> - ))); + .andExpect(status().isOk()).andDo(document("locations", pathParameters(// <2> + parameterWithName("latitude").description("The location's latitude"), // <3> + parameterWithName("longitude").description("The location's longitude") // <4> + ))); // end::path-parameters[] } diff --git a/docs/src/test/java/com/example/mockmvc/Payload.java b/docs/src/test/java/com/example/mockmvc/Payload.java index f049f30a..70e2ffaa 100644 --- a/docs/src/test/java/com/example/mockmvc/Payload.java +++ b/docs/src/test/java/com/example/mockmvc/Payload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -40,91 +40,69 @@ public class Payload { public void response() throws Exception { // tag::response[] - this.mockMvc.perform(get("/user/5").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("index", - responseFields( // <1> - fieldWithPath("contact.email") - .description("The user's email address"), // <2> + this.mockMvc.perform(get("/user/5").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("index", responseFields(// <1> + fieldWithPath("contact.email").description("The user's email address"), // <2> fieldWithPath("contact.name").description("The user's name")))); // <3> // end::response[] } public void subsection() throws Exception { // tag::subsection[] - this.mockMvc.perform(get("/user/5").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("index", - responseFields( // <1> - subsectionWithPath("contact") - .description("The user's contact details")))); // <1> + this.mockMvc.perform(get("/user/5").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("index", responseFields(// <1> + subsectionWithPath("contact").description("The user's contact details")))); // <1> // end::subsection[] } public void explicitType() throws Exception { - this.mockMvc.perform(get("/user/5").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) + this.mockMvc.perform(get("/user/5").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) // tag::explicit-type[] - .andDo(document("index", - responseFields( - fieldWithPath("contact.email").type(JsonFieldType.STRING) // <1> - .description("The user's email address")))); + .andDo(document("index", responseFields(fieldWithPath("contact.email").type(JsonFieldType.STRING) // <1> + .description("The user's email address")))); // end::explicit-type[] } public void constraints() throws Exception { - this.mockMvc.perform(post("/users/").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) + this.mockMvc.perform(post("/users/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) // tag::constraints[] - .andDo(document("create-user", requestFields( - attributes(key("title").value("Fields for user creation")), // <1> + .andDo(document("create-user", requestFields(attributes(key("title").value("Fields for user creation")), // <1> fieldWithPath("name").description("The user's name") - .attributes(key("constraints") - .value("Must not be null. Must not be empty")), // <2> + .attributes(key("constraints").value("Must not be null. Must not be empty")), // <2> fieldWithPath("email").description("The user's email address") - .attributes(key("constraints") - .value("Must be a valid email address"))))); // <3> + .attributes(key("constraints").value("Must be a valid email address"))))); // <3> // end::constraints[] } public void descriptorReuse() throws Exception { - FieldDescriptor[] book = new FieldDescriptor[] { - fieldWithPath("title").description("Title of the book"), + FieldDescriptor[] book = new FieldDescriptor[] { fieldWithPath("title").description("Title of the book"), fieldWithPath("author").description("Author of the book") }; // tag::single-book[] - this.mockMvc.perform(get("/books/1").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(document("book", responseFields(book))); // <1> + this.mockMvc.perform(get("/books/1").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("book", responseFields(book))); // <1> // end::single-book[] // tag::book-array[] - this.mockMvc.perform(get("/books").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("book", - responseFields( - fieldWithPath("[]").description("An array of books")) // <1> - .andWithPrefix("[].", book))); // <2> + this.mockMvc.perform(get("/books").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("book", responseFields(fieldWithPath("[]").description("An array of books")) // <1> + .andWithPrefix("[].", book))); // <2> // end::book-array[] } public void fieldsSubsection() throws Exception { // tag::fields-subsection[] - this.mockMvc.perform(get("/locations/1").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("location", - responseFields(beneathPath("weather.temperature"), // <1> - fieldWithPath("high").description( - "The forecast high in degrees celcius"), // <2> - fieldWithPath("low") - .description("The forecast low in degrees celcius")))); + this.mockMvc.perform(get("/locations/1").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("location", responseFields(beneathPath("weather.temperature"), // <1> + fieldWithPath("high").description("The forecast high in degrees celcius"), // <2> + fieldWithPath("low").description("The forecast low in degrees celcius")))); // end::fields-subsection[] } public void bodySubsection() throws Exception { // tag::body-subsection[] - this.mockMvc.perform(get("/locations/1").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(document("location", - responseBody(beneathPath("weather.temperature")))); // <1> + this.mockMvc.perform(get("/locations/1").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .andDo(document("location", responseBody(beneathPath("weather.temperature")))); // <1> // end::body-subsection[] } diff --git a/docs/src/test/java/com/example/mockmvc/PerTestPreprocessing.java b/docs/src/test/java/com/example/mockmvc/PerTestPreprocessing.java index 90eab9c9..c39db4db 100644 --- a/docs/src/test/java/com/example/mockmvc/PerTestPreprocessing.java +++ b/docs/src/test/java/com/example/mockmvc/PerTestPreprocessing.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -33,8 +33,8 @@ public class PerTestPreprocessing { public void general() throws Exception { // tag::preprocessing[] this.mockMvc.perform(get("/")).andExpect(status().isOk()) - .andDo(document("index", preprocessRequest(removeHeaders("Foo")), // <1> - preprocessResponse(prettyPrint()))); // <2> + .andDo(document("index", preprocessRequest(removeHeaders("Foo")), // <1> + preprocessResponse(prettyPrint()))); // <2> // end::preprocessing[] } diff --git a/docs/src/test/java/com/example/mockmvc/RequestParameters.java b/docs/src/test/java/com/example/mockmvc/RequestParameters.java index aea22173..1f206a94 100644 --- a/docs/src/test/java/com/example/mockmvc/RequestParameters.java +++ b/docs/src/test/java/com/example/mockmvc/RequestParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -16,6 +16,8 @@ package com.example.mockmvc; +import org.springframework.test.web.servlet.MockMvc; + import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; @@ -23,8 +25,6 @@ import static org.springframework.restdocs.request.RequestDocumentation.paramete import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.springframework.test.web.servlet.MockMvc; - public class RequestParameters { private MockMvc mockMvc; @@ -32,21 +32,18 @@ public class RequestParameters { public void getQueryStringSnippet() throws Exception { // tag::request-parameters-query-string[] this.mockMvc.perform(get("/users?page=2&per_page=100")) // <1> - .andExpect(status().isOk()) - .andDo(document("users", requestParameters( // <2> - parameterWithName("page").description("The page to retrieve"), // <3> - parameterWithName("per_page").description("Entries per page") // <4> - ))); + .andExpect(status().isOk()).andDo(document("users", requestParameters(// <2> + parameterWithName("page").description("The page to retrieve"), // <3> + parameterWithName("per_page").description("Entries per page") // <4> + ))); // end::request-parameters-query-string[] } public void postFormDataSnippet() throws Exception { // tag::request-parameters-form-data[] this.mockMvc.perform(post("/users").param("username", "Tester")) // <1> - .andExpect(status().isCreated()) - .andDo(document("create-user", requestParameters( - parameterWithName("username").description("The user's username") - ))); + .andExpect(status().isCreated()).andDo(document("create-user", + requestParameters(parameterWithName("username").description("The user's username")))); // end::request-parameters-form-data[] } diff --git a/docs/src/test/java/com/example/mockmvc/RequestPartPayload.java b/docs/src/test/java/com/example/mockmvc/RequestPartPayload.java index 1b1ee295..34e82d2e 100644 --- a/docs/src/test/java/com/example/mockmvc/RequestPartPayload.java +++ b/docs/src/test/java/com/example/mockmvc/RequestPartPayload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -33,30 +33,24 @@ public class RequestPartPayload { public void fields() throws Exception { // tag::fields[] - MockMultipartFile image = new MockMultipartFile("image", "image.png", "image/png", - "<>".getBytes()); - MockMultipartFile metadata = new MockMultipartFile("metadata", "", - "application/json", "{ \"version\": \"1.0\"}".getBytes()); + MockMultipartFile image = new MockMultipartFile("image", "image.png", "image/png", "<>".getBytes()); + MockMultipartFile metadata = new MockMultipartFile("metadata", "", "application/json", + "{ \"version\": \"1.0\"}".getBytes()); - this.mockMvc.perform(fileUpload("/images").file(image).file(metadata) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("image-upload", requestPartFields("metadata", // <1> - fieldWithPath("version").description("The version of the image")))); // <2> + this.mockMvc.perform(fileUpload("/images").file(image).file(metadata).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andDo(document("image-upload", requestPartFields("metadata", // <1> + fieldWithPath("version").description("The version of the image")))); // <2> // end::fields[] } public void body() throws Exception { // tag::body[] - MockMultipartFile image = new MockMultipartFile("image", "image.png", "image/png", - "<>".getBytes()); - MockMultipartFile metadata = new MockMultipartFile("metadata", "", - "application/json", "{ \"version\": \"1.0\"}".getBytes()); + MockMultipartFile image = new MockMultipartFile("image", "image.png", "image/png", "<>".getBytes()); + MockMultipartFile metadata = new MockMultipartFile("metadata", "", "application/json", + "{ \"version\": \"1.0\"}".getBytes()); - this.mockMvc.perform(fileUpload("/images").file(image).file(metadata) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document("image-upload", requestPartBody("metadata"))); // <1> + this.mockMvc.perform(fileUpload("/images").file(image).file(metadata).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andDo(document("image-upload", requestPartBody("metadata"))); // <1> // end::body[] } diff --git a/docs/src/test/java/com/example/mockmvc/RequestParts.java b/docs/src/test/java/com/example/mockmvc/RequestParts.java index 3f17dd03..888b6c01 100644 --- a/docs/src/test/java/com/example/mockmvc/RequestParts.java +++ b/docs/src/test/java/com/example/mockmvc/RequestParts.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2021 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. @@ -31,10 +31,9 @@ public class RequestParts { public void upload() throws Exception { // tag::request-parts[] this.mockMvc.perform(multipart("/upload").file("file", "example".getBytes())) // <1> - .andExpect(status().isOk()) - .andDo(document("upload", requestParts( // <2> - partWithName("file").description("The file to upload")) // <3> - )); + .andExpect(status().isOk()).andDo(document("upload", requestParts(// <2> + partWithName("file").description("The file to upload")) // <3> + )); // end::request-parts[] } diff --git a/docs/src/test/java/com/example/restassured/CustomDefaultOperationPreprocessors.java b/docs/src/test/java/com/example/restassured/CustomDefaultOperationPreprocessors.java index f34181e0..cfcdc90d 100644 --- a/docs/src/test/java/com/example/restassured/CustomDefaultOperationPreprocessors.java +++ b/docs/src/test/java/com/example/restassured/CustomDefaultOperationPreprocessors.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -39,10 +39,10 @@ public class CustomDefaultOperationPreprocessors { public void setup() { // tag::custom-default-operation-preprocessors[] this.spec = new RequestSpecBuilder() - .addFilter(documentationConfiguration(this.restDocumentation).operationPreprocessors() - .withRequestDefaults(removeHeaders("Foo")) // <1> - .withResponseDefaults(prettyPrint())) // <2> - .build(); + .addFilter(documentationConfiguration(this.restDocumentation).operationPreprocessors() + .withRequestDefaults(removeHeaders("Foo")) // <1> + .withResponseDefaults(prettyPrint())) // <2> + .build(); // end::custom-default-operation-preprocessors[] } diff --git a/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java b/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java index b79df859..d236d109 100644 --- a/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java +++ b/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -38,8 +38,7 @@ public class CustomDefaultSnippets { public void setUp() { // tag::custom-default-snippets[] this.spec = new RequestSpecBuilder() - .addFilter(documentationConfiguration(this.restDocumentation).snippets() - .withDefaults(curlRequest())) + .addFilter(documentationConfiguration(this.restDocumentation).snippets().withDefaults(curlRequest())) .build(); // end::custom-default-snippets[] } diff --git a/docs/src/test/java/com/example/restassured/CustomEncoding.java b/docs/src/test/java/com/example/restassured/CustomEncoding.java index bb61ccd3..8c503086 100644 --- a/docs/src/test/java/com/example/restassured/CustomEncoding.java +++ b/docs/src/test/java/com/example/restassured/CustomEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -37,8 +37,7 @@ public class CustomEncoding { public void setUp() { // tag::custom-encoding[] this.spec = new RequestSpecBuilder() - .addFilter(documentationConfiguration(this.restDocumentation) - .snippets().withEncoding("ISO-8859-1")) + .addFilter(documentationConfiguration(this.restDocumentation).snippets().withEncoding("ISO-8859-1")) .build(); // end::custom-encoding[] } diff --git a/docs/src/test/java/com/example/restassured/CustomFormat.java b/docs/src/test/java/com/example/restassured/CustomFormat.java index c79f0d56..63bcb6a6 100644 --- a/docs/src/test/java/com/example/restassured/CustomFormat.java +++ b/docs/src/test/java/com/example/restassured/CustomFormat.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -37,10 +37,8 @@ public class CustomFormat { @Before public void setUp() { // tag::custom-format[] - this.spec = new RequestSpecBuilder() - .addFilter(documentationConfiguration(this.restDocumentation) - .snippets().withTemplateFormat(TemplateFormats.markdown())) - .build(); + this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(this.restDocumentation).snippets() + .withTemplateFormat(TemplateFormats.markdown())).build(); // end::custom-format[] } diff --git a/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java b/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java index 0cabb95b..f92d6e36 100644 --- a/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java +++ b/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -43,20 +43,18 @@ public class EveryTestPreprocessing { @Before public void setup() { this.spec = new RequestSpecBuilder() - .addFilter(documentationConfiguration(this.restDocumentation).operationPreprocessors() - .withRequestDefaults(removeHeaders("Foo")) // <1> - .withResponseDefaults(prettyPrint())) // <2> - .build(); + .addFilter(documentationConfiguration(this.restDocumentation).operationPreprocessors() + .withRequestDefaults(removeHeaders("Foo")) // <1> + .withResponseDefaults(prettyPrint())) // <2> + .build(); } // end::setup[] public void use() throws Exception { // tag::use[] RestAssured.given(this.spec) - .filter(document("index", - links(linkWithRel("self").description("Canonical self link")))) - .when().get("/") - .then().assertThat().statusCode(is(200)); + .filter(document("index", links(linkWithRel("self").description("Canonical self link")))).when() + .get("/").then().assertThat().statusCode(is(200)); // end::use[] } diff --git a/docs/src/test/java/com/example/restassured/ExampleApplicationJUnit5Tests.java b/docs/src/test/java/com/example/restassured/ExampleApplicationJUnit5Tests.java index 1002a9a3..275e591e 100644 --- a/docs/src/test/java/com/example/restassured/ExampleApplicationJUnit5Tests.java +++ b/docs/src/test/java/com/example/restassured/ExampleApplicationJUnit5Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -35,9 +35,9 @@ public class ExampleApplicationJUnit5Tests { @BeforeEach public void setUp(RestDocumentationContextProvider restDocumentation) { - this.spec = new RequestSpecBuilder() - .addFilter(documentationConfiguration(restDocumentation)) // <1> + this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(restDocumentation)) // <1> .build(); } // end::setup[] + } diff --git a/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java b/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java index a88177af..22af139a 100644 --- a/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java +++ b/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -37,9 +37,7 @@ public class ExampleApplicationTestNgTests { @BeforeMethod public void setUp(Method method) { - this.spec = new RequestSpecBuilder().addFilter( - documentationConfiguration(this.restDocumentation)) - .build(); + this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(this.restDocumentation)).build(); this.restDocumentation.beforeTest(getClass(), method.getName()); } @@ -51,4 +49,5 @@ public class ExampleApplicationTestNgTests { this.restDocumentation.afterTest(); } // end::teardown[] + } diff --git a/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java b/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java index 882f19cc..1df00b12 100644 --- a/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java +++ b/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -36,9 +36,9 @@ public class ExampleApplicationTests { @Before public void setUp() { - this.spec = new RequestSpecBuilder().addFilter( - documentationConfiguration(this.restDocumentation)) // <1> + this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(this.restDocumentation)) // <1> .build(); } // end::setup[] + } diff --git a/docs/src/test/java/com/example/restassured/HttpHeaders.java b/docs/src/test/java/com/example/restassured/HttpHeaders.java index 8c4ab223..09bcaf68 100644 --- a/docs/src/test/java/com/example/restassured/HttpHeaders.java +++ b/docs/src/test/java/com/example/restassured/HttpHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -31,21 +31,18 @@ public class HttpHeaders { public void headers() throws Exception { // tag::headers[] - RestAssured.given(this.spec) - .filter(document("headers", - requestHeaders( // <1> - headerWithName("Authorization").description( - "Basic auth credentials")), // <2> - responseHeaders( // <3> - headerWithName("X-RateLimit-Limit").description( - "The total number of requests permitted per period"), - headerWithName("X-RateLimit-Remaining").description( - "Remaining requests permitted in current period"), - headerWithName("X-RateLimit-Reset").description( - "Time at which the rate limit period will reset")))) - .header("Authorization", "Basic dXNlcjpzZWNyZXQ=") // <4> - .when().get("/people") - .then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).filter(document("headers", requestHeaders(// <1> + headerWithName("Authorization").description("Basic auth credentials")), // <2> + responseHeaders(// <3> + headerWithName("X-RateLimit-Limit") + .description("The total number of requests permitted per period"), + headerWithName("X-RateLimit-Remaining") + .description("Remaining requests permitted in current period"), + headerWithName("X-RateLimit-Reset") + .description("Time at which the rate limit period will reset")))) + .header("Authorization", "Basic dXNlcjpzZWNyZXQ=") // <4> + .when().get("/people").then().assertThat().statusCode(is(200)); // end::headers[] } + } diff --git a/docs/src/test/java/com/example/restassured/Hypermedia.java b/docs/src/test/java/com/example/restassured/Hypermedia.java index 7953de2c..1d013702 100644 --- a/docs/src/test/java/com/example/restassured/Hypermedia.java +++ b/docs/src/test/java/com/example/restassured/Hypermedia.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -31,24 +31,21 @@ public class Hypermedia { public void defaultExtractor() throws Exception { // tag::links[] - RestAssured.given(this.spec) - .accept("application/json") - .filter(document("index", links( // <1> - linkWithRel("alpha").description("Link to the alpha resource"), // <2> - linkWithRel("bravo").description("Link to the bravo resource")))) // <3> - .get("/").then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).accept("application/json").filter(document("index", links(// <1> + linkWithRel("alpha").description("Link to the alpha resource"), // <2> + linkWithRel("bravo").description("Link to the bravo resource")))) // <3> + .get("/").then().assertThat().statusCode(is(200)); // end::links[] } public void explicitExtractor() throws Exception { - RestAssured.given(this.spec) - .accept("application/json") - // tag::explicit-extractor[] - .filter(document("index", links(halLinks(), // <1> - linkWithRel("alpha").description("Link to the alpha resource"), - linkWithRel("bravo").description("Link to the bravo resource")))) - // end::explicit-extractor[] - .get("/").then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).accept("application/json") + // tag::explicit-extractor[] + .filter(document("index", links(halLinks(), // <1> + linkWithRel("alpha").description("Link to the alpha resource"), + linkWithRel("bravo").description("Link to the bravo resource")))) + // end::explicit-extractor[] + .get("/").then().assertThat().statusCode(is(200)); } } diff --git a/docs/src/test/java/com/example/restassured/InvokeService.java b/docs/src/test/java/com/example/restassured/InvokeService.java index 62d22f4d..5937b15a 100644 --- a/docs/src/test/java/com/example/restassured/InvokeService.java +++ b/docs/src/test/java/com/example/restassured/InvokeService.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -35,4 +35,5 @@ public class InvokeService { .then().assertThat().statusCode(is(200)); // <5> // end::invoke-service[] } + } diff --git a/docs/src/test/java/com/example/restassured/ParameterizedOutput.java b/docs/src/test/java/com/example/restassured/ParameterizedOutput.java index 8b0384f9..8626345d 100644 --- a/docs/src/test/java/com/example/restassured/ParameterizedOutput.java +++ b/docs/src/test/java/com/example/restassured/ParameterizedOutput.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -37,8 +37,7 @@ public class ParameterizedOutput { // tag::parameterized-output[] @Before public void setUp() { - this.spec = new RequestSpecBuilder() - .addFilter(documentationConfiguration(this.restDocumentation)) + this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(this.restDocumentation)) .addFilter(document("{method-name}/{step}")).build(); } // end::parameterized-output[] diff --git a/docs/src/test/java/com/example/restassured/PathParameters.java b/docs/src/test/java/com/example/restassured/PathParameters.java index 1dfc9352..0da95f00 100644 --- a/docs/src/test/java/com/example/restassured/PathParameters.java +++ b/docs/src/test/java/com/example/restassured/PathParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -30,12 +30,12 @@ public class PathParameters { public void pathParametersSnippet() throws Exception { // tag::path-parameters[] - RestAssured.given(this.spec) - .filter(document("locations", pathParameters( // <1> - parameterWithName("latitude").description("The location's latitude"), // <2> - parameterWithName("longitude").description("The location's longitude")))) // <3> - .when().get("/locations/{latitude}/{longitude}", 51.5072, 0.1275) // <4> - .then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).filter(document("locations", pathParameters(// <1> + parameterWithName("latitude").description("The location's latitude"), // <2> + parameterWithName("longitude").description("The location's longitude")))) // <3> + .when().get("/locations/{latitude}/{longitude}", 51.5072, 0.1275) // <4> + .then().assertThat().statusCode(is(200)); // end::path-parameters[] } + } diff --git a/docs/src/test/java/com/example/restassured/Payload.java b/docs/src/test/java/com/example/restassured/Payload.java index b9e92f4c..22dfb5d7 100644 --- a/docs/src/test/java/com/example/restassured/Payload.java +++ b/docs/src/test/java/com/example/restassured/Payload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -39,92 +39,76 @@ public class Payload { public void response() throws Exception { // tag::response[] - RestAssured.given(this.spec).accept("application/json") - .filter(document("user", responseFields( // <1> - fieldWithPath("contact.name").description("The user's name"), // <2> - fieldWithPath("contact.email").description("The user's email address")))) // <3> - .when().get("/user/5") - .then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).accept("application/json").filter(document("user", responseFields(// <1> + fieldWithPath("contact.name").description("The user's name"), // <2> + fieldWithPath("contact.email").description("The user's email address")))) // <3> + .when().get("/user/5").then().assertThat().statusCode(is(200)); // end::response[] } public void subsection() throws Exception { // tag::subsection[] RestAssured.given(this.spec).accept("application/json") - .filter(document("user", responseFields( - subsectionWithPath("contact").description("The user's contact details")))) // <1> - .when().get("/user/5") - .then().assertThat().statusCode(is(200)); + .filter(document("user", + responseFields(subsectionWithPath("contact").description("The user's contact details")))) // <1> + .when().get("/user/5").then().assertThat().statusCode(is(200)); // end::subsection[] } public void explicitType() throws Exception { RestAssured.given(this.spec).accept("application/json") - // tag::explicit-type[] - .filter(document("user", responseFields( - fieldWithPath("contact.email") - .type(JsonFieldType.STRING) // <1> - .description("The user's email address")))) - // end::explicit-type[] - .when().get("/user/5") - .then().assertThat().statusCode(is(200)); + // tag::explicit-type[] + .filter(document("user", responseFields(fieldWithPath("contact.email").type(JsonFieldType.STRING) // <1> + .description("The user's email address")))) + // end::explicit-type[] + .when().get("/user/5").then().assertThat().statusCode(is(200)); } public void constraints() throws Exception { RestAssured.given(this.spec).accept("application/json") - // tag::constraints[] - .filter(document("create-user", requestFields( - attributes(key("title").value("Fields for user creation")), // <1> - fieldWithPath("name").description("The user's name") - .attributes(key("constraints") - .value("Must not be null. Must not be empty")), // <2> - fieldWithPath("email").description("The user's email address") - .attributes(key("constraints") - .value("Must be a valid email address"))))) // <3> - // end::constraints[] - .when().post("/users") - .then().assertThat().statusCode(is(200)); + // tag::constraints[] + .filter(document("create-user", + requestFields(attributes(key("title").value("Fields for user creation")), // <1> + fieldWithPath("name").description("The user's name") + .attributes(key("constraints").value("Must not be null. Must not be empty")), // <2> + fieldWithPath("email").description("The user's email address") + .attributes(key("constraints").value("Must be a valid email address"))))) // <3> + // end::constraints[] + .when().post("/users").then().assertThat().statusCode(is(200)); } public void descriptorReuse() throws Exception { - FieldDescriptor[] book = new FieldDescriptor[] { - fieldWithPath("title").description("Title of the book"), + FieldDescriptor[] book = new FieldDescriptor[] { fieldWithPath("title").description("Title of the book"), fieldWithPath("author").description("Author of the book") }; // tag::single-book[] - RestAssured.given(this.spec).accept("application/json") - .filter(document("book", responseFields(book))) // <1> - .when().get("/books/1") - .then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).accept("application/json").filter(document("book", responseFields(book))) // <1> + .when().get("/books/1").then().assertThat().statusCode(is(200)); // end::single-book[] // tag::book-array[] RestAssured.given(this.spec).accept("application/json") - .filter(document("books", responseFields( - fieldWithPath("[]").description("An array of books")) // <1> - .andWithPrefix("[].", book))) // <2> - .when().get("/books") - .then().assertThat().statusCode(is(200)); + .filter(document("books", responseFields(fieldWithPath("[]").description("An array of books")) // <1> + .andWithPrefix("[].", book))) // <2> + .when().get("/books").then().assertThat().statusCode(is(200)); // end::book-array[] } public void fieldsSubsection() throws Exception { // tag::fields-subsection[] RestAssured.given(this.spec).accept("application/json") - .filter(document("location", responseFields(beneathPath("weather.temperature"), // <1> - fieldWithPath("high").description("The forecast high in degrees celcius"), // <2> - fieldWithPath("low").description("The forecast low in degrees celcius")))) - .when().get("/locations/1") - .then().assertThat().statusCode(is(200)); + .filter(document("location", responseFields(beneathPath("weather.temperature"), // <1> + fieldWithPath("high").description("The forecast high in degrees celcius"), // <2> + fieldWithPath("low").description("The forecast low in degrees celcius")))) + .when().get("/locations/1").then().assertThat().statusCode(is(200)); // end::fields-subsection[] } public void bodySubsection() throws Exception { // tag::body-subsection[] RestAssured.given(this.spec).accept("application/json") - .filter(document("location", responseBody(beneathPath("weather.temperature")))) // <1> - .when().get("/locations/1") - .then().assertThat().statusCode(is(200)); + .filter(document("location", responseBody(beneathPath("weather.temperature")))) // <1> + .when().get("/locations/1").then().assertThat().statusCode(is(200)); // end::body-subsection[] } diff --git a/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java b/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java index c523fe22..2f63dfc9 100644 --- a/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java +++ b/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -32,11 +32,9 @@ public class PerTestPreprocessing { public void general() throws Exception { // tag::preprocessing[] - RestAssured.given(this.spec) - .filter(document("index", preprocessRequest(removeHeaders("Foo")), // <1> - preprocessResponse(prettyPrint()))) // <2> - .when().get("/") - .then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).filter(document("index", preprocessRequest(removeHeaders("Foo")), // <1> + preprocessResponse(prettyPrint()))) // <2> + .when().get("/").then().assertThat().statusCode(is(200)); // end::preprocessing[] } diff --git a/docs/src/test/java/com/example/restassured/RequestParameters.java b/docs/src/test/java/com/example/restassured/RequestParameters.java index 6c8349c8..40a48fa7 100644 --- a/docs/src/test/java/com/example/restassured/RequestParameters.java +++ b/docs/src/test/java/com/example/restassured/RequestParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -30,23 +30,22 @@ public class RequestParameters { public void getQueryStringSnippet() throws Exception { // tag::request-parameters-query-string[] - RestAssured.given(this.spec) - .filter(document("users", requestParameters( // <1> - parameterWithName("page").description("The page to retrieve"), // <2> - parameterWithName("per_page").description("Entries per page")))) // <3> - .when().get("/users?page=2&per_page=100") // <4> - .then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).filter(document("users", requestParameters(// <1> + parameterWithName("page").description("The page to retrieve"), // <2> + parameterWithName("per_page").description("Entries per page")))) // <3> + .when().get("/users?page=2&per_page=100") // <4> + .then().assertThat().statusCode(is(200)); // end::request-parameters-query-string[] } public void postFormDataSnippet() throws Exception { // tag::request-parameters-form-data[] RestAssured.given(this.spec) - .filter(document("create-user", requestParameters( - parameterWithName("username").description("The user's username")))) - .formParam("username", "Tester") // <1> - .when().post("/users") // <2> - .then().assertThat().statusCode(is(200)); + .filter(document("create-user", + requestParameters(parameterWithName("username").description("The user's username")))) + .formParam("username", "Tester") // <1> + .when().post("/users") // <2> + .then().assertThat().statusCode(is(200)); // end::request-parameters-form-data[] } diff --git a/docs/src/test/java/com/example/restassured/RequestPartPayload.java b/docs/src/test/java/com/example/restassured/RequestPartPayload.java index e4f857be..5dcfc7fc 100644 --- a/docs/src/test/java/com/example/restassured/RequestPartPayload.java +++ b/docs/src/test/java/com/example/restassured/RequestPartPayload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -38,11 +38,10 @@ public class RequestPartPayload { Map metadata = new HashMap<>(); metadata.put("version", "1.0"); RestAssured.given(this.spec).accept("application/json") - .filter(document("image-upload", requestPartFields("metadata", // <1> - fieldWithPath("version").description("The version of the image")))) // <2> - .when().multiPart("image", new File("image.png"), "image/png") - .multiPart("metadata", metadata).post("images") - .then().assertThat().statusCode(is(200)); + .filter(document("image-upload", requestPartFields("metadata", // <1> + fieldWithPath("version").description("The version of the image")))) // <2> + .when().multiPart("image", new File("image.png"), "image/png").multiPart("metadata", metadata) + .post("images").then().assertThat().statusCode(is(200)); // end::fields[] } @@ -51,10 +50,9 @@ public class RequestPartPayload { Map metadata = new HashMap<>(); metadata.put("version", "1.0"); RestAssured.given(this.spec).accept("application/json") - .filter(document("image-upload", requestPartBody("metadata"))) // <1> - .when().multiPart("image", new File("image.png"), "image/png") - .multiPart("metadata", metadata).post("images") - .then().assertThat().statusCode(is(200)); + .filter(document("image-upload", requestPartBody("metadata"))) // <1> + .when().multiPart("image", new File("image.png"), "image/png").multiPart("metadata", metadata) + .post("images").then().assertThat().statusCode(is(200)); // end::body[] } diff --git a/docs/src/test/java/com/example/restassured/RequestParts.java b/docs/src/test/java/com/example/restassured/RequestParts.java index 9bb5803e..70059b12 100644 --- a/docs/src/test/java/com/example/restassured/RequestParts.java +++ b/docs/src/test/java/com/example/restassured/RequestParts.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -30,12 +30,11 @@ public class RequestParts { public void upload() throws Exception { // tag::request-parts[] - RestAssured.given(this.spec) - .filter(document("users", requestParts( // <1> - partWithName("file").description("The file to upload")))) // <2> - .multiPart("file", "example") // <3> - .when().post("/upload") // <4> - .then().statusCode(is(200)); + RestAssured.given(this.spec).filter(document("users", requestParts(// <1> + partWithName("file").description("The file to upload")))) // <2> + .multiPart("file", "example") // <3> + .when().post("/upload") // <4> + .then().statusCode(is(200)); // end::request-parts[] } diff --git a/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java b/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java index b460ea27..1668cc5e 100644 --- a/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java +++ b/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -30,12 +30,10 @@ public class RestAssuredSnippetReuse extends SnippetReuse { public void documentation() throws Exception { // tag::use[] - RestAssured.given(this.spec) - .accept("application/json") - .filter(document("example", this.pagingLinks.and( // <1> - linkWithRel("alpha").description("Link to the alpha resource"), - linkWithRel("bravo").description("Link to the bravo resource")))) - .get("/").then().assertThat().statusCode(is(200)); + RestAssured.given(this.spec).accept("application/json").filter(document("example", this.pagingLinks.and(// <1> + linkWithRel("alpha").description("Link to the alpha resource"), + linkWithRel("bravo").description("Link to the bravo resource")))).get("/").then().assertThat() + .statusCode(is(200)); // end::use[] } diff --git a/docs/src/test/java/com/example/webtestclient/CustomUriConfiguration.java b/docs/src/test/java/com/example/webtestclient/CustomUriConfiguration.java index d987e418..c82caad7 100644 --- a/docs/src/test/java/com/example/webtestclient/CustomUriConfiguration.java +++ b/docs/src/test/java/com/example/webtestclient/CustomUriConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2021 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. @@ -40,10 +40,9 @@ public class CustomUriConfiguration { // tag::custom-uri-configuration[] @Before public void setUp() { - this.webTestClient = WebTestClient.bindToApplicationContext(this.context) - .configureClient() - .baseUrl("https://api.example.com") // <1> - .filter(documentationConfiguration(this.restDocumentation)).build(); + this.webTestClient = WebTestClient.bindToApplicationContext(this.context).configureClient() + .baseUrl("https://api.example.com") // <1> + .filter(documentationConfiguration(this.restDocumentation)).build(); } // end::custom-uri-configuration[] diff --git a/docs/src/test/java/com/example/webtestclient/ExampleApplicationJUnit5Tests.java b/docs/src/test/java/com/example/webtestclient/ExampleApplicationJUnit5Tests.java index e17cef67..10379ab4 100644 --- a/docs/src/test/java/com/example/webtestclient/ExampleApplicationJUnit5Tests.java +++ b/docs/src/test/java/com/example/webtestclient/ExampleApplicationJUnit5Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2021 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. @@ -34,10 +34,8 @@ public class ExampleApplicationJUnit5Tests { private WebTestClient webTestClient; @BeforeEach - public void setUp(ApplicationContext applicationContext, - RestDocumentationContextProvider restDocumentation) { - this.webTestClient = WebTestClient.bindToApplicationContext(applicationContext) - .configureClient() + public void setUp(ApplicationContext applicationContext, RestDocumentationContextProvider restDocumentation) { + this.webTestClient = WebTestClient.bindToApplicationContext(applicationContext).configureClient() .filter(documentationConfiguration(restDocumentation)) // <1> .build(); } diff --git a/docs/src/test/java/com/example/webtestclient/ExampleApplicationTestNgTests.java b/docs/src/test/java/com/example/webtestclient/ExampleApplicationTestNgTests.java index dac8f272..cad6efb0 100644 --- a/docs/src/test/java/com/example/webtestclient/ExampleApplicationTestNgTests.java +++ b/docs/src/test/java/com/example/webtestclient/ExampleApplicationTestNgTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2021 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. @@ -41,8 +41,7 @@ public class ExampleApplicationTestNgTests { @BeforeMethod public void setUp(Method method) { - this.webTestClient = WebTestClient.bindToApplicationContext(this.context) - .configureClient() + this.webTestClient = WebTestClient.bindToApplicationContext(this.context).configureClient() .filter(documentationConfiguration(this.restDocumentation)) // <1> .build(); this.restDocumentation.beforeTest(getClass(), method.getName()); diff --git a/docs/src/test/java/com/example/webtestclient/ExampleApplicationTests.java b/docs/src/test/java/com/example/webtestclient/ExampleApplicationTests.java index 4438632c..980b540a 100644 --- a/docs/src/test/java/com/example/webtestclient/ExampleApplicationTests.java +++ b/docs/src/test/java/com/example/webtestclient/ExampleApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2021 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. @@ -40,8 +40,7 @@ public class ExampleApplicationTests { @Before public void setUp() { - this.webTestClient = WebTestClient.bindToApplicationContext(this.context) - .configureClient() + this.webTestClient = WebTestClient.bindToApplicationContext(this.context).configureClient() .filter(documentationConfiguration(this.restDocumentation)) // <1> .build(); } diff --git a/docs/src/test/java/com/example/webtestclient/HttpHeaders.java b/docs/src/test/java/com/example/webtestclient/HttpHeaders.java index 6d709c08..7f8a2c0b 100644 --- a/docs/src/test/java/com/example/webtestclient/HttpHeaders.java +++ b/docs/src/test/java/com/example/webtestclient/HttpHeaders.java @@ -35,9 +35,9 @@ public class HttpHeaders { .get().uri("/people").header("Authorization", "Basic dXNlcjpzZWNyZXQ=") // <1> .exchange().expectStatus().isOk().expectBody() .consumeWith(document("headers", - requestHeaders( // <2> + requestHeaders(// <2> headerWithName("Authorization").description("Basic auth credentials")), // <3> - responseHeaders( // <4> + responseHeaders(// <4> headerWithName("X-RateLimit-Limit") .description("The total number of requests permitted per period"), headerWithName("X-RateLimit-Remaining") diff --git a/docs/src/test/java/com/example/webtestclient/Hypermedia.java b/docs/src/test/java/com/example/webtestclient/Hypermedia.java index f4852fbe..be247cb0 100644 --- a/docs/src/test/java/com/example/webtestclient/Hypermedia.java +++ b/docs/src/test/java/com/example/webtestclient/Hypermedia.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2021 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. @@ -30,21 +30,20 @@ public class Hypermedia { public void defaultExtractor() throws Exception { // tag::links[] - this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange() - .expectStatus().isOk().expectBody() - .consumeWith(document("index",links( // <1> - linkWithRel("alpha").description("Link to the alpha resource"), // <2> - linkWithRel("bravo").description("Link to the bravo resource")))); // <3> + this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk() + .expectBody().consumeWith(document("index", links(// <1> + linkWithRel("alpha").description("Link to the alpha resource"), // <2> + linkWithRel("bravo").description("Link to the bravo resource")))); // <3> // end::links[] } public void explicitExtractor() throws Exception { - this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange() - .expectStatus().isOk().expectBody() - // tag::explicit-extractor[] - .consumeWith(document("index",links(halLinks(), // <1> - linkWithRel("alpha").description("Link to the alpha resource"), - linkWithRel("bravo").description("Link to the bravo resource")))); + this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk() + .expectBody() + // tag::explicit-extractor[] + .consumeWith(document("index", links(halLinks(), // <1> + linkWithRel("alpha").description("Link to the alpha resource"), + linkWithRel("bravo").description("Link to the bravo resource")))); // end::explicit-extractor[] } diff --git a/docs/src/test/java/com/example/webtestclient/PathParameters.java b/docs/src/test/java/com/example/webtestclient/PathParameters.java index feef547f..6627c701 100644 --- a/docs/src/test/java/com/example/webtestclient/PathParameters.java +++ b/docs/src/test/java/com/example/webtestclient/PathParameters.java @@ -33,7 +33,7 @@ public class PathParameters { this.webTestClient.get().uri("/locations/{latitude}/{longitude}", 51.5072, 0.1275) // <1> .exchange().expectStatus().isOk().expectBody() .consumeWith(document("locations", - pathParameters( // <2> + pathParameters(// <2> parameterWithName("latitude").description("The location's latitude"), // <3> parameterWithName("longitude").description("The location's longitude")))); // <4> // end::path-parameters[] diff --git a/docs/src/test/java/com/example/webtestclient/Payload.java b/docs/src/test/java/com/example/webtestclient/Payload.java index e648c373..e9b116f5 100644 --- a/docs/src/test/java/com/example/webtestclient/Payload.java +++ b/docs/src/test/java/com/example/webtestclient/Payload.java @@ -42,7 +42,7 @@ public class Payload { this.webTestClient.get().uri("user/5").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody() .consumeWith(document("user", - responseFields( // <1> + responseFields(// <1> fieldWithPath("contact.email").description("The user's email address"), // <2> fieldWithPath("contact.name").description("The user's name")))); // <3> // end::response[] diff --git a/docs/src/test/java/com/example/webtestclient/RequestParameters.java b/docs/src/test/java/com/example/webtestclient/RequestParameters.java index 4fe3454b..aa312832 100644 --- a/docs/src/test/java/com/example/webtestclient/RequestParameters.java +++ b/docs/src/test/java/com/example/webtestclient/RequestParameters.java @@ -35,7 +35,7 @@ public class RequestParameters { // tag::request-parameters-query-string[] this.webTestClient.get().uri("/users?page=2&per_page=100") // <1> .exchange().expectStatus().isOk().expectBody() - .consumeWith(document("users", requestParameters( // <2> + .consumeWith(document("users", requestParameters(// <2> parameterWithName("page").description("The page to retrieve"), // <3> parameterWithName("per_page").description("Entries per page") // <4> ))); diff --git a/docs/src/test/java/com/example/webtestclient/RequestParts.java b/docs/src/test/java/com/example/webtestclient/RequestParts.java index 5677f2bc..e1115fb8 100644 --- a/docs/src/test/java/com/example/webtestclient/RequestParts.java +++ b/docs/src/test/java/com/example/webtestclient/RequestParts.java @@ -37,7 +37,7 @@ public class RequestParts { multipartData.add("file", "example".getBytes()); this.webTestClient.post().uri("/upload").body(BodyInserters.fromMultipartData(multipartData)) // <1> .exchange().expectStatus().isOk().expectBody() - .consumeWith(document("upload", requestParts( // <2> + .consumeWith(document("upload", requestParts(// <2> partWithName("file").description("The file to upload")) // <3> )); // end::request-parts[] diff --git a/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java b/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java index 7c4ec521..110835b4 100644 --- a/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java +++ b/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java @@ -34,7 +34,7 @@ public class WebTestClientSnippetReuse extends SnippetReuse { // tag::use[] this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange() .expectStatus().isOk().expectBody() - .consumeWith(document("example", this.pagingLinks.and( // <1> + .consumeWith(document("example", this.pagingLinks.and(// <1> linkWithRel("alpha").description("Link to the alpha resource"), linkWithRel("bravo").description("Link to the bravo resource")))); // end::use[] diff --git a/gradle.properties b/gradle.properties index fe72b41c..c590ff5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,8 @@ -org.gradle.daemon=false version=2.0.6.BUILD-SNAPSHOT +org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 +org.gradle.parallel=true + asciidoctorj15Version=1.5.8.1 asciidoctorj16Version=1.6.2 asciidoctorj20Version=2.0.0 @@ -9,4 +11,5 @@ asciidoctorj22Version=2.2.0 asciidoctorj23Version=2.3.0 asciidoctorj24Version=2.4.2 -javaFormatVersion=0.0.15 +javaFormatVersion=0.0.27 +jmustacheVersion=1.12 diff --git a/gradle/publish-maven.gradle b/gradle/publish-maven.gradle index 94b5e564..c6460c32 100644 --- a/gradle/publish-maven.gradle +++ b/gradle/publish-maven.gradle @@ -1,45 +1,49 @@ -install { - repositories.mavenInstaller { - customizePom(pom, project) +plugins.withType(MavenPublishPlugin) { + publishing { + publications { + maven(MavenPublication) { publication -> + from components.java + versionMapping { + usage("java-api") { + fromResolutionResult() + } + usage("java-runtime") { + fromResolutionResult() + } + } + pom { + name = project.provider { project.description } + description = project.provider { project.description } + url = "https://github.com/spring-projects/spring-restdocs" + organization { + name = "Spring IO" + url = "https://projects.spring.io/spring-restdocs" + } + licenses { + license { + name = "The Apache Software License, Version 2.0" + url = "https://www.apache.org/licenses/LICENSE-2.0.txt" + distribution = "repo" + } + } + scm { + url = "https://github.com/spring-projects/spring-restdocs" + connection = "scm:git:git://github.com/spring-projects/spring-restdocs" + developerConnection = "scm:git:git://github.com/spring-projects/spring-restdocs" + } + developers { + developer { + id = "awilkinson" + name = "Andy Wilkinson" + email = "awilkinson@pivotal.io" + } + } + issueManagement { + system = "GitHub" + url = "https://github.com/spring-projects/spring-restdocs/issues" + } + } + } + } } } - -def customizePom(pom, gradleProject) { - pom.whenConfigured { generatedPom -> - generatedPom.dependencies.removeAll { dep -> - dep.scope == "test" - } - generatedPom.project { - name = gradleProject.description - description = gradleProject.description - url = "https://github.com/spring-projects/spring-restdocs" - organization { - name = "Spring IO" - url = "https://projects.spring.io/spring-restdocs" - } - licenses { - license { - name "The Apache Software License, Version 2.0" - url "https://www.apache.org/licenses/LICENSE-2.0.txt" - distribution "repo" - } - } - scm { - url = "https://github.com/spring-projects/spring-restdocs" - connection = "scm:git:git://github.com/spring-projects/spring-restdocs" - developerConnection = "scm:git:git://github.com/spring-projects/spring-restdocs" - } - developers { - developer { - id = "awilkinson" - name = "Andy Wilkinson" - email = "awilkinson@pivotal.io" - } - } - issueManagement { - system = "GitHub" - url = "https://github.com/spring-projects/spring-restdocs/issues" - } - } - } -} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 18792c68..e708b1c0 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ab4553c0..442d9132 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Aug 01 14:27:17 BST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/gradlew b/gradlew index 4453ccea..4f906e0c 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# 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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -66,6 +82,7 @@ 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 @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,35 +156,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162..107acd32 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@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 + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. 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= +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%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :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 %CMD_LINE_ARGS% +"%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 diff --git a/samples/junit5/build.gradle b/samples/junit5/build.gradle index 9e2d3b4e..27776c38 100644 --- a/samples/junit5/build.gradle +++ b/samples/junit5/build.gradle @@ -8,7 +8,7 @@ buildscript { } plugins { - id "org.asciidoctor.convert" version "1.5.9.2" + id "org.asciidoctor.jvm.convert" version "3.3.2" } apply plugin: 'java' @@ -18,7 +18,8 @@ apply plugin: 'io.spring.dependency-management' repositories { mavenLocal() - maven { url 'https://repo.spring.io/libs-snapshot' } + maven { url 'https://repo.spring.io/milestone' } + maven { url 'https://repo.spring.io/snapshot' } mavenCentral() } @@ -33,17 +34,21 @@ ext { ext['spring-restdocs.version'] = '2.0.6.BUILD-SNAPSHOT' +configurations { + asciidoctorExtensions +} + dependencies { - asciidoctor 'org.springframework.restdocs:spring-restdocs-asciidoctor' + asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor' - compile 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-web' - testCompile('org.springframework.boot:spring-boot-starter-test') { + testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'junit', module: 'junit;' } - testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc' - testCompile 'org.junit.jupiter:junit-jupiter-api' - testRuntime 'org.junit.jupiter:junit-jupiter-engine' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' + testImplementation 'org.junit.jupiter:junit-jupiter-api' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' } test { @@ -52,6 +57,7 @@ test { } asciidoctor { + configurations "asciidoctorExtensions" inputs.dir snippetsDir dependsOn test } diff --git a/samples/junit5/gradle/wrapper/gradle-wrapper.jar b/samples/junit5/gradle/wrapper/gradle-wrapper.jar index 27768f1b..62d4c053 100644 Binary files a/samples/junit5/gradle/wrapper/gradle-wrapper.jar and b/samples/junit5/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/junit5/gradle/wrapper/gradle-wrapper.properties b/samples/junit5/gradle/wrapper/gradle-wrapper.properties index 949819d2..442d9132 100644 --- a/samples/junit5/gradle/wrapper/gradle-wrapper.properties +++ b/samples/junit5/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/samples/junit5/gradlew b/samples/junit5/gradlew index cccdd3d5..fbd7c515 100755 --- a/samples/junit5/gradlew +++ b/samples/junit5/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# 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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ 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 @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/samples/junit5/gradlew.bat b/samples/junit5/gradlew.bat index f9553162..5093609d 100644 --- a/samples/junit5/gradlew.bat +++ b/samples/junit5/gradlew.bat @@ -1,3 +1,19 @@ +@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 + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. 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= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%* 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 %CMD_LINE_ARGS% diff --git a/samples/junit5/settings.gradle b/samples/junit5/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/samples/rest-assured/build.gradle b/samples/rest-assured/build.gradle index c7c63c73..f1ed5ab8 100644 --- a/samples/rest-assured/build.gradle +++ b/samples/rest-assured/build.gradle @@ -8,7 +8,7 @@ buildscript { } plugins { - id "org.asciidoctor.convert" version "1.5.9.2" + id "org.asciidoctor.jvm.convert" version "3.3.2" } apply plugin: 'java' @@ -18,7 +18,8 @@ apply plugin: 'io.spring.dependency-management' repositories { mavenLocal() - maven { url 'https://repo.spring.io/libs-snapshot' } + maven { url 'https://repo.spring.io/milestone' } + maven { url 'https://repo.spring.io/snapshot' } mavenCentral() } @@ -33,12 +34,18 @@ ext { ext['spring-restdocs.version'] = '2.0.6.BUILD-SNAPSHOT' +configurations { + asciidoctorExtensions +} + dependencies { - asciidoctor 'org.springframework.restdocs:spring-restdocs-asciidoctor' - compile 'org.springframework.boot:spring-boot-starter-web' - testCompile 'io.rest-assured:rest-assured:3.0.2' - testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile 'org.springframework.restdocs:spring-restdocs-restassured' + asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor' + + implementation 'org.springframework.boot:spring-boot-starter-web' + + testImplementation 'io.rest-assured:rest-assured:3.0.2' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.restdocs:spring-restdocs-restassured' } test { @@ -46,6 +53,7 @@ test { } asciidoctor { + configurations "asciidoctorExtensions" inputs.dir snippetsDir dependsOn test } diff --git a/samples/rest-assured/gradle/wrapper/gradle-wrapper.jar b/samples/rest-assured/gradle/wrapper/gradle-wrapper.jar index 70e26274..62d4c053 100644 Binary files a/samples/rest-assured/gradle/wrapper/gradle-wrapper.jar and b/samples/rest-assured/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/rest-assured/gradle/wrapper/gradle-wrapper.properties b/samples/rest-assured/gradle/wrapper/gradle-wrapper.properties index 1e11c4b7..442d9132 100644 --- a/samples/rest-assured/gradle/wrapper/gradle-wrapper.properties +++ b/samples/rest-assured/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Aug 08 09:59:27 BST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/samples/rest-assured/gradlew b/samples/rest-assured/gradlew index 4453ccea..fbd7c515 100755 --- a/samples/rest-assured/gradlew +++ b/samples/rest-assured/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# 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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -66,6 +82,7 @@ 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 @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,35 +156,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/samples/rest-assured/gradlew.bat b/samples/rest-assured/gradlew.bat index f9553162..5093609d 100644 --- a/samples/rest-assured/gradlew.bat +++ b/samples/rest-assured/gradlew.bat @@ -1,3 +1,19 @@ +@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 + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. 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= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%* 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 %CMD_LINE_ARGS% diff --git a/samples/rest-assured/settings.gradle b/samples/rest-assured/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/samples/rest-notes-slate/build.gradle b/samples/rest-notes-slate/build.gradle index 90a95155..a357e7ee 100644 --- a/samples/rest-notes-slate/build.gradle +++ b/samples/rest-notes-slate/build.gradle @@ -14,7 +14,8 @@ apply plugin: 'io.spring.dependency-management' repositories { mavenLocal() - maven { url 'https://repo.spring.io/libs-snapshot' } + maven { url 'https://repo.spring.io/milestone' } + maven { url 'https://repo.spring.io/snapshot' } mavenCentral() } @@ -30,15 +31,15 @@ ext { ext['spring-restdocs.version'] = '2.0.6.BUILD-SNAPSHOT' dependencies { - compile 'org.springframework.boot:spring-boot-starter-data-jpa' - compile 'org.springframework.boot:spring-boot-starter-data-rest' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-data-rest' - runtime 'com.h2database:h2' - runtime 'org.atteo:evo-inflector:1.2.1' + runtimeOnly 'com.h2database:h2' + runtimeOnly 'org.atteo:evo-inflector:1.2.1' - testCompile 'com.jayway.jsonpath:json-path' - testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc' + testImplementation 'com.jayway.jsonpath:json-path' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' } test { diff --git a/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.jar b/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.jar index 94fe1b06..e708b1c0 100644 Binary files a/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.jar and b/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.properties b/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.properties index 861b71aa..442d9132 100644 --- a/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.properties +++ b/samples/rest-notes-slate/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Aug 08 10:00:04 BST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/samples/rest-notes-slate/gradlew b/samples/rest-notes-slate/gradlew index 4453ccea..4f906e0c 100755 --- a/samples/rest-notes-slate/gradlew +++ b/samples/rest-notes-slate/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# 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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -66,6 +82,7 @@ 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 @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,35 +156,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/samples/rest-notes-slate/gradlew.bat b/samples/rest-notes-slate/gradlew.bat index f9553162..107acd32 100644 --- a/samples/rest-notes-slate/gradlew.bat +++ b/samples/rest-notes-slate/gradlew.bat @@ -1,3 +1,19 @@ +@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 + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. 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= +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%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :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 %CMD_LINE_ARGS% +"%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 diff --git a/samples/rest-notes-slate/settings.gradle b/samples/rest-notes-slate/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/samples/rest-notes-spring-data-rest/pom.xml b/samples/rest-notes-spring-data-rest/pom.xml index c8c1ee49..fccf9a86 100644 --- a/samples/rest-notes-spring-data-rest/pom.xml +++ b/samples/rest-notes-spring-data-rest/pom.xml @@ -124,20 +124,36 @@ + + spring-milestones + Spring milestones + https://repo.spring.io/milestone + + false + + spring-snapshots Spring snapshots - https://repo.spring.io/libs-snapshot + https://repo.spring.io/snapshot true + + spring-milestones + Spring milestones + https://repo.spring.io/milestone + + false + + spring-snapshots Spring snapshots - https://repo.spring.io/libs-snapshot + https://repo.spring.io/snapshot true diff --git a/samples/rest-notes-spring-hateoas/build.gradle b/samples/rest-notes-spring-hateoas/build.gradle index 2ddee60d..666441fb 100644 --- a/samples/rest-notes-spring-hateoas/build.gradle +++ b/samples/rest-notes-spring-hateoas/build.gradle @@ -8,7 +8,7 @@ buildscript { } plugins { - id "org.asciidoctor.convert" version "1.5.9.2" + id "org.asciidoctor.jvm.convert" version "3.3.2" } apply plugin: 'java' @@ -18,7 +18,8 @@ apply plugin: 'io.spring.dependency-management' repositories { mavenLocal() - maven { url 'https://repo.spring.io/libs-snapshot' } + maven { url 'https://repo.spring.io/milestone' } + maven { url 'https://repo.spring.io/snapshot' } mavenCentral() } @@ -33,16 +34,23 @@ ext { ext['spring-restdocs.version'] = '2.0.6.BUILD-SNAPSHOT' +configurations { + asciidoctorExtensions +} + dependencies { - asciidoctor 'org.springframework.restdocs:spring-restdocs-asciidoctor' - compile 'org.springframework.boot:spring-boot-starter-data-jpa' - compile 'org.springframework.boot:spring-boot-starter-hateoas' - runtime 'com.h2database:h2' - runtime 'org.atteo:evo-inflector:1.2.1' - testCompile 'com.jayway.jsonpath:json-path' - testCompile 'org.assertj:assertj-core' - testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc' + asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor' + + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-hateoas' + + runtimeOnly 'com.h2database:h2' + runtimeOnly 'org.atteo:evo-inflector:1.2.1' + + testImplementation 'com.jayway.jsonpath:json-path' + testImplementation 'org.assertj:assertj-core' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' } test { @@ -50,6 +58,7 @@ test { } asciidoctor { + configurations "asciidoctorExtensions" inputs.dir snippetsDir dependsOn test } diff --git a/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.jar b/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.jar index 383baf1e..e708b1c0 100644 Binary files a/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.jar and b/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.properties b/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.properties index e3f31fa4..442d9132 100644 --- a/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.properties +++ b/samples/rest-notes-spring-hateoas/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Aug 08 10:00:26 BST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/samples/rest-notes-spring-hateoas/gradlew b/samples/rest-notes-spring-hateoas/gradlew index 4453ccea..4f906e0c 100755 --- a/samples/rest-notes-spring-hateoas/gradlew +++ b/samples/rest-notes-spring-hateoas/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# 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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -66,6 +82,7 @@ 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 @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,35 +156,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/samples/rest-notes-spring-hateoas/gradlew.bat b/samples/rest-notes-spring-hateoas/gradlew.bat index f9553162..107acd32 100644 --- a/samples/rest-notes-spring-hateoas/gradlew.bat +++ b/samples/rest-notes-spring-hateoas/gradlew.bat @@ -1,3 +1,19 @@ +@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 + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. 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= +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%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :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 %CMD_LINE_ARGS% +"%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 diff --git a/samples/rest-notes-spring-hateoas/settings.gradle b/samples/rest-notes-spring-hateoas/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/samples/testng/build.gradle b/samples/testng/build.gradle index 5c561662..f2f16497 100644 --- a/samples/testng/build.gradle +++ b/samples/testng/build.gradle @@ -8,7 +8,7 @@ buildscript { } plugins { - id "org.asciidoctor.convert" version "1.5.9.2" + id "org.asciidoctor.jvm.convert" version "3.3.2" } apply plugin: 'java' @@ -18,7 +18,8 @@ apply plugin: 'io.spring.dependency-management' repositories { mavenLocal() - maven { url 'https://repo.spring.io/libs-snapshot' } + maven { url 'https://repo.spring.io/milestone' } + maven { url 'https://repo.spring.io/snapshot' } mavenCentral() } @@ -33,14 +34,18 @@ ext { ext['spring-restdocs.version'] = '2.0.6.BUILD-SNAPSHOT' +configurations { + asciidoctorExtensions +} + dependencies { - asciidoctor 'org.springframework.restdocs:spring-restdocs-asciidoctor' - compile 'org.springframework.boot:spring-boot-starter-web' - testCompile('org.springframework.boot:spring-boot-starter-test') { + asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor' + implementation 'org.springframework.boot:spring-boot-starter-web' + testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'junit', module: 'junit;' } - testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc' - testCompile 'org.testng:testng:6.9.10' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' + testImplementation 'org.testng:testng:6.9.10' } test { @@ -49,6 +54,7 @@ test { } asciidoctor { + configurations "asciidoctorExtensions" inputs.dir snippetsDir dependsOn test } diff --git a/samples/testng/gradle/wrapper/gradle-wrapper.jar b/samples/testng/gradle/wrapper/gradle-wrapper.jar index 0a070c33..e708b1c0 100644 Binary files a/samples/testng/gradle/wrapper/gradle-wrapper.jar and b/samples/testng/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/testng/gradle/wrapper/gradle-wrapper.properties b/samples/testng/gradle/wrapper/gradle-wrapper.properties index 6f07d35b..442d9132 100644 --- a/samples/testng/gradle/wrapper/gradle-wrapper.properties +++ b/samples/testng/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Aug 08 10:00:39 BST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/samples/testng/gradlew b/samples/testng/gradlew index 4453ccea..4f906e0c 100755 --- a/samples/testng/gradlew +++ b/samples/testng/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# 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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -66,6 +82,7 @@ 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 @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,35 +156,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/samples/testng/gradlew.bat b/samples/testng/gradlew.bat index f9553162..107acd32 100644 --- a/samples/testng/gradlew.bat +++ b/samples/testng/gradlew.bat @@ -1,3 +1,19 @@ +@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 + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. 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= +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%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :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 %CMD_LINE_ARGS% +"%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 diff --git a/samples/testng/settings.gradle b/samples/testng/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/samples/web-test-client/build.gradle b/samples/web-test-client/build.gradle index 0460dabc..3580fe66 100644 --- a/samples/web-test-client/build.gradle +++ b/samples/web-test-client/build.gradle @@ -1,5 +1,5 @@ plugins { - id "org.asciidoctor.convert" version "1.5.9.2" + id "org.asciidoctor.jvm.convert" version "3.3.2" } apply plugin: 'java' @@ -7,7 +7,8 @@ apply plugin: 'eclipse' repositories { mavenLocal() - maven { url 'https://repo.spring.io/libs-snapshot' } + maven { url 'https://repo.spring.io/milestone' } + maven { url 'https://repo.spring.io/snapshot' } mavenCentral() } @@ -22,14 +23,20 @@ ext { ext['spring-restdocs.version'] = '2.0.6.BUILD-SNAPSHOT' +configurations { + asciidoctorExtensions +} + dependencies { - compile 'io.projectreactor.ipc:reactor-netty:0.7.1.RELEASE' - compile 'org.springframework:spring-context:5.0.1.RELEASE' - compile 'org.springframework:spring-webflux:5.0.1.RELEASE' - testCompile 'junit:junit:4.12' - testCompile 'org.springframework:spring-test:5.0.1.RELEASE' - testCompile "org.springframework.restdocs:spring-restdocs-webtestclient:${project.ext['spring-restdocs.version']}" - asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${project.ext['spring-restdocs.version']}" + asciidoctorExtensions "org.springframework.restdocs:spring-restdocs-asciidoctor:${project.ext['spring-restdocs.version']}" + + implementation 'io.projectreactor.ipc:reactor-netty:0.7.1.RELEASE' + implementation 'org.springframework:spring-context:5.0.1.RELEASE' + implementation 'org.springframework:spring-webflux:5.0.1.RELEASE' + + testImplementation 'junit:junit:4.12' + testImplementation 'org.springframework:spring-test:5.0.1.RELEASE' + testImplementation "org.springframework.restdocs:spring-restdocs-webtestclient:${project.ext['spring-restdocs.version']}" } test { @@ -37,6 +44,7 @@ test { } asciidoctor { + configurations "asciidoctorExtensions" inputs.dir snippetsDir dependsOn test } diff --git a/samples/web-test-client/gradle/wrapper/gradle-wrapper.jar b/samples/web-test-client/gradle/wrapper/gradle-wrapper.jar index 27768f1b..0d4a9516 100644 Binary files a/samples/web-test-client/gradle/wrapper/gradle-wrapper.jar and b/samples/web-test-client/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/web-test-client/gradle/wrapper/gradle-wrapper.properties b/samples/web-test-client/gradle/wrapper/gradle-wrapper.properties index 949819d2..442d9132 100644 --- a/samples/web-test-client/gradle/wrapper/gradle-wrapper.properties +++ b/samples/web-test-client/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/samples/web-test-client/settings.gradle b/samples/web-test-client/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/settings.gradle b/settings.gradle index 458a5e3c..91035a9c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,12 +1,38 @@ -rootProject.name = 'spring-restdocs' +pluginManagement { + repositories { + mavenCentral() + maven { url "https://repo.spring.io/plugins-release" } + gradlePluginPortal() + } +} -include 'docs' -include 'spring-restdocs-asciidoctor' -include 'spring-restdocs-asciidoctor-1.5' -include 'spring-restdocs-asciidoctor-1.6' -include 'spring-restdocs-asciidoctor-2.x' -include 'spring-restdocs-asciidoctor-support' -include 'spring-restdocs-core' -include 'spring-restdocs-mockmvc' -include 'spring-restdocs-restassured' -include 'spring-restdocs-webtestclient' +plugins { + id "com.gradle.enterprise" version "3.6.1" + id "io.spring.ge.conventions" version "0.0.7" +} + +rootProject.name = "spring-restdocs" + +settings.gradle.projectsLoaded { + gradleEnterprise { + buildScan { + settings.gradle.rootProject.getBuildDir().mkdirs() + new File(settings.gradle.rootProject.getBuildDir(), "build-scan-uri.txt").text = "build scan not generated" + buildScanPublished { scan -> + new File(settings.gradle.rootProject.getBuildDir(), "build-scan-uri.txt").text = "<${scan.buildScanUri}|build scan>\n" + } + } + } +} + +include "docs" +include "spring-restdocs-asciidoctor" +include "spring-restdocs-asciidoctor-1.5" +include "spring-restdocs-asciidoctor-1.6" +include "spring-restdocs-asciidoctor-2.x" +include "spring-restdocs-asciidoctor-support" +include "spring-restdocs-core" +include "spring-restdocs-mockmvc" +include "spring-restdocs-platform" +include "spring-restdocs-restassured" +include "spring-restdocs-webtestclient" diff --git a/spring-restdocs-asciidoctor-1.5/build.gradle b/spring-restdocs-asciidoctor-1.5/build.gradle index 653cb107..05dfb19a 100644 --- a/spring-restdocs-asciidoctor-1.5/build.gradle +++ b/spring-restdocs-asciidoctor-1.5/build.gradle @@ -1,10 +1,19 @@ -description = 'AsciidoctorJ 1.5 extensions for Spring REST Docs' +plugins { + id "java" +} + +description = "AsciidoctorJ 1.5 extensions for Spring REST Docs" dependencies { - compileOnly "org.asciidoctor:asciidoctorj:$asciidoctorj15Version" - implementation project(':spring-restdocs-asciidoctor-support') - testCompile 'junit:junit' - testCompile "org.asciidoctor:asciidoctorj:$asciidoctorj15Version" - testCompile 'org.assertj:assertj-core' - testRuntime project(':spring-restdocs-asciidoctor-support') -} \ No newline at end of file + compileOnly("org.asciidoctor:asciidoctorj:$asciidoctorj15Version") + + implementation(project(":spring-restdocs-asciidoctor-support")) + + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation("junit:junit") + testImplementation("org.asciidoctor:asciidoctorj:$asciidoctorj15Version") + testImplementation("org.assertj:assertj-core") + + testRuntimeOnly(project(":spring-restdocs-asciidoctor-support")) +} diff --git a/spring-restdocs-asciidoctor-1.6/build.gradle b/spring-restdocs-asciidoctor-1.6/build.gradle index a09724e6..7a9695a6 100644 --- a/spring-restdocs-asciidoctor-1.6/build.gradle +++ b/spring-restdocs-asciidoctor-1.6/build.gradle @@ -1,10 +1,19 @@ -description = 'AsciidoctorJ 1.6 extensions for Spring REST Docs' +plugins { + id "java" +} + +description = "AsciidoctorJ 1.6 extensions for Spring REST Docs" dependencies { - compileOnly "org.asciidoctor:asciidoctorj:$asciidoctorj16Version" - implementation project(':spring-restdocs-asciidoctor-support') - testCompile 'junit:junit' - testCompile "org.asciidoctor:asciidoctorj:$asciidoctorj16Version" - testCompile 'org.assertj:assertj-core' - testRuntime project(':spring-restdocs-asciidoctor-support') -} \ No newline at end of file + compileOnly("org.asciidoctor:asciidoctorj:$asciidoctorj16Version") + + implementation(project(":spring-restdocs-asciidoctor-support")) + + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation("junit:junit") + testImplementation("org.asciidoctor:asciidoctorj:$asciidoctorj16Version") + testImplementation("org.assertj:assertj-core") + + testRuntimeOnly(project(":spring-restdocs-asciidoctor-support")) +} diff --git a/spring-restdocs-asciidoctor-2.x/build.gradle b/spring-restdocs-asciidoctor-2.x/build.gradle index f2ed1334..bc6361e7 100644 --- a/spring-restdocs-asciidoctor-2.x/build.gradle +++ b/spring-restdocs-asciidoctor-2.x/build.gradle @@ -1,10 +1,18 @@ -description = 'AsciidoctorJ 2.x extensions for Spring REST Docs' +plugins { + id "java" +} +description = "AsciidoctorJ 2.x extensions for Spring REST Docs" dependencies { - compileOnly "org.asciidoctor:asciidoctorj:$asciidoctorj20Version" - implementation project(':spring-restdocs-asciidoctor-support') - testCompile 'junit:junit' - testCompile "org.asciidoctor:asciidoctorj:$asciidoctorj20Version" - testCompile 'org.assertj:assertj-core' - testRuntime project(':spring-restdocs-asciidoctor-support') -} \ No newline at end of file + compileOnly("org.asciidoctor:asciidoctorj:$asciidoctorj20Version") + + implementation(project(":spring-restdocs-asciidoctor-support")) + + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation("junit:junit") + testImplementation("org.asciidoctor:asciidoctorj:$asciidoctorj20Version") + testImplementation("org.assertj:assertj-core") + + testRuntimeOnly(project(":spring-restdocs-asciidoctor-support")) +} diff --git a/spring-restdocs-asciidoctor-support/build.gradle b/spring-restdocs-asciidoctor-support/build.gradle index 5274e875..a6ef58c4 100644 --- a/spring-restdocs-asciidoctor-support/build.gradle +++ b/spring-restdocs-asciidoctor-support/build.gradle @@ -1,6 +1,12 @@ -description = 'Support code for AsciidoctorJ extensions for Spring REST Docs' +plugins { + id "java" +} + +description = "Support code for AsciidoctorJ extensions for Spring REST Docs" dependencies { - testCompile 'junit:junit' - testCompile 'org.assertj:assertj-core' -} \ No newline at end of file + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation("junit:junit") + testImplementation("org.assertj:assertj-core") +} diff --git a/spring-restdocs-asciidoctor/build.gradle b/spring-restdocs-asciidoctor/build.gradle index 89dc101b..d9337562 100644 --- a/spring-restdocs-asciidoctor/build.gradle +++ b/spring-restdocs-asciidoctor/build.gradle @@ -1,33 +1,43 @@ -description = 'Spring REST Docs Asciidoctor Extension' +plugins { + id "java-library" + id "maven-publish" + id "matrixtest" +} + +description = "Spring REST Docs Asciidoctor Extension" configurations { merge - testRuntime { extendsFrom merge } + testRuntimeOnly { extendsFrom merge } } dependencies { - merge project(':spring-restdocs-asciidoctor-1.5') - merge project(':spring-restdocs-asciidoctor-1.6') - merge project(':spring-restdocs-asciidoctor-2.x') - testCompile 'org.apache.pdfbox:pdfbox' - testCompile 'org.asciidoctor:asciidoctorj:1.5.8.1' - testCompile 'org.assertj:assertj-core' - testCompile 'junit:junit' - testCompile 'org.springframework:spring-core' - testRuntime 'org.asciidoctor:asciidoctorj-pdf' + internal(platform(project(":spring-restdocs-platform"))) + + merge project(":spring-restdocs-asciidoctor-1.5") + merge project(":spring-restdocs-asciidoctor-1.6") + merge project(":spring-restdocs-asciidoctor-2.x") + + testImplementation("org.apache.pdfbox:pdfbox") + testImplementation("org.asciidoctor:asciidoctorj:1.5.8.1") + testImplementation("org.assertj:assertj-core") + testImplementation("junit:junit") + testImplementation("org.springframework:spring-core") + + testRuntimeOnly("org.asciidoctor:asciidoctorj-pdf") } jar { - dependsOn ':spring-restdocs-asciidoctor-1.5:jar' - dependsOn ':spring-restdocs-asciidoctor-1.6:jar' - dependsOn ':spring-restdocs-asciidoctor-2.x:jar' + dependsOn(":spring-restdocs-asciidoctor-1.5:jar") + dependsOn(":spring-restdocs-asciidoctor-1.6:jar") + dependsOn(":spring-restdocs-asciidoctor-2.x:jar") from configurations.merge.collect { file -> zipTree(file) } } matrixTest { asciidoctorj { - group = 'org.asciidoctor' - artifact = 'asciidoctorj' + group = "org.asciidoctor" + artifact = "asciidoctorj" versions = [ asciidoctorj16Version, asciidoctorj20Version, asciidoctorj21Version, @@ -36,4 +46,4 @@ matrixTest { asciidoctorj24Version ] } -} \ No newline at end of file +} diff --git a/spring-restdocs-core/build.gradle b/spring-restdocs-core/build.gradle index 656dc5d8..9b010c8f 100644 --- a/spring-restdocs-core/build.gradle +++ b/spring-restdocs-core/build.gradle @@ -1,4 +1,11 @@ -description = 'Spring REST Docs Core' +plugins { + id "java-library" + id "matrixtest" + id "maven-publish" + id "optional-dependencies" +} + +description = "Spring REST Docs Core" configurations { jarjar @@ -7,8 +14,8 @@ configurations { } task jmustacheRepackJar(type: Jar) { repackJar -> - repackJar.baseName = "restdocs-jmustache-repack" - repackJar.version = dependencyManagement.managedVersions['com.samskivert:jmustache'] + repackJar.archiveBaseName = "restdocs-jmustache-repack" + repackJar.archiveVersion = jmustacheVersion doLast() { project.ant { @@ -16,32 +23,41 @@ task jmustacheRepackJar(type: Jar) { repackJar -> classpath: configurations.jarjar.asPath jarjar(destfile: repackJar.archivePath) { configurations.jmustache.each { originalJar -> - zipfileset(src: originalJar, includes: '**/*.class') + zipfileset(src: originalJar, includes: "**/*.class") } - rule(pattern: 'com.samskivert.**', result: 'org.springframework.restdocs.@1') + rule(pattern: "com.samskivert.**", result: "org.springframework.restdocs.@1") } } } } dependencies { - compile 'com.fasterxml.jackson.core:jackson-databind' - compile 'org.springframework:spring-web' - compile files(jmustacheRepackJar) - jarjar 'com.googlecode.jarjar:jarjar:1.3' - jmustache 'com.samskivert:jmustache@jar' - optional 'commons-codec:commons-codec' - optional 'javax.validation:validation-api' - optional 'junit:junit' - optional 'org.hibernate.validator:hibernate-validator' - optional 'org.junit.jupiter:junit-jupiter-api' - testCompile 'org.assertj:assertj-core' - testCompile 'org.javamoney:moneta' - testCompile 'org.mockito:mockito-core' - testCompile 'org.hamcrest:hamcrest-core' - testCompile 'org.hamcrest:hamcrest-library' - testCompile 'org.springframework:spring-test' - testRuntime 'org.glassfish:javax.el:3.0.0' + implementation("com.fasterxml.jackson.core:jackson-databind") + implementation("org.springframework:spring-web") + implementation(files(jmustacheRepackJar)) + + internal(platform(project(":spring-restdocs-platform"))) + + jarjar("com.googlecode.jarjar:jarjar:1.3") + + jmustache(platform(project(":spring-restdocs-platform"))) + jmustache("com.samskivert:jmustache@jar") + + optional("commons-codec:commons-codec") + optional("javax.validation:validation-api") + optional("junit:junit") + optional("org.hibernate.validator:hibernate-validator") + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation("junit:junit") + testImplementation("org.assertj:assertj-core") + testImplementation("org.javamoney:moneta") + testImplementation("org.mockito:mockito-core") + testImplementation("org.hamcrest:hamcrest-core") + testImplementation("org.hamcrest:hamcrest-library") + testImplementation("org.springframework:spring-test") + + testRuntimeOnly("org.glassfish:javax.el:3.0.0") } jar { @@ -60,13 +76,9 @@ artifacts { testArtifacts testJar } -test { - jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*,excludes=org.springframework.restdocs.mustache.*" -} - matrixTest { springFramework { - group = 'org.springframework' - versions = ['5.1.+', '5.2.+'] + group = "org.springframework" + versions = ["5.1.+", "5.2.+"] } -} \ No newline at end of file +} diff --git a/spring-restdocs-mockmvc/build.gradle b/spring-restdocs-mockmvc/build.gradle index 4783c371..9d6ca74e 100644 --- a/spring-restdocs-mockmvc/build.gradle +++ b/spring-restdocs-mockmvc/build.gradle @@ -1,26 +1,33 @@ -description = 'Spring REST Docs MockMvc' - -dependencies { - compile 'javax.servlet:javax.servlet-api' - compile 'org.springframework:spring-test' - compile project(':spring-restdocs-core') - optional 'junit:junit' - runtime 'org.springframework:spring-webmvc' - - testCompile 'org.mockito:mockito-core' - testCompile 'org.hamcrest:hamcrest-library' - testCompile 'org.springframework.hateoas:spring-hateoas' - testCompile project(path: ':spring-restdocs-core', configuration: 'testArtifacts') - testRuntime 'commons-logging:commons-logging:1.2' +plugins { + id "java-library" + id "matrixtest" + id "maven-publish" + id "optional-dependencies" } -test { - jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*" +description = "Spring REST Docs MockMvc" + +dependencies { + api(project(":spring-restdocs-core")) + api("org.springframework:spring-webmvc") + api("org.springframework:spring-test") + + implementation("javax.servlet:javax.servlet-api") + + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation(project(path: ":spring-restdocs-core", configuration: "testArtifacts")) + testImplementation("org.assertj:assertj-core") + testImplementation("org.hamcrest:hamcrest-library") + testImplementation("org.mockito:mockito-core") + testImplementation("org.springframework.hateoas:spring-hateoas") + + testRuntimeOnly("commons-logging:commons-logging:1.2") } matrixTest { springFramework { - group = 'org.springframework' - versions = ['5.1.+', '5.2.+', '5.3.+'] + group = "org.springframework" + versions = ["5.1.+", "5.2.+", "5.3.+"] } -} \ No newline at end of file +} diff --git a/spring-restdocs-platform/build.gradle b/spring-restdocs-platform/build.gradle new file mode 100644 index 00000000..59fb644d --- /dev/null +++ b/spring-restdocs-platform/build.gradle @@ -0,0 +1,33 @@ +plugins { + id 'java-platform' +} + +javaPlatform { + allowDependencies() +} + +dependencies { + constraints { + api("com.fasterxml.jackson.core:jackson-databind:2.9.5") + api("com.samskivert:jmustache:$jmustacheVersion") + api("commons-codec:commons-codec:1.10") + api("javax.servlet:javax.servlet-api:3.1.0") + api("javax.validation:validation-api:2.0.0.Final") + api("junit:junit:4.12") + api("io.rest-assured:rest-assured:3.0.7") + api("org.apache.pdfbox:pdfbox:2.0.7") + api("org.assertj:assertj-core:3.11.1") + api("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.18") + api("org.hamcrest:hamcrest-core:1.3") + api("org.hamcrest:hamcrest-library:1.3") + api("org.hibernate.validator:hibernate-validator:6.0.9.Final") + api("org.jacoco:org.jacoco.agent:0.7.9") + api("org.javamoney:moneta:1.1") + api("org.jruby:jruby-complete:9.1.13.0") + api("org.junit.jupiter:junit-jupiter-api:5.0.0") + api("org.mockito:mockito-core:1.10.19") + api("org.springframework.hateoas:spring-hateoas:0.23.0.RELEASE") + api("org.synchronoss.cloud:nio-multipart-parser:1.1.0") + } + api(enforcedPlatform("org.springframework:spring-framework-bom:$springVersion")) +} diff --git a/spring-restdocs-restassured/build.gradle b/spring-restdocs-restassured/build.gradle index 27008ecb..c4eddc8d 100644 --- a/spring-restdocs-restassured/build.gradle +++ b/spring-restdocs-restassured/build.gradle @@ -1,23 +1,30 @@ -description = 'Spring REST Docs REST Assured' - -dependencies { - compile project(':spring-restdocs-core') - compile 'io.rest-assured:rest-assured' - - testCompile 'org.apache.tomcat.embed:tomcat-embed-core:8.5.13' - testCompile 'org.assertj:assertj-core' - testCompile 'org.hamcrest:hamcrest-library' - testCompile 'org.mockito:mockito-core' - testCompile project(path: ':spring-restdocs-core', configuration: 'testArtifacts') +plugins { + id "java-library" + id "matrixtest" + id "maven-publish" } -test { - jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*" +description = "Spring REST Docs REST Assured" + +dependencies { + api(project(":spring-restdocs-core")) + api("io.rest-assured:rest-assured") + + implementation("org.springframework:spring-web") + + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation(project(path: ":spring-restdocs-core", configuration: "testArtifacts")) + testImplementation("com.fasterxml.jackson.core:jackson-databind") + testImplementation("org.apache.tomcat.embed:tomcat-embed-core:8.5.13") + testImplementation("org.assertj:assertj-core") + testImplementation("org.hamcrest:hamcrest-library") + testImplementation("org.mockito:mockito-core") } matrixTest { restAssured { - group = 'io.rest-assured' - versions = ['4.0.0', '4.1.2', '4.2.0', '4.3.1'] + group = "io.rest-assured" + versions = ["4.0.0", "4.1.2", "4.2.0", "4.3.1"] } -} \ No newline at end of file +} diff --git a/spring-restdocs-webtestclient/build.gradle b/spring-restdocs-webtestclient/build.gradle index 2ee3a506..f13aa0df 100644 --- a/spring-restdocs-webtestclient/build.gradle +++ b/spring-restdocs-webtestclient/build.gradle @@ -1,30 +1,36 @@ -description = 'Spring REST Docs WebFlux' - -dependencies { - compile 'org.springframework:spring-test' - compile 'org.springframework:spring-webflux' - compile project(':spring-restdocs-core') - - testCompile 'org.mockito:mockito-core' - testCompile 'org.hamcrest:hamcrest-library' - testCompile project(path: ':spring-restdocs-core', configuration: 'testArtifacts') - testRuntime 'org.springframework:spring-context' - testRuntime 'org.synchronoss.cloud:nio-multipart-parser' +plugins { + id "java-library" + id "matrixtest" + id "maven-publish" } -test { - jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*" +description = "Spring REST Docs WebFlux" + +dependencies { + api(project(":spring-restdocs-core")) + api("org.springframework:spring-test") + api("org.springframework:spring-webflux") + + internal(platform(project(":spring-restdocs-platform"))) + + testImplementation(project(path: ":spring-restdocs-core", configuration: "testArtifacts")) + testImplementation("org.assertj:assertj-core") + testImplementation("org.hamcrest:hamcrest-library") + testImplementation("org.mockito:mockito-core") + + testRuntimeOnly("org.springframework:spring-context") + testRuntimeOnly("org.synchronoss.cloud:nio-multipart-parser") } matrixTest { springFramework { - group = 'org.springframework' - versions = ['5.1.+', '5.2.+', '5.3.+'] + group = "org.springframework" + versions = ["5.1.+", "5.2.+", "5.3.+"] } } project.afterEvaluate { - configurations.getByName('testRuntimeClasspath_org.springframework_5.3.+') { - exclude group: 'org.synchronoss.cloud', module: 'nio-multipart-parser' + configurations.getByName("testRuntimeClasspath_org.springframework_5.3.+") { + exclude group: "org.synchronoss.cloud", module: "nio-multipart-parser" } }