Add liquibase test rollback on update property

See gh-13159
This commit is contained in:
Vladyslav Kiriushkin
2018-05-14 11:54:59 +03:00
committed by Stephane Nicoll
parent b839c98de9
commit 08279c889c
3 changed files with 25 additions and 1 deletions

View File

@@ -129,6 +129,7 @@ public class LiquibaseAutoConfiguration {
liquibase.setLabels(this.properties.getLabels());
liquibase.setChangeLogParameters(this.properties.getParameters());
liquibase.setRollbackFile(this.properties.getRollbackFile());
liquibase.setTestRollbackOnUpdate(this.properties.isTestRollbackOnUpdate());
return liquibase;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -94,6 +94,11 @@ public class LiquibaseProperties {
*/
private File rollbackFile;
/**
* Whether rollback should be tested before update is performed.
*/
private boolean testRollbackOnUpdate;
public String getChangeLog() {
return this.changeLog;
}
@@ -191,4 +196,11 @@ public class LiquibaseProperties {
this.rollbackFile = rollbackFile;
}
public boolean isTestRollbackOnUpdate() {
return this.testRollbackOnUpdate;
}
public void setTestRollbackOnUpdate(boolean testRollbackOnUpdate) {
this.testRollbackOnUpdate = testRollbackOnUpdate;
}
}

View File

@@ -238,6 +238,17 @@ public class LiquibaseAutoConfigurationTests {
});
}
@Test
public void testRollbackOnUpdate() throws IOException {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues(
"spring.liquibase.test-rollback-on-update:true")
.run((context) -> {
SpringLiquibase liquibase = context.getBean(SpringLiquibase.class);
assertThat(liquibase.isTestRollbackOnUpdate());
});
}
@Test
public void liquibaseDataSource() {
this.contextRunner.withUserConfiguration(LiquibaseDataSourceConfiguration.class,