Skip to content

spring.test.database.replace property ignored #7229

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

Closed
snowe2010 opened this issue Oct 26, 2016 · 5 comments
Closed

spring.test.database.replace property ignored #7229

snowe2010 opened this issue Oct 26, 2016 · 5 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@snowe2010
Copy link

Looking at the annotation AutoConfigureTestDatabase, I should be able to use the property spring.test.database.replace to avoid annotation based configuration for all of my tests (we are using custom postgres dialect and can't get hsqldb to work). Attempting to use this property does not work though. I will attempt to create a project showing the problem later.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 26, 2016
@wilkinsona
Copy link
Member

Looking at the annotation AutoConfigureTestDatabase, I should be able to use the property spring.test.database.replace to avoid annotation based configuration for all of my tests

What did you see that caused you to draw that conclusion?

The @PropertyMapping annotation controls the mapping of annotation attributes into a PropertySource. This PropertySource is added in first place, thereby taking precedence over other sources. This means that your spring.test.database.replace property is very unlikely to have any effect unless you're customising the environment with another property source and positioning it before the annotations-based property source.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Oct 26, 2016
@snowe2010
Copy link
Author

Ah I was also getting some information from here, http://www.devthoughts.pl/2016/08/02/datajpatest-from-spring-boot/, but I guess that's wrong then. Is there any way to avoid the annotation based config? I'd rather not have to put an annotation on every test and instead use a property.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 26, 2016
@philwebb
Copy link
Member

There isn't currently a way to do this. I think it should be possible to create your own meta-annotation if that helps. Something like:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE_
public @interface MyDataJpaTest {
}

Doing something like we did for @AutoConfigureMockMvc might be a nice enhancement here. See #6455

@philwebb philwebb added type: enhancement A general enhancement status: ideal-for-contribution An issue that a contributor can help us with and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Oct 26, 2016
@snowe2010
Copy link
Author

Ah, darn, I thought that might be the only way. Ok, well thank you for the help then.

eddumelendez added a commit to eddumelendez/spring-boot that referenced this issue Dec 3, 2016
eddumelendez added a commit to eddumelendez/spring-boot that referenced this issue Dec 3, 2016
eddumelendez added a commit to eddumelendez/spring-boot that referenced this issue Dec 3, 2016
eddumelendez added a commit to eddumelendez/spring-boot that referenced this issue Dec 3, 2016
@philwebb philwebb added this to the 1.5.0 RC1 milestone Dec 5, 2016
@snicoll
Copy link
Member

snicoll commented Dec 15, 2016

Closing in favour of PR #7560

@snicoll snicoll closed this as completed Dec 15, 2016
@snicoll snicoll added status: duplicate A duplicate of another issue and removed type: enhancement A general enhancement status: ideal-for-contribution An issue that a contributor can help us with labels Dec 15, 2016
@snicoll snicoll removed this from the 1.5.0 M1 milestone Dec 15, 2016
snicoll added a commit that referenced this issue Dec 16, 2016
* pr/7560:
  Polish contribution
  Add support for property spring.test.database.replace
@philwebb philwebb added status: superseded An issue that has been superseded by another and removed status: duplicate A duplicate of another issue labels Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

5 participants