Sam Brannen

Polishing

Introduce test for DeferredResult w/ delayed error in MVC Test

This commit introduces a test that verifies the fix introduced in

6842fd7fb954e751fb6c310f7183527fd1876653.

Issue: SPR-13079

Polish AsyncTests

Document MVC Test log()/print() variants in reference manual

Issue: SPR-13171

Introduce DirtiesContextBeforeModesTestExecutionListener

SPR-12429 introduced various `BEFORE_` modes in `@DirtiesContext`. To

support these new modes, `DirtiesContextTestExecutionListener` (DCTEL)

was updated to support both `BEFORE_` and `AFTER_` modes. However,

there is a problem with having DCTEL support `BEFORE_` modes since it

is typically configured to execute after the

`DependencyInjectionTestExecutionListener` (DITEL), and this leads to

several undesired side effects:

  • The test's `ApplicationContext` is closed by DCTEL after

    dependencies have been injected into the test instance.

  • Injected dependencies may therefore attempt to interact with an

    `ApplicationContext` that is no longer active.

  • If a test has its `ApplicationContext` injected as a dependency,

    interaction with the context will likely fail since the context has

    been closed.

  • Any `TestExecutionListeners` registered after DCTEL will get a new

    `ApplicationContext` if they invoke `getApplicationContext()` on the

    `TestContext`.

This commit fixes these issues by introducing a new

`DirtiesContextBeforeModesTestExecutionListener` (DCBMTEL) that is

registered by default before DITEL. The previous support for `BEFORE_*`

modes has been moved from DCTEL to DCBMTEL. In addition, an

`AbstractDirtiesContextTestExecutionListener` has been extracted from

DCTEL in order to avoid code duplication.

Issue: SPR-13180

Updated required email dependencies in reference manual

Beginning with Java 6, the JavaBeans Activation Framework (JAF) is part

of the JDK. Thus, there is no longer a need to explicitly include a

dependency on `activation.jar` when using Spring's email support in

Spring Framework 4.0 and higher which anyway requires Java 6 or higher.

This commit therefore removes the JAF requirement from the reference

manual.

Update required email dependencies in reference manual

Beginning with Java 6, the JavaBeans Activation Framework (JAF) is part

of the JDK. Thus, there is no longer a need to explicitly include a

dependency on `activation.jar` when using Spring's email support in

Spring Framework 4.0 and higher which anyway requires Java 6 or higher.

This commit therefore removes the JAF requirement from the reference

manual.

Polish Javadoc for (Synthesizing)MethodParameter

Use annotation attribute aliases in examples

This commit updates examples in the reference manual to use annotation

attribute aliases.

Polish attribute alias examples in "what's new"

Use annotation attribute aliases in examples

This commit updates examples in the reference manual to use annotation

attribute aliases.

Polish CORS documentation in the reference manual

Document XML attributes in mvc:resource-chain in 4.1 XSD

Issue: SPR-12804

Polish resource chain documentation

Polish resource chain documentation

Polish LoggingResultHandler in Spring MVC Test

Issue: SPR-13171

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

Print cookies in human-readable form in Spring MVC Test

Prior to this commit, when rendering cookies via `andDo(print())` in

Spring MVC Test, the output for the `MockHttpServletResponse` would

look something like the following:

Cookies = [javax.servlet.http.Cookie@25084a1e]

The reason is that the Cookie class in javax.servlet-api-3.0.1.jar does

not implement toString(). Consequently, nothing about the cookie's

name, value, etc., is displayed, thereby making the debug output for

cookies next to useless.

This commit improves on this by implementing custom toString() logic

for cookies in debug output in Spring MVC Test. For example, the output

now looks like this (without the newlines):

Cookies = [[Cookie@47faa49c name = 'enigma', value = '42',

comment = [null], domain = [null], maxAge = -1,

path = [null], secure = false, version = 0,

httpOnly = false]]

In addition, this commit fixes a minor bug for FlashMap debug output if

the FlashMap is empty.

Issue: SPR-13168

Polish Javadoc for MVC parameter binding annotations

Merge pull request #828 from Youmoo/Youmoo-patch-1

  • Youmoo-Youmoo-patch-1:

    Fix BeanWrapperImpl example code in ref. manual

Polish MimeType

Refactor WebSocket int. tests to work w/ Jetty 9.3

Recent builds of Jetty 9.3 require that Jetty's own ServletContext

implementation be supplied to WebSocketServerFactory's init() method.

Otherwise, the Jetty server will fail to start with the exception

message: "Not running on Jetty, WebSocket support unavailable".

This commit refactors AbstractWebSocketIntegrationTests,

AbstractSockJsIntegrationTests, and all WebSocketTestServer

implementations in order to support this new requirement.

Specifically:

  • WebSocketTestServer defines a new getServletContext() method;

    TomcatWebSocketTestServer, UndertowTestServer, and

    JettyWebSocketTestServer have all been updated to return the

    ServletContext created by the embedded server.

  • The setup() methods in AbstractWebSocketIntegrationTests and

    AbstractSockJsIntegrationTests have been updated so that the

    WebApplicationContext is supplied the appropriate ServletContext,

    after deployConfig() has been invoked on the WebSocketTestServer but

    before the WebApplicationContext is refreshed.

Issue: SPR-13162

Uses Charset instead of String in MimeType.equals()

Prior to this commit, Spring's MimeType checked for equality between

two MIME types based on the equality of their properties maps; however,

the properties maps contain string representations of the "charset"

values. Thus, "UTF-8" is never equal to "utf-8" which breaks the

contract for character set names which must be compared in a

case-insensitive manner.

This commit addresses this issue by ensuring that "charset" properties

in MimeType instances are compared as Java Charset instances, thereby

ignoring case when checking for equality between charset names.

Issue: SPR-13157

Polish Javadoc in MimeType

Support inlined SQL statements in @Sql

Prior to this commit, it was only possible to declare SQL statements

via @Sql within external script resources (i.e., classpath or file

system resources); however, many developers have inquired about the

ability to inline SQL statements with @Sql analogous to the support for

inlined properties in @TestPropertySource.

This commit introduces support for declaring inlined SQL statements

in `@Sql` via a new `statements` attribute. Inlined statements are

executed after statements in scripts.

Issue: SPR-13159

Document attribute alias support in AnnotationUtils

Synthesize annotation arrays within AnnotationUtils

Issue: SPR-11393

Fix broken (Async)RestTemplate integration tests

Issue: SPR-13157

Fix formatting issues in the testing chapter

Synthesize annotation from defaults

This commit introduces a convenience method in AnnotationUtils for

synthesizing an annotation from its default attribute values.

TransactionalTestExecutionListener has been refactored to invoke this

new convenience method.

Issue: SPR-13087