1 Attachment(s)
Spring 3.2 web async test (multiple thread test)
I had spent a couple of days to try Spring 3.2 new mvc test feature for testing async request by asyncDispatch and some situation disturb me.(execute attachment by "mvn test" and look at the testing log).
My problems are
- Only a few method success, but most of them failed
- Sometimes async request method was invoked twice
Finally,I wrote another test method "testMultipleAsyncEcho2" to complete the test.
Is there a official,robust way to test async request ?
PathVariable at final problem
I found another problem.
Running attachment by execute "mvn jetty:run" command to run and go to http://localhost:8080/echo/.
Every thing is OK except type "Photo's name is Picture.jpg" in the second input field and click on the second Async button.
It raise a http 406 HttpMediaTypeNotAcceptableException.
That is because message embed in the final path(a PathVariable).
and 3.2 document says content type determines by file extension.
I had been writing a picture management system and always make picture's file name as final patch variable.
How can I change configuration to backwards to pre spring version?
Solved! Spring 3.2 web test cannot running under multiple thread
The MockMvc.java snip to display not thread safe.
Code:
public ResultActions perform(RequestBuilder requestBuilder) throws Exception {
....
this.filterChain.reset();
this.filterChain.doFilter(request, response);
applyDefaultResultActions(mvcResult);
....
}
So I rewrite some code to solve this problem