mockhostdomainremoteAddr: --> (anything different)I cannot find proper method for that. Is it even possible?..." />

MockHttpServletRequestBuilder - how to change remoteAddress of remoteHost of HttpServletRequest?

I'm trying to create mock request for integration test (@SpringBootTest).


MockHttpServletRequestBuilder requestBuilder = get("/users/register/user1");

What I want to check is the remote of this request. In my controller Im getting this information from HttpServletRequest

HttpServletRequest request;



Unfortunately right now getRemoteHost() will always return localhost.

I would like to change it in my mock request to something else eg:

remoteHost: localhost --> mockhostdomain

remoteAddr: --> (anything different)

I cannot find proper method for that. Is it even possible?...

Read More »

By: StackOverFlow - 5 days ago

Related Posts