Skip to content

Configure @DataJpaTest's Embedded Datasource URL  #10271

Closed
@SingleShot

Description

@SingleShot

This is a "quality of life" request...

Here's my use case: I want my app configured for Postgres, but I want to run @DataJpaTest tests against HSQLDB using Postgres compatibility mode. I've figured out how to do this by annotating my tests like so

@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)

And adding the following to src/test/resources/application.properties:

spring.datasource.url=jdbc:hsqldb:mem:mydatabase;sql.syntax_pgs=true

The important tidbit is the ;sql.syntax_pgs=true which turns on Postgres compatibility mode.

I would prefer to not have to add @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) to every test or to make a custom annotation, and instead, would like a property that allows me to tweak my embedded test database's connection url, for example spring.test.datasource.url=jdbc:hsqldb:mem:%s;sql.syntax_pgs=true

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions