Using MockMVC in tests, and I need to check the GET URL, which is already URL encoded:
http://host:port/app/controller/[ALREADY URL ENCODED]
The code:
mockmvc.perform(get("/controller/[ALREADY URL ENCODED]")
However, in the logs, I see that the URL has been re-encoded by the URL before it goes to the appropriate controller method. Is there any way to prevent spring mockmvc for url encoding? Perhaps disable url encoding in test?
This is an example of the string [[SUSPENDED URL ENCODED] ":
MEUwQzBBMD8wPTAJBgUrDgMCGgUABBQ%2Fm36Fj2BE19VBYXRO62zrgIYp0gQVAQazEyvlq22wsMBkRyAeaUiZ%2BhTUAgMGJbQ%3D
This is the URL again before the controller sees it.
This is from logs (the string was re-encoded at the url)
xxxxx [main] DEBUG [ostwsTestDispatcherServlet] DispatcherServlet with name '' processing GET request for [/app/controller/MEUwQzBBMD8wPTAJBgUrDgMCGgUABBQ%252Fm36Fj2BE19VBYXRO62zrgIYp0gQVAQazEyvlq22wsMBkRyAeaUiZ%252BhTUAgMGJbQ%253D]
Please note that if I invoke the use of CURL, then there is no url encoding executed by the spring framework, and the controller receives what is sent. However, mockmvc would do the encoding before it gets the appropriate controller method.
curl -X GET http:host:port/app/controller/[ALREADY URL ENCODED]
Thanks.
source share