HttpRequestMethodNotSupportedException when testing controller
Posted by Rey Jexter Bumalay at 10:43 AMAfter a spending about 2 days researching on the HttpRequestMethodNotSupportedException thrown when running AbstractController.handleRequest in my test, I decided to view spring source code to see the real cause of this problem.
The problem was when creating MockHttpServletRequest, it doesn't set a default method name. To solve this problem, I simply added a request method type on the mock request object. See the following code:
request = new MockHttpServletRequest();
request.setMethod("POST");
Labels: spring, spring mvc, testing
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment