dimanche 28 août 2016

Unable to use @DataJpaTest if Spring security is on classpath

I am trying to update my test cases to use the @DataJpaTest. However, I am encountering some issues that appear to be related to Spring Security. The following is an example of the test class.

@RunWith(SpringRunner.class)
@DataJpaTest
public class ExampleRepositoryTest  {

    @Rule
    public final ExpectedException exception = ExpectedException.none();

    @Inject
    private ExampleRepository repository;

    @Test
    public void test() throws Exception {
       ...
    }

I keep getting the error java.lang.IllegalStateException: Failed to load ApplicationContext due to the missing bean org.springframework.security.config.annotation.ObjectPostProcessor.

The project is a RESTful application with Spring security. The original test case created a full Spring Boot context using @SpringBootTest. The @DataJpaTest is supposed to help me test the JPA slice, which is exactly what I want.

Any help would be greatly appreciated. What am I missing?

Aucun commentaire:

Enregistrer un commentaire