Commit 45346b63 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.2.x' into 2.3.x

Closes gh-22669
parents 7e547b60 22dc4e76
...@@ -7206,7 +7206,7 @@ It can also be used to configure the host, scheme, and port that appears in any ...@@ -7206,7 +7206,7 @@ It can also be used to configure the host, scheme, and port that appears in any
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-mock-mvc]] [[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-mock-mvc]]
===== Auto-configured Spring REST Docs Tests with Mock MVC ===== Auto-configured Spring REST Docs Tests with Mock MVC
`@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs. `@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs when testing Servlet-based web applications.
You can inject it by using `@Autowired` and use it in your tests as you normally would when using Mock MVC and Spring REST Docs, as shown in the following example: You can inject it by using `@Autowired` and use it in your tests as you normally would when using Mock MVC and Spring REST Docs, as shown in the following example:
[source,java,indent=0] [source,java,indent=0]
...@@ -7276,7 +7276,7 @@ The following example shows a `RestDocumentationResultHandler` being defined: ...@@ -7276,7 +7276,7 @@ The following example shows a `RestDocumentationResultHandler` being defined:
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-web-test-client]] [[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-web-test-client]]
===== Auto-configured Spring REST Docs Tests with WebTestClient ===== Auto-configured Spring REST Docs Tests with WebTestClient
`@AutoConfigureRestDocs` can also be used with `WebTestClient`. `@AutoConfigureRestDocs` can also be used with `WebTestClient` when testing reactive web applications.
You can inject it by using `@Autowired` and use it in your tests as you normally would when using `@WebFluxTest` and Spring REST Docs, as shown in the following example: You can inject it by using `@Autowired` and use it in your tests as you normally would when using `@WebFluxTest` and Spring REST Docs, as shown in the following example:
[source,java,indent=0] [source,java,indent=0]
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -23,16 +23,25 @@ import java.lang.annotation.Retention; ...@@ -23,16 +23,25 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import io.restassured.RestAssured;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.test.web.servlet.MockMvc;
/** /**
* Annotation that can be applied to a test class to enable and configure * Annotation that can be applied to a test class to enable and configure
* auto-configuration of Spring REST Docs. Allows configuration of the output directory * auto-configuration of Spring REST Docs. The auto-configuration sets up
* and the host, scheme, and port of generated URIs. When further configuration is * {@link MockMvc}-based testing of a servlet web application, {@link WebTestClient}-based
* required a {@link RestDocsMockMvcConfigurationCustomizer} bean can be used. * testing of a reactive web application, or {@link RestAssured}-based testing of any web
* application over HTTP.
* <p>
* Allows configuration of the output directory and the host, scheme, and port of
* generated URIs. When further configuration is required a
* {@link RestDocsMockMvcConfigurationCustomizer} bean can be used.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 1.4.0 * @since 1.4.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment