Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure @DataJpaTest's Embedded Datasource URL #10271

Closed
SingleShot opened this issue Sep 12, 2017 · 5 comments
Closed

Configure @DataJpaTest's Embedded Datasource URL #10271

SingleShot opened this issue Sep 12, 2017 · 5 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@SingleShot
Copy link

SingleShot commented Sep 12, 2017

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!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 12, 2017
@snicoll
Copy link
Member

snicoll commented Sep 12, 2017

There is spring.test.database.connection so I guess spring.test.database.url is doable.

@snicoll snicoll added priority: low type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 12, 2017
@SingleShot
Copy link
Author

Of course, right after posting this I discovered this (in src/test/resources/application.properties) produces what I want without having to add annotations anywhere:

spring.datasource.url=jdbc:hsqldb:mem:mydatabase;sql.syntax_pgs=true
spring.test.database.replace=none

So... feel free to close this ticket as "won't fix" - thanks for considering it!

@snicoll
Copy link
Member

snicoll commented Sep 12, 2017

There's that, right. I wouldn't use application.properties though, you're potentially shadowing the application.properties you might have in your production resources for that module. But that's a detail.

@snicoll snicoll closed this as completed Sep 12, 2017
@snicoll snicoll added status: invalid An issue that we don't feel is valid and removed priority: low type: enhancement A general enhancement labels Sep 12, 2017
@snicoll

This comment has been minimized.

@geoffreywiseman

This comment has been minimized.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Nov 14, 2019
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

6 participants