I have a SpringBoot 2.0 application, and I've decided to mix annotations and XML configuration using orm.xml
. So, I've put orm.xml
(JPA file with XML configuration) in resources/META-INF
, and, when starting the application, it's taken into account and everything is good, it works like a charm.
However, when running integration tests (which use an in-memory database), orm.xml
seems to be completely ignored, as the test fails with an exception related to a missing mapping, mapping which I've written in orm.xml
(an embeddable entity).
Here's how a test looks like:
package hello;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@DataJpaTest
public class ApplicationTests {
@Test
public void contextLoads() {
}
}
I've also tried @AutoConfigureTestDatabase
instead of @DataJpaTest
, but with no success.
What should I change, in order for the integration test to load orm.xml
?