diff --git a/README.adoc b/README.adoc
index 3fd0cf7..c311b09 100644
--- a/README.adoc
+++ b/README.adoc
@@ -27,8 +27,8 @@ include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/
For all Spring applications, you should start with the https://start.spring.io[Spring
Initializr]. The Initializr offers a fast way to pull in all the dependencies you need for
-an application and does a lot of the setup for you. This example needs only the Spring Web
-dependency.
+an application and does a lot of the setup for you. This example needs only the Spring Web
+and Spring REST Docs dependencies.
The following listing shows the `pom.xml` file that is created when you choose Maven:
@@ -63,8 +63,8 @@ include::complete/src/main/java/com/example/testingrestdocs/HomeController.java[
== Run the Application
-The Spring Initializr creates a `main` class that you can use to launch the application.
-The following listing (from
+The Spring Initializr creates a `{YourProjectName}Application` class with a `main` method
+that is used to launch the application. The following listing (from
`src/main/java/com/example/testingrestdocs/TestingRestdocsApplication.java`) shows the
application class that the Spring Initializr created:
@@ -75,6 +75,9 @@ include::complete/src/main/java/com/example/testingrestdocs/TestingRestdocsAppli
----
====
+
+=== Demistifying the annotations
+
`@SpringBootApplication` is a convenience annotation that adds all of the following:
- `@Configuration`: Tags the class as a source of bean definitions for the application
@@ -93,64 +96,43 @@ application. Did you notice that there is not a single line of XML? There is no
file, either. This web application is 100% pure Java and you did not have to deal with
configuring any plumbing or infrastructure. Spring Boot handles all of that for you.
-Logging output is displayed. The service should be up and running within a few seconds.
+=== Getting up and going with wrappers
+The easiest way to get started is to use the *Maven or Gradle wrapper*. It will download
+all the necessary dependencies and start the Spring Boot app (by running the `main()`
+method) for you.
+
+==== Running using the Maven Wrapper
+Start the application by running `./mvnw spring-boot:run` on the command line in the root of the project.
+
+==== Running using the Gradle Wrapper
+Start the application by running `./gradlew bootRun` on the command line in the root of the project.
+
+
+Once you start the application, logging output will be displayed and the service should be up
+and running within a few seconds. You'll know it's ready once you see a line that reads
+something like `Started TestingRestdocsApplication in 1.492 seconds`.
+
== Test the Application
Now that the application is running, you can test it. You can load the home page at
`http://localhost:8080`. However, to give yourself more confidence that the application
works when you make changes, you want to automate the testing. You also want to publish
-documentation for the HTTP endpoint. You can generate the dynamic parts of that testing as
+documentation for the HTTP endpoint. You can generate the dynamic parts of that documentation as
part of the tests by using Spring REST Docs.
The first thing you can do is write a simple sanity check test that fails if the
-application context cannot start. To do so, add Spring Test and Spring REST Docs as
-dependencies to your project, in the test scope. The following listing shows what to add
-if you use Maven:
-
-====
-[source,xml]
-----
-include::complete/pom.xml[tag=test]
-----
-====
-
-The following listing shows the completed `pom.xml` file:
-
-====
-[source,xml]
-----
-include::complete/pom.xml[]
-----
-====
+application context cannot start.
-The following example shows what to add if you use Gradle:
+NOTE: All the dependencies you need to write JUnit 5 tests are included for you by the
+`pom.xml` that came with the project you got from Spring Initializr.
-====
-[source,groovy]
-----
-include::complete/build.gradle[tag=test]
-----
-====
-
-The following listing shows the completed `build.gradle` file:
-
-====
-[source,groovy]
-----
-include::complete/build.gradle[]
-----
-====
-
-NOTE: You can ignore the comments in the build files. They are there to let us pick up
-parts of the files for inclusion in this guide.
-
-NOTE: You have included the `mockmvc` flavor of REST Docs, which uses Spring MockMvc to
+NOTE: By deafult, you get the `mockmvc` flavor of REST Docs, which uses Spring MockMvc to
capture the HTTP content. If your own application does not use Spring MVC, you can also
use a `restassured` flavor, which works with full stack integration tests.
-Now create a test case with the `@RunWith` and `@SpringBootTest` annotations and an empty
-test method, as the following example (from
+A test case checking if the context loads has already been created for you by Spring Initialzr.
+It has the `@SpringBootTest` annotation and an empty test method, as the following example (from
`src/test/java/com/example/testingrestdocs/TestingRestdocsApplicationTests.java`) shows:
====
@@ -163,17 +145,26 @@ include::complete/src/test/java/com/example/testingrestdocs/TestingRestdocsAppli
You can run this test in your IDE or on the command line (by running `./mvnw test` or
`./gradlew test`).
+:mock-mvc: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/web/servlet/MockMvc.html
+:web-mvc-test: https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.html
+
It is nice to have a sanity check, but you should also write some tests that assert the
behavior of our application. A useful approach is to test only the MVC layer, where Spring
-handles the incoming HTTP request and hands it off to your controller. To do that, you can
-use Spring's `MockMvc` and ask for that to be injected for you by using the `@WebMvcTest`
-annotation on the test case. The following example (from
-`src/test/java/com/example/testingrestdocs/WebLayerTest.java`) shows how to do so:
+handles the incoming HTTP request and hands it off to your controller.
+
+:testing-web-layer-tutorial: https://spring.io/guides/gs/testing-web/
+
+TIP: For those new to it, the {testing-web-layer-tutorial}[Testing the Web Layer tutorial] goes into
+more depth on this kind of testing. In this tutorial we'll focus on REST Docs.
+
+To test just the web layer, you can use {mock-mvc}[Spring's `MockMvc`] and ask for it to
+be injected for you by using the {web-mvc-test}[`@WebMvcTest` annotation] on the test
+case. The following example (from `src/test/java/com/example/testingrestdocs/WebLayerTest.java`)
+shows how to do so:
====
[source,java]
----
-@RunWith(SpringRunner.class)
@WebMvcTest(HomeController.class)
public class WebLayerTest {
@@ -193,11 +184,13 @@ public class WebLayerTest {
== Generate Snippets for Documentation
The test in the preceding section makes (mock) HTTP requests and asserts the responses.
-The HTTP API that you have created has dynamic content (at least in principle), so it
+Most HTTP APIs that you create, in principle, will have dynamic content so it
would be really nice to be able to spy on the tests and siphon off the HTTP requests for
-use in the documentation. Spring REST Docs lets you do so by generating "`snippets`". You
-can get this working by adding an annotation to your test and an extra "`assertion`". The
-following example (from `src/test/java/com/example/testingrestdocs/WebLayerTest.java`)
+use in the documentation.
+
+Spring REST Docs does just that and lets you document it in things called "`snippets`".
+You can get this working by adding an annotation to your test along with an extra "`assertion`".
+The following example (from `src/test/java/com/example/testingrestdocs/WebLayerTest.java`)
shows the complete test:
====
@@ -207,16 +200,20 @@ include::complete/src/test/java/com/example/testingrestdocs/WebLayerTest.java[]
----
====
-The new annotation is `@AutoConfigureRestDocs` (from Spring Boot), which takes an argument
-for a directory location for the generated snippets. And the new assertion is
-`MockMvcRestDocumentation.document`, which takes an argument for a string identifier for
-the snippets.
+:auto-configure-rest-docs-annotation: https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.html
+:document: https://docs.spring.io/spring-restdocs/docs/current/api/org/springframework/restdocs/mockmvc/MockMvcRestDocumentation.html
+:asciidoctor-link: http://asciidoctor.org/
+
+The new annotation is {auto-configure-rest-docs-annotation}[`@AutoConfigureRestDocs`]
+(from Spring Boot), (which can take an argument for a directory location for the generated
+snippets). And the new assertion is {document}[`MockMvcRestDocumentation.document`], which takes an
+argument for a string identifier for the snippets.
NOTE: Gradle users might prefer to use `build` instead of `target` as an output directory.
However, it does not matter. Use whichever you prefer.
Run the test and then look in `target/snippets`. You should find a directory called `home`
-(the identifier) that contains http://asciidoctor.org/[Asciidoctor] snippets, as follows:
+(the identifier provided to `document()`) that contains {asciidoctor-link}[Asciidoctor] snippets, as follows:
====
[source,bash]
@@ -233,9 +230,51 @@ Run the test and then look in `target/snippets`. You should find a directory cal
----
====
-The default snippets are in Asciidoctor format for the HTTP request and response. There
-are also command line examples for `curl` and `httpie` (two common and popular command
-line HTTP clients).
+The HTTP request and response are captured and a snippet is generated for each.
+
+
+====
+.Request
+[source,http,options="nowrap"]
+----
+GET / HTTP/1.1
+Host: localhost:8080
+----
+====
+
+====
+.Response
+[source,http,options="nowrap"]
+----
+HTTP/1.1 200 OK
+Content-Type: application/json
+Content-Length: 26
+
+{"message":"Hello, World"}
+----
+====
+
+:more-on-curl: https://idratherbewriting.com/learnapidoc/docapis_install_curl.html
+:more-on-httpie: https://httpie.io/
+
+There are also command line examples for {more-on-curl}[curl] and {more-on-httpie}[httpie]
+(two common and popular command line HTTP clients).
+
+====
+.Generated curl request
+[source,bash]
+----
+$ curl 'http://localhost:8080/' -i -X GET
+----
+====
+
+====
+.Generated httpie request
+[source,bash]
+----
+$ http GET 'http://localhost:8080/'
+----
+====
You can create additional snippets by adding arguments to the `document()` assertion in
the test. For example, you can document each of the fields in a JSON response by using the
@@ -249,23 +288,24 @@ this.mockMvc.perform(get("/"))
...
.andDo(document("home", responseFields(
fieldWithPath("message").description("The welcome message for the user.")
- ));
+ )));
----
====
-If you run the test, you should find an additional snippet file called
+If you run this test, you should find an additional snippet file called
`response-fields.adoc`. It contains a table of field names and descriptions. If you omit a
field or get its name wrong, the test fails. This is the power of REST Docs.
+:spring-rest-docs-documentation: http://docs.spring.io/spring-restdocs/docs/current/reference/html5/
+
NOTE: You can create custom snippets and change the format of the snippets and customize
values, such as the hostname. See the documentation for
-http://docs.spring.io/spring-restdocs/docs/current/reference/html5/[Spring REST Docs] for
-more detail.
+{spring-rest-docs-documentation}[Spring REST Docs] for more detail.
== Using the Snippets
-To use the generated snippets, you want to have some Asciidoctor content in the project
-and then include the snippets at build time. To see this work, create a new file called
+To use the generated snippets, you'll need to create an Asciidoctor file in the project
+and then include the snippets in it at build time. To see this work, create a new file called
`src/main/asciidoc/index.adoc` and include the snippets as desired. The following example
(from `src/main/asciidoc/index.adoc`) shows how to do so:
@@ -295,49 +335,54 @@ only other markup in this simple case is the `=` at the top (which is a level-1
heading) and the `.` before the captions ("`request`" and "`response`") on the snippets.
The `.` turns the text on that line into a caption.
-Then, in the build configuration, you need to process this source file into your chosen
-documentation format. For example, you can use Maven to generate HTML
-(`target/generated-docs` is generated when you do `./mvnw package`). The following listing
-shows the Asciidoc portion of the `pom.xml` file:
+Maven or Gradle will generate HTML documentation from your `index.adoc` file at build time.
+Spring Initializr provided the necessary config, you just need to make sure the file
+is where Maven or Gradle expects it.
-====
-[source,xml]
-----
-include::complete/pom.xml[tag=asciidoc,indent=0]
-----
-====
+Run `./mvnw package` and you'll find the documentation in the `target/generated-docs` folder.
+
+// FIXME: Gradle isn't generating the snippets for some reason, as nothing appears in the build/generated-snippets
+// FIXME: folder—the folder appears, but no snippets. ¯\_(ツ)_/¯️
-If you use Gradle, `build/asciidoc` is generated when you run `./gradlew asciidoctor`. The
-following listing shows the Asciidoctor-related parts of the `build.gradle` file:
+If you use Gradle, run `./gradlew asciidoctor` and you'll find the documentation in the
+`build/asciidoc` folder. The following listing shows the Asciidoctor-related
+parts of the `build.gradle` file:
====
[source,groovy]
----
-plugins {
- ...
- id 'org.asciidoctor.convert' version '1.5.6'
-}
+...
+include::complete/build.gradle[tag=asciidoc-config1]
...
-asciidoctor {
- sourceDir 'src/main/asciidoc'
- attributes \
- 'snippets': file('target/snippets')
-}
+include::complete/build.gradle[tag=asciidoc-config2]
+
----
+<1> If you want Maven and Gradle to look in the same place for the docs, you'll need to add this line yourself;
+see note below.
+<2> Informs gradle about how to resolve the `snippets` variable in `index.adoc`.
+// FIXME: if there's a conventional way to do this, instead of specifying some configuration, do that instead.
====
NOTE: The default location for Asciidoctor sources in Gradle is `src/doc/asciidoc`. We set
the `sourceDir` to match the default for Maven.
+:docs-screenshot: https://user-images.githubusercontent.com/19827042/103386593-db63f400-4abc-11eb-95e8-3a76e2fb8348.png
+
+.The generated HTML docs
+image::{docs-screenshot}[The generated HTML docs]
+
== Summary
Congratulations! You have just developed a Spring application and documented it by using
-Spring Restdocs. You could publish the HTML documentation you created to a static website
+Spring REST Docs. You could publish the HTML documentation you created to a static website
or package it up and serve it from the application itself. Your documentation will always
be up to date, and tests will fail your build if it is not.
+// TODO: It would be nice to include a quick example of how to package and serve the docs with the
+// TODO: application itself.
+
== See Also
The following guides may also be helpful:
diff --git a/complete/.gitignore b/complete/.gitignore
new file mode 100644
index 0000000..48a2396
--- /dev/null
+++ b/complete/.gitignore
@@ -0,0 +1,44 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/complete/.mvn/wrapper/MavenWrapperDownloader.java b/complete/.mvn/wrapper/MavenWrapperDownloader.java
index fc5ad5e..e76d1f3 100755
--- a/complete/.mvn/wrapper/MavenWrapperDownloader.java
+++ b/complete/.mvn/wrapper/MavenWrapperDownloader.java
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -20,12 +20,12 @@
public class MavenWrapperDownloader {
- private static final String WRAPPER_VERSION = "0.5.2";
+ private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
- + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + " .jar";
+ + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
diff --git a/complete/.mvn/wrapper/maven-wrapper.jar b/complete/.mvn/wrapper/maven-wrapper.jar
index 968b23b..2cc7d4a 100755
Binary files a/complete/.mvn/wrapper/maven-wrapper.jar and b/complete/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/complete/.mvn/wrapper/maven-wrapper.properties b/complete/.mvn/wrapper/maven-wrapper.properties
index 0b3b65e..642d572 100755
--- a/complete/.mvn/wrapper/maven-wrapper.properties
+++ b/complete/.mvn/wrapper/maven-wrapper.properties
@@ -1,2 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
-wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.tar.gz
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
diff --git a/complete/build.gradle b/complete/build.gradle
index f110adc..8227046 100644
--- a/complete/build.gradle
+++ b/complete/build.gradle
@@ -1,32 +1,41 @@
plugins {
- id 'org.springframework.boot' version '2.3.2.RELEASE'
- id 'io.spring.dependency-management' version '1.0.8.RELEASE'
+ id 'org.springframework.boot' version '2.4.1'
+ id 'io.spring.dependency-management' version '1.0.10.RELEASE'
+ id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
- id 'org.asciidoctor.convert' version '1.5.6'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
-asciidoctor {
- sourceDir 'src/main/asciidoc'
- attributes \
- 'snippets': file('target/snippets')
-}
-
repositories {
mavenCentral()
}
+// tag::asciidoc-config1[]
+ext {
+ set('snippetsDir', file("build/generated-snippets"))
+}
+// end::asciidoc-config1[]
+
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
- testImplementation('org.springframework.boot:spring-boot-starter-test') {
- exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
- }
}
+// tag::asciidoc-config2[]
test {
+ outputs.dir snippetsDir
useJUnitPlatform()
}
+
+asciidoctor {
+ sourceDir 'src/main/asciidoc'
+ inputs.dir snippetsDir
+ dependsOn test
+
+ attributes 'snippets': file('build/generated-snippets')
+}
+// end::asciidoc-config2[]
diff --git a/complete/gradle/wrapper/gradle-wrapper.jar b/complete/gradle/wrapper/gradle-wrapper.jar
index 5c2d1cf..e708b1c 100644
Binary files a/complete/gradle/wrapper/gradle-wrapper.jar and b/complete/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/complete/gradle/wrapper/gradle-wrapper.properties b/complete/gradle/wrapper/gradle-wrapper.properties
index bb8b2fc..4d9ca16 100644
--- a/complete/gradle/wrapper/gradle-wrapper.properties
+++ b/complete/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/complete/gradlew b/complete/gradlew
index 83f2acf..4f906e0 100755
--- a/complete/gradlew
+++ b/complete/gradlew
@@ -82,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
@@ -129,6 +130,7 @@ fi
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
@@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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
@@ -175,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/complete/gradlew.bat b/complete/gradlew.bat
index 24467a1..ac1b06f 100644
--- a/complete/gradlew.bat
+++ b/complete/gradlew.bat
@@ -29,6 +29,9 @@ 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="-Xmx64m" "-Xms64m"
@@ -37,7 +40,7 @@ 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.
@@ -51,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%
@@ -61,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/complete/mvnw b/complete/mvnw
index eb65ff2..a16b543 100755
--- a/complete/mvnw
+++ b/complete/mvnw
@@ -8,7 +8,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# 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
@@ -19,7 +19,7 @@
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
+# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
@@ -211,10 +211,10 @@ else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
- if [ "$MVNW_REPOURL" = true]; then
- jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
+ if [ -n "$MVNW_REPOURL" ]; then
+ jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
- jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
@@ -246,7 +246,7 @@ else
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
-
+
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
@@ -296,6 +296,11 @@ if $cygwin; then
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
diff --git a/complete/mvnw.cmd b/complete/mvnw.cmd
index 4f5150a..c8d4337 100755
--- a/complete/mvnw.cmd
+++ b/complete/mvnw.cmd
@@ -7,7 +7,7 @@
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@@ -18,7 +18,7 @@
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
+@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@@ -26,7 +26,7 @@
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@@ -37,7 +37,7 @@
@echo off
@REM set title of command window
title %0
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
@@ -120,7 +120,7 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
@@ -129,14 +129,18 @@ FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
- echo Found %WRAPPER_JAR%
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
) else (
- if not "%MVNW_REPOURL%" == "" (
- SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
- )
- echo Couldn't find %WRAPPER_JAR%, downloading it ...
- echo Downloading from: %DOWNLOAD_URL%
-
+ if not "%MVNW_REPOURL%" == "" (
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ )
+
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
@@ -144,10 +148,16 @@ if exist %WRAPPER_JAR% (
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
- echo Finished downloading %WRAPPER_JAR%
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
)
@REM End of extension
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
diff --git a/complete/pom.xml b/complete/pom.xml
index 1a89bab..1a14ead 100644
--- a/complete/pom.xml
+++ b/complete/pom.xml
@@ -5,14 +5,14 @@
org.springframework.boot
spring-boot-starter-parent
- 2.3.2.RELEASE
+ 2.4.1
com.example
testing-restdocs
0.0.1-SNAPSHOT
testing-restdocs
- Demo project for Spring Boot
+ Demo project for testing Spring REST Docs
1.8
@@ -23,6 +23,7 @@
org.springframework.boot
spring-boot-starter-web
+
org.springframework.boot
spring-boot-starter-test
@@ -33,25 +34,41 @@
spring-restdocs-mockmvc
test
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
+
+
+ org.asciidoctor
+ asciidoctor-maven-plugin
+ 1.5.8
+
+
+ generate-docs
+ prepare-package
+
+ process-asciidoc
+
+
+ html
+ book
+
+
+
+
+
+ org.springframework.restdocs
+ spring-restdocs-asciidoctor
+ ${spring-restdocs.version}
+
+
+
org.springframework.boot
spring-boot-maven-plugin
+
diff --git a/complete/src/test/java/com/example/testingrestdocs/WebLayerTest.java b/complete/src/test/java/com/example/testingrestdocs/WebLayerTest.java
index a3f95e1..a1e23c9 100644
--- a/complete/src/test/java/com/example/testingrestdocs/WebLayerTest.java
+++ b/complete/src/test/java/com/example/testingrestdocs/WebLayerTest.java
@@ -15,7 +15,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(HomeController.class)
-@AutoConfigureRestDocs(outputDir = "target/snippets")
+@AutoConfigureRestDocs
public class WebLayerTest {
@Autowired
diff --git a/initial/.gitignore b/initial/.gitignore
new file mode 100644
index 0000000..48a2396
--- /dev/null
+++ b/initial/.gitignore
@@ -0,0 +1,44 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/initial/.mvn/wrapper/MavenWrapperDownloader.java b/initial/.mvn/wrapper/MavenWrapperDownloader.java
index fc5ad5e..e76d1f3 100755
--- a/initial/.mvn/wrapper/MavenWrapperDownloader.java
+++ b/initial/.mvn/wrapper/MavenWrapperDownloader.java
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -20,12 +20,12 @@
public class MavenWrapperDownloader {
- private static final String WRAPPER_VERSION = "0.5.2";
+ private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
- + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + " .jar";
+ + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
diff --git a/initial/.mvn/wrapper/maven-wrapper.jar b/initial/.mvn/wrapper/maven-wrapper.jar
index 968b23b..2cc7d4a 100755
Binary files a/initial/.mvn/wrapper/maven-wrapper.jar and b/initial/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/initial/.mvn/wrapper/maven-wrapper.properties b/initial/.mvn/wrapper/maven-wrapper.properties
index 0b3b65e..642d572 100755
--- a/initial/.mvn/wrapper/maven-wrapper.properties
+++ b/initial/.mvn/wrapper/maven-wrapper.properties
@@ -1,2 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
-wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.tar.gz
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
diff --git a/initial/build.gradle b/initial/build.gradle
index 384abb5..6aa437c 100644
--- a/initial/build.gradle
+++ b/initial/build.gradle
@@ -1,6 +1,7 @@
plugins {
- id 'org.springframework.boot' version '2.3.2.RELEASE'
- id 'io.spring.dependency-management' version '1.0.8.RELEASE'
+ id 'org.springframework.boot' version '2.4.1'
+ id 'io.spring.dependency-management' version '1.0.10.RELEASE'
+ id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
}
@@ -12,13 +13,22 @@ repositories {
mavenCentral()
}
+ext {
+ set('snippetsDir', file("build/generated-snippets"))
+}
+
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
- testImplementation('org.springframework.boot:spring-boot-starter-test') {
- exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
- }
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
+ testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
}
test {
+ outputs.dir snippetsDir
useJUnitPlatform()
}
+
+asciidoctor {
+ inputs.dir snippetsDir
+ dependsOn test
+}
diff --git a/initial/gradle/wrapper/gradle-wrapper.jar b/initial/gradle/wrapper/gradle-wrapper.jar
index 5c2d1cf..e708b1c 100644
Binary files a/initial/gradle/wrapper/gradle-wrapper.jar and b/initial/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/initial/gradle/wrapper/gradle-wrapper.properties b/initial/gradle/wrapper/gradle-wrapper.properties
index bb8b2fc..4d9ca16 100644
--- a/initial/gradle/wrapper/gradle-wrapper.properties
+++ b/initial/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/initial/gradlew b/initial/gradlew
index 83f2acf..4f906e0 100755
--- a/initial/gradlew
+++ b/initial/gradlew
@@ -82,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
@@ -129,6 +130,7 @@ fi
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
@@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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
@@ -175,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/initial/gradlew.bat b/initial/gradlew.bat
index 24467a1..ac1b06f 100644
--- a/initial/gradlew.bat
+++ b/initial/gradlew.bat
@@ -29,6 +29,9 @@ 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="-Xmx64m" "-Xms64m"
@@ -37,7 +40,7 @@ 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.
@@ -51,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%
@@ -61,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/initial/mvnw b/initial/mvnw
index eb65ff2..a16b543 100755
--- a/initial/mvnw
+++ b/initial/mvnw
@@ -8,7 +8,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# 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
@@ -19,7 +19,7 @@
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
+# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
@@ -211,10 +211,10 @@ else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
- if [ "$MVNW_REPOURL" = true]; then
- jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
+ if [ -n "$MVNW_REPOURL" ]; then
+ jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
- jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
@@ -246,7 +246,7 @@ else
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
-
+
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
@@ -296,6 +296,11 @@ if $cygwin; then
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
diff --git a/initial/mvnw.cmd b/initial/mvnw.cmd
index 4f5150a..c8d4337 100755
--- a/initial/mvnw.cmd
+++ b/initial/mvnw.cmd
@@ -7,7 +7,7 @@
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@@ -18,7 +18,7 @@
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
+@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@@ -26,7 +26,7 @@
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@@ -37,7 +37,7 @@
@echo off
@REM set title of command window
title %0
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
@@ -120,7 +120,7 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
@@ -129,14 +129,18 @@ FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
- echo Found %WRAPPER_JAR%
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
) else (
- if not "%MVNW_REPOURL%" == "" (
- SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar"
- )
- echo Couldn't find %WRAPPER_JAR%, downloading it ...
- echo Downloading from: %DOWNLOAD_URL%
-
+ if not "%MVNW_REPOURL%" == "" (
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ )
+
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
@@ -144,10 +148,16 @@ if exist %WRAPPER_JAR% (
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
- echo Finished downloading %WRAPPER_JAR%
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
)
@REM End of extension
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
diff --git a/initial/pom.xml b/initial/pom.xml
index e19baf1..dff67e7 100644
--- a/initial/pom.xml
+++ b/initial/pom.xml
@@ -5,14 +5,14 @@
org.springframework.boot
spring-boot-starter-parent
- 2.3.2.RELEASE
+ 2.4.1
com.example
testing-restdocs
0.0.1-SNAPSHOT
testing-restdocs
- Demo project for Spring Boot
+ Demo project for testing Spring REST Docs
1.8
@@ -28,17 +28,41 @@
org.springframework.boot
spring-boot-starter-test
test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
+
+
+ org.springframework.restdocs
+ spring-restdocs-mockmvc
+ test
+
+ org.asciidoctor
+ asciidoctor-maven-plugin
+ 1.5.8
+
+
+ generate-docs
+ prepare-package
+
+ process-asciidoc
+
+
+ html
+ book
+
+
+
+
+
+ org.springframework.restdocs
+ spring-restdocs-asciidoctor
+ ${spring-restdocs.version}
+
+
+
org.springframework.boot
spring-boot-maven-plugin
diff --git a/initial/src/test/java/com/example/testingrestdocs/TestingRestdocsApplicationTests.java b/initial/src/test/java/com/example/testingrestdocs/TestingRestdocsApplicationTests.java
index 765e6bc..de18f81 100644
--- a/initial/src/test/java/com/example/testingrestdocs/TestingRestdocsApplicationTests.java
+++ b/initial/src/test/java/com/example/testingrestdocs/TestingRestdocsApplicationTests.java
@@ -1,14 +1,13 @@
package com.example.testingrestdocs;
import org.junit.jupiter.api.Test;
-
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
-public class TestingRestdocsApplicationTests {
+class TestingRestdocsApplicationTests {
@Test
- public void contextLoads() {
+ void contextLoads() {
}
}