I had some unit tests for the DAO layer of a Spring 4 MVC application. Then I added Spring Security to certain methods in my controllers, and the DAO's they use.
I figured out how to make the @WithMockUser annotation work in the controller tests, but I'm stumped on the DAO tests. The exception I get on every dao test is:
java.lang.IllegalStateException: Failed to load ApplicationContext
....
Caused by: java.lang.IllegalArgumentException: An AuthenticationManager is required
I have these annoations at the start of the DaoTest:
@TestExecutionListeners({ WithSecurityContextTestExecutionListener.class })
@ContextConfiguration(classes = DaoConfig.class)
The @ContextConfiguration is the same as in the actual code; I've suggestions to make it different, but nothing concrete. How do I unravel this? I'm also hoping there's a way to do it without using org.springframework.web.* or org.springframework.test.web.* classes, since this should be 'underneath' the whole web tier.
Aucun commentaire:
Enregistrer un commentaire