Skip to content

Tag: spring-boot-test

How to setServletPath() in Spring Junit WebTestClient?

This creates a MockHttpServletRequest that is send to the @RestContoller servlets. Problem: my servlets make use of HttpServletRequest.getServletPath(), but which is always empty using the WebTestClient approach above. Question: how can I explicit set the servletPath in my junit tests? Answer I could solve it as follows, but as this is really hacky, I’d still appreciate a proper solution.

Spring Boot Application is starting up from a JUnit test but unable to access through URL

I have a JUnit Test that starts my spring boot appcliation ( If I run the JUnit test, Application is successfully starting up, but not accessible through url Application Logs: When I tried to access the application through url ‘http://localhost:8080/process’, It says Site can’t be reached. Answer Why would you do such thing? This should be a unit test and