Commit 1411cc3d authored by Phillip Webb's avatar Phillip Webb

Reorder a few how-to sections

Closes gh-26262
parents 5f7e3d39 e08d4f1f
...@@ -2527,7 +2527,7 @@ howto.spring-mvc.customize-view-resolvers ...@@ -2527,7 +2527,7 @@ howto.spring-mvc.customize-view-resolvers
# 2 == Testing With Spring Security # 2 == Testing With Spring Security
howto-use-test-with-spring-security=\ howto-use-test-with-spring-security=\
howto.testing-with-spring-security howto.spring-mvc.testing.with-spring-security
# 2 == Jersey # 2 == Jersey
howto-jersey=\ howto-jersey=\
...@@ -2845,11 +2845,11 @@ howto.traditional-deployment.weblogic ...@@ -2845,11 +2845,11 @@ howto.traditional-deployment.weblogic
# 2 == Use Jedis Instead of Lettuce # 2 == Use Jedis Instead of Lettuce
howto-use-jedis-instead-of-lettuce=\ howto-use-jedis-instead-of-lettuce=\
howto.jedis-instead-of-lettuce howto.nosql.jedis-instead-of-lettuce
# 2 == Use Testcontainers for integration testing # 2 == Use Testcontainers for integration testing
howto-testcontainers=\ howto-testcontainers=\
howto.testcontainers howto.testing.testcontainers
......
...@@ -404,7 +404,7 @@ If you define your own `webDriver` scope you may find it stops working when you ...@@ -404,7 +404,7 @@ If you define your own `webDriver` scope you may find it stops working when you
If you have Spring Security on the classpath, `@WebMvcTest` will also scan `WebSecurityConfigurer` beans. If you have Spring Security on the classpath, `@WebMvcTest` will also scan `WebSecurityConfigurer` beans.
Instead of disabling security completely for such tests, you can use Spring Security's test support. Instead of disabling security completely for such tests, you can use Spring Security's test support.
More details on how to use Spring Security's `MockMvc` support can be found in this _<<howto#howto.testing-with-spring-security>>_ how-to section. More details on how to use Spring Security's `MockMvc` support can be found in this _<<howto#howto.testing.with-spring-security>>_ how-to section.
TIP: Sometimes writing Spring MVC tests is not enough; Spring Boot can help you run <<features#features.testing.spring-boot-applications.with-running-server, full end-to-end tests with an actual server>>. TIP: Sometimes writing Spring MVC tests is not enough; Spring Boot can help you run <<features#features.testing.spring-boot-applications.with-running-server, full end-to-end tests with an actual server>>.
......
...@@ -23,8 +23,6 @@ include::howto/webserver.adoc[] ...@@ -23,8 +23,6 @@ include::howto/webserver.adoc[]
include::howto/spring-mvc.adoc[] include::howto/spring-mvc.adoc[]
include::howto/testing-with-spring-security.adoc[]
include::howto/jersey.adoc[] include::howto/jersey.adoc[]
include::howto/http-clients.adoc[] include::howto/http-clients.adoc[]
...@@ -45,10 +43,8 @@ include::howto/security.adoc[] ...@@ -45,10 +43,8 @@ include::howto/security.adoc[]
include::howto/hotswapping.adoc[] include::howto/hotswapping.adoc[]
include::howto/testing.adoc[]
include::howto/build.adoc[] include::howto/build.adoc[]
include::howto/traditional-deployment.adoc[] include::howto/traditional-deployment.adoc[]
include::howto/jedis-instead-of-lettuce.adoc[]
include::howto/testcontainers.adoc[]
[[howto.jedis-instead-of-lettuce]] [[howto.nosql]]
== Use Jedis Instead of Lettuce == NoSQL
Spring Boot offers a number of starters that support NoSQL technologies.
This section answers questions that arise from using NoSQL with Spring Boot.
[[howto.nosql.jedis-instead-of-lettuce]]
=== Use Jedis Instead of Lettuce
By default, the Spring Boot starter (`spring-boot-starter-data-redis`) uses https://github.com/lettuce-io/lettuce-core/[Lettuce]. By default, the Spring Boot starter (`spring-boot-starter-data-redis`) uses https://github.com/lettuce-io/lettuce-core/[Lettuce].
You need to exclude that dependency and include the https://github.com/xetorthio/jedis/[Jedis] one instead. You need to exclude that dependency and include the https://github.com/xetorthio/jedis/[Jedis] one instead.
Spring Boot manages both of these dependencies so you can switch to Jedis without specifying a version. Spring Boot manages both of these dependencies so you can switch to Jedis without specifying a version.
......
[[howto.testing-with-spring-security]]
== Testing With Spring Security
Spring Security provides support for running tests as a specific user.
For example, the test in the snippet below will run with an authenticated user that has the `ADMIN` role.
[source,java,indent=0,subs="verbatim"]
----
include::{docs-java}/howto/testingwithspringsecurity/MySecurityTests.java[]
----
Spring Security provides comprehensive integration with Spring MVC Test and this can also be used when testing controllers using the `@WebMvcTest` slice and `MockMvc`.
For additional details on Spring Security's testing support, refer to Spring Security's {spring-security-docs}#test[reference documentation]).
[[howto.testcontainers]] [[howto.testing]]
== Use Testcontainers for integration testing == Testing
Spring Boot includes a number of testing utilities and support classes as well as a dedicated starter that provides common test dependencies.
This section answers common questions about testing.
[[howto.testing.with-spring-security]]
=== Testing With Spring Security
Spring Security provides support for running tests as a specific user.
For example, the test in the snippet below will run with an authenticated user that has the `ADMIN` role.
[source,java,indent=0,subs="verbatim"]
----
include::{docs-java}/howto/testing/withspringsecurity/MySecurityTests.java[]
----
Spring Security provides comprehensive integration with Spring MVC Test and this can also be used when testing controllers using the `@WebMvcTest` slice and `MockMvc`.
For additional details on Spring Security's testing support, refer to Spring Security's {spring-security-docs}#test[reference documentation]).
[[howto.testing.testcontainers]]
=== Use Testcontainers for Integration Testing
The https://www.testcontainers.org/[Testcontainers] library provides a way to manage services running inside Docker containers. The https://www.testcontainers.org/[Testcontainers] library provides a way to manage services running inside Docker containers.
It integrates with JUnit, allowing you to write a test class that can start up a container before any of the tests run. It integrates with JUnit, allowing you to write a test class that can start up a container before any of the tests run.
Testcontainers is especially useful for writing integration tests that talk to a real backend service such as MySQL, MongoDB, Cassandra etc. Testcontainers is especially useful for writing integration tests that talk to a real backend service such as MySQL, MongoDB, Cassandra etc.
...@@ -7,7 +31,7 @@ Testcontainers can be used in a Spring Boot test as follows: ...@@ -7,7 +31,7 @@ Testcontainers can be used in a Spring Boot test as follows:
[source,java,indent=0,subs="verbatim"] [source,java,indent=0,subs="verbatim"]
---- ----
include::{docs-java}/howto/testcontainers/vanilla/MyIntegrationTests.java[] include::{docs-java}/howto/testing/testcontainers/vanilla/MyIntegrationTests.java[]
---- ----
This will start up a docker container running Neo4j (if Docker is running locally) before any of the tests are run. This will start up a docker container running Neo4j (if Docker is running locally) before any of the tests are run.
...@@ -17,7 +41,7 @@ This can be done with a static `@DynamicPropertySource` method that allows addin ...@@ -17,7 +41,7 @@ This can be done with a static `@DynamicPropertySource` method that allows addin
[source,java,indent=0,subs="verbatim"] [source,java,indent=0,subs="verbatim"]
---- ----
include::{docs-java}/howto/testcontainers/dynamicproperties/MyIntegrationTests.java[] include::{docs-java}/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.java[]
---- ----
The above configuration allows Neo4j-related beans in the application to communicate with Neo4j running inside the Testcontainers-managed Docker container. The above configuration allows Neo4j-related beans in the application to communicate with Neo4j running inside the Testcontainers-managed Docker container.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.docs.howto.testcontainers.dynamicproperties; package org.springframework.boot.docs.howto.testing.testcontainers.dynamicproperties;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.testcontainers.containers.Neo4jContainer; import org.testcontainers.containers.Neo4jContainer;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.docs.howto.testcontainers.vanilla; package org.springframework.boot.docs.howto.testing.testcontainers.vanilla;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.testcontainers.containers.Neo4jContainer; import org.testcontainers.containers.Neo4jContainer;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.docs.howto.testingwithspringsecurity; package org.springframework.boot.docs.howto.testing.withspringsecurity;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.docs.howto.testingwithspringsecurity; package org.springframework.boot.docs.howto.testing.withspringsecurity;
class UserController { class UserController {
......
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