I am writing a Spring test case for my Spring controller, in my controller we use like this: request.getSession (). getServletContext (). getRealPath ("/ myFolderName"); It works fine for regular queries, but for unit test cases like MockHttpServletRequest, it's a call to the method above that indicates null. how can i get realPath for MockHttpServletRequest.
Thanks, Praneeth.
By default MockHttpServletRequest, it acts as if the root webapp folder was a pathpath, so you should be able to use getRealPath()class paths for resources.
MockHttpServletRequest
getRealPath()
MockHttpServletRequest MockServletContext, MockServletContext getRealPath() ..
MockServletContext