Skip to content
Advertisement

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.

SpringBootTest for an arbitrary ApplicationConfiguration class to test the reading of the application.yml file

I would like to learn how to write a SpringBootTest for an existing ApplicationConfiguration class for the purpose of testing the functionality of reading the application.yml file. I would be happy with java or groovy. I am not able to share the existing ApplicationConfiguration class, so I would gladly accept any example offered that starts with an existing ApplicationConfiguration that

Junit Force to throw Exception on method call

I am trying to throw the exception whenever simpleJdbcCall.execute(namedParameters) called but I see it is not throwing the error, is there something i am missing here ? Here is my class here is my Junit Class Answer When writing spring-boot integration test you should inject the mock beans using @MockBean annotation You can a follow some of the examples here

Attribute ServerContainer not found in ServletContext

In my Spring boot application i use also websockets. Everything works fine, as expected in production. Now i started to create UnitTests with Spring-Boot-Test. Every time i start a @SpringBootTest , i get following exception (shortened): Long Version Spring Websocket Config Class POM.XML Spring Application Class Typical Failing Test Problem The Problem is, the actual Test never comes to the

Advertisement