embedded-database-spring-test icon indicating copy to clipboard operation
embedded-database-spring-test copied to clipboard

db rider with zonkyio embedded postgresql

Open alex123asd123asd opened this issue 1 year ago • 2 comments

Hello. Does it possible to use db rider with zonkyio embedded postgresql? I have tried, but without success - @DataSet annotation throws an exception that table does not exist.

alex123asd123asd avatar Apr 17 '24 07:04 alex123asd123asd

Hi, thanks for the comment. I've just tested it and it seems that this combination works fine. Technically, it should be possible to use the embedded database library with any tool that accesses the database using Spring's dataSource bean.

However, proper configuration is essential for proper operation. Make sure you have the caseSensitiveTableNames flag enabled and that your schema name is set up correctly. In my case, the annotations below were enough to get it working.

@DBRider
@DBUnit(caseSensitiveTableNames = true, escapePattern = "\"?\"", schema = "test")

tomix26 avatar Apr 17 '24 15:04 tomix26

Cool it works. Thank you for your help :)

@Sql("/datasets/init.sql")
@ExtendWith(DBUnitExtension.class)
@SpringJUnitConfig(DbTestConfig.class)
@DBUnit(caseSensitiveTableNames = true)
@AutoConfigureEmbeddedDatabase(provider = ZONKY)
class CddAlertRepositoryImplV2IntegrationTest {

    @Autowired
    MyRepository myRepository;

    Info INFO = Info.builder()
            .x("x")
            .y("y")
            .z("z")
            .build();

    @Test
    @DataSet("/datasets/data.xml")
    void test() {
        var data = myRepository.getData(INFO);
        var expected = ...;
        assertEquals(expected, data);
    }

}

alex123asd123asd avatar Apr 18 '24 19:04 alex123asd123asd

Glad to hear it 👍

tomix26 avatar Jul 19 '24 13:07 tomix26