Skip to content

Test failed on a Resource server when using Spring WebMvc RouterFunction #9

Closed
@hantsy

Description

@hantsy

I created a Resource server example project using Spring WebMvc RouterFunction and Auth0 IDP.

https://github.com/hantsy/spring-webmvc-auth0-sample

When adding tests, I followed the Spring Security Samples.

I tried to use @MockMvc to test the functionality but failed. The @MockMvc can not recognize RouterFunction bean and the new Spring Security Servlet SecurityFilterChain.

Then I created a MockMvc from WebApplicationContext, check https://github.com/hantsy/spring-webmvc-auth0-sample/blob/master/src/test/java/com/example/demo/ApplicationTests.java, but failed due to an exception.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.test.web.servlet.DefaultMvcResult.setHandler(Object)" because "mvcResult" is null

    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)

Also posted on stackoverflow, https://stackoverflow.com/questions/67171628/resource-server-test-failes-with-auth0-issuer-uri

Metadata

Metadata

Assignees

Labels

invalidThis doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions