Introduce LoggingResultHandler in Spring MVC Test

Prior to this commit, the Spring MVC Test framework only provided
support for printing debug information about the MvcResult to STDOUT.

This commit introduces support for logging `MvcResult` details at
`DEBUG` level via the Apache Commons Logging API. In addition, this
commit introduces additional `print(..)` variants for printing debug
information to custom output streams and writers.

Specifically, `MockMvcResultHandlers` has been augmented with the
following new static methods:

 - `log()`
 - `print(OutputStream)`
 - `print(Writer)`

Issue: SPR-13171
This commit is contained in:
Sam Brannen
2015-06-27 21:53:19 +02:00
parent 895d43a2b3
commit 693dcba867
6 changed files with 138 additions and 32 deletions

View File

@@ -554,14 +554,9 @@ public @interface MyTestConfig {
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
----
* The `ContextCache` that is used for caching ++ApplicationContext++s
between tests is now a public API with a default implementation that
can be replaced for custom caching needs.
* `DefaultTestContext`, `DefaultBootstrapContext`, and
`DefaultCacheAwareContextLoaderDelegate` are now public classes in the
`support` subpackage, allowing for custom extensions.
* ++TestContextBootstrapper++s are now responsible for building the
`TestContext`.
* `AopTestUtils` is a new testing utility that allows developers to
obtain a reference to the underlying target object hidden behind one
or more Spring proxies.
* `ReflectionTestUtils` now supports setting and getting `static` fields,
including constants.
* The original ordering of bean definition profiles declared via
@@ -575,6 +570,18 @@ public @interface MyTestConfig {
configuration for the `ApplicationContext`.
* `@Sql` now supports execution of _inlined SQL statements_ via a new
`statements` attribute.
* The `ContextCache` that is used for caching ++ApplicationContext++s
between tests is now a public API with a default implementation that
can be replaced for custom caching needs.
* `DefaultTestContext`, `DefaultBootstrapContext`, and
`DefaultCacheAwareContextLoaderDelegate` are now public classes in the
`support` subpackage, allowing for custom extensions.
* ++TestContextBootstrapper++s are now responsible for building the
`TestContext`.
* In the Spring MVC Test framework, `MvcResult` details can now be logged
at `DEBUG` level or written to a custom `OutputStream` or `Writer`. See
the new `log()`, `print(OutputStream)`, and `print(Writer)` methods in
`MockMvcResultHandlers` for details.
* The JDBC XML namespace supports a new `database-name` attribute in
`<jdbc:embedded-database>`, allowing developers to set unique names
for embedded databases - for example, via a SpEL expression or a
@@ -587,6 +594,3 @@ public @interface MyTestConfig {
** `EmbeddedDatabaseFactory.setGenerateUniqueDatabaseName()`
** `EmbeddedDatabaseBuilder.generateUniqueName()`
** `<jdbc:embedded-database generate-name="true" ... >`
* `AopTestUtils` is a new testing utility that allows developers to
obtain a reference to the underlying target object hidden behind one
or more Spring proxies.