diff --git a/pom.xml b/pom.xml index ba9d14116..d8a60477f 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,8 @@ 3.3.1 3.0.2 + 5.10.3 + 1.10.3 Liquibase.org @@ -85,9 +87,9 @@ ${liquibase-core.version} - org.codehaus.groovy + org.apache.groovy groovy-all - 2.5.19 + 4.0.22 pom @@ -98,12 +100,44 @@ org.codehaus.groovy groovy-swing + + junit + junit + org.spockframework spock-core - 1.3-groovy-2.5 + 2.3-groovy-4.0 + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + compile + + + org.junit.platform + junit-platform-suite + ${junit-platform.version} + + + org.junit.platform + junit-platform-launcher + ${junit-platform.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit.version} + + + org.junit.platform + junit-platform-engine + ${junit-platform.version} + test org.skyscreamer @@ -222,7 +256,7 @@ com.athaydes spock-reports - 1.7.1 + 2.5.1-groovy-4.0 test @@ -294,6 +328,9 @@ + + 1.8 + org.apache.maven.plugins @@ -395,6 +432,21 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + + **/*Test + **/*Tests + **/*Spec + **/*Suite + + + + @@ -450,6 +502,9 @@ + + 1.8 + diff --git a/src/main/groovy/liquibase/harness/AdvancedHarnessSuite.groovy b/src/main/groovy/liquibase/harness/AdvancedHarnessSuite.groovy index 8a3dde3b6..9f46c1eed 100644 --- a/src/main/groovy/liquibase/harness/AdvancedHarnessSuite.groovy +++ b/src/main/groovy/liquibase/harness/AdvancedHarnessSuite.groovy @@ -1,12 +1,11 @@ package liquibase.harness - import liquibase.harness.generateChangelog.GenerateChangelogTest import liquibase.harness.snapshot.SnapshotObjectTests -import org.junit.runner.RunWith -import org.junit.runners.Suite +import org.junit.platform.suite.api.SelectClasses +import org.junit.platform.suite.api.Suite -@RunWith(Suite.class) -@Suite.SuiteClasses([GenerateChangelogTest, SnapshotObjectTests]) +@Suite +@SelectClasses([GenerateChangelogTest, SnapshotObjectTests]) abstract class AdvancedHarnessSuite { } diff --git a/src/main/groovy/liquibase/harness/BaseHarnessSuite.groovy b/src/main/groovy/liquibase/harness/BaseHarnessSuite.groovy index 7954be723..ae4799e41 100644 --- a/src/main/groovy/liquibase/harness/BaseHarnessSuite.groovy +++ b/src/main/groovy/liquibase/harness/BaseHarnessSuite.groovy @@ -2,10 +2,10 @@ package liquibase.harness import liquibase.harness.change.ChangeObjectTests import liquibase.harness.data.ChangeDataTests -import org.junit.runner.RunWith -import org.junit.runners.Suite +import org.junit.platform.suite.api.SelectClasses +import org.junit.platform.suite.api.Suite -@RunWith(Suite.class) -@Suite.SuiteClasses([ChangeObjectTests, ChangeDataTests]) +@Suite +@SelectClasses([ChangeObjectTests, ChangeDataTests]) abstract class BaseHarnessSuite { } diff --git a/src/main/groovy/liquibase/harness/FoundationalHarnessSuite.groovy b/src/main/groovy/liquibase/harness/FoundationalHarnessSuite.groovy index b06977cbc..ecd19576d 100644 --- a/src/main/groovy/liquibase/harness/FoundationalHarnessSuite.groovy +++ b/src/main/groovy/liquibase/harness/FoundationalHarnessSuite.groovy @@ -1,11 +1,10 @@ package liquibase.harness - import liquibase.harness.compatibility.foundational.FoundationalTest -import org.junit.runner.RunWith -import org.junit.runners.Suite +import org.junit.platform.suite.api.SelectClasses +import org.junit.platform.suite.api.Suite -@RunWith(Suite.class) -@Suite.SuiteClasses([FoundationalTest]) +@Suite +@SelectClasses([FoundationalTest]) abstract class FoundationalHarnessSuite { } diff --git a/src/main/groovy/liquibase/harness/change/ChangeObjectTests.groovy b/src/main/groovy/liquibase/harness/change/ChangeObjectTests.groovy index 62750b16e..d8f60cb3c 100644 --- a/src/main/groovy/liquibase/harness/change/ChangeObjectTests.groovy +++ b/src/main/groovy/liquibase/harness/change/ChangeObjectTests.groovy @@ -5,7 +5,7 @@ import liquibase.database.jvm.JdbcConnection import liquibase.harness.config.DatabaseUnderTest import liquibase.harness.config.TestConfig import liquibase.harness.util.rollback.RollbackStrategy -import org.junit.Assume +import org.junit.jupiter.api.Assumptions import spock.lang.Shared import spock.lang.Specification import spock.lang.Unroll @@ -44,7 +44,7 @@ class ChangeObjectTests extends Specification { and: "ignore testcase if it's invalid for this combination of db type and/or version" shouldRunChangeSet = !expectedSql?.toLowerCase()?.contains("invalid test") - Assume.assumeTrue(expectedSql, shouldRunChangeSet) + Assumptions.assumeTrue(shouldRunChangeSet, expectedSql) and: "fail test if snapshot is not provided" shouldRunChangeSet = expectedSnapshot != null diff --git a/src/main/groovy/liquibase/harness/compatibility/foundational/FoundationalTest.groovy b/src/main/groovy/liquibase/harness/compatibility/foundational/FoundationalTest.groovy index 65ebc47ac..f9cd7e16c 100644 --- a/src/main/groovy/liquibase/harness/compatibility/foundational/FoundationalTest.groovy +++ b/src/main/groovy/liquibase/harness/compatibility/foundational/FoundationalTest.groovy @@ -7,7 +7,7 @@ import liquibase.harness.config.TestConfig import liquibase.harness.util.rollback.RollbackStrategy import org.json.JSONArray import org.json.JSONObject -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.skyscreamer.jsonassert.JSONCompareMode import spock.lang.Shared import spock.lang.Specification @@ -116,7 +116,7 @@ class FoundationalTest extends Specification { assert compareJSONArrays(generatedResultSetArray, expectedResultSetArray, JSONCompareMode.LENIENT) } catch (Exception exception) { Scope.getCurrentScope().getUI().sendMessage("Error executing metadata checking sql! " + exception.printStackTrace()) - Assert.fail exception.message + Assertions.fail exception.message } finally { newConnection == null ?: newConnection.close() @@ -130,7 +130,7 @@ class FoundationalTest extends Specification { // Assume test object was not created after 'update' command execution and test failed. Scope.getCurrentScope().getUI().sendMessage("Error executing test table checking sql! " + sqlException.printStackTrace()) - Assert.fail sqlException.message + Assertions.fail sqlException.message } } @@ -151,7 +151,7 @@ class FoundationalTest extends Specification { Scope.getCurrentScope().getUI().sendMessage("ERROR!: Rollback was not successful! " + "The object was not removed after 'rollback' command: " + resultSet.getMetaData().getTableName(0)) - Assert.fail() + Assertions.fail() } } catch (ignored) { (connection.isClosed() || connection.autoCommit) ?: connection.commit() diff --git a/src/main/groovy/liquibase/harness/data/ChangeDataTests.groovy b/src/main/groovy/liquibase/harness/data/ChangeDataTests.groovy index e9d54c3b9..dc8cb10cc 100644 --- a/src/main/groovy/liquibase/harness/data/ChangeDataTests.groovy +++ b/src/main/groovy/liquibase/harness/data/ChangeDataTests.groovy @@ -9,8 +9,7 @@ import liquibase.harness.util.rollback.RollbackStrategy import liquibase.resource.ClassLoaderResourceAccessor import org.json.JSONArray import org.json.JSONObject -import org.junit.Assert -import org.junit.Assume +import org.junit.jupiter.api.Assumptions import org.skyscreamer.jsonassert.JSONCompareMode import spock.lang.Shared import spock.lang.Specification @@ -59,7 +58,7 @@ class ChangeDataTests extends Specification { and: "ignore testcase if it's invalid for this combination of db type and/or version" shouldRunChangeSet = !expectedSql?.toLowerCase()?.contains("invalid test") - Assume.assumeTrue(expectedSql, shouldRunChangeSet) + Assumptions.assumeTrue(shouldRunChangeSet, expectedSql) and: "fail test if expectedResultSet is not provided" shouldRunChangeSet = expectedResultSet != null diff --git a/src/main/groovy/liquibase/harness/generateChangelog/GenerateChangelogTest.groovy b/src/main/groovy/liquibase/harness/generateChangelog/GenerateChangelogTest.groovy index 340d3a91c..63df90d9b 100644 --- a/src/main/groovy/liquibase/harness/generateChangelog/GenerateChangelogTest.groovy +++ b/src/main/groovy/liquibase/harness/generateChangelog/GenerateChangelogTest.groovy @@ -7,7 +7,7 @@ import liquibase.harness.config.DatabaseUnderTest import liquibase.harness.config.TestConfig import liquibase.harness.util.rollback.RollbackStrategy import liquibase.ui.UIService -import org.junit.Assume +import org.junit.jupiter.api.Assumptions import spock.lang.Shared import spock.lang.Specification import spock.lang.Unroll @@ -50,7 +50,7 @@ class GenerateChangelogTest extends Specification { and: "ignore testcase if it's invalid for this combination of db type and/or version" shouldRunChangeSet = !getResourceContent("/$testInput.sqlChangelogPath").toLowerCase()?.contains("invalid test") - Assume.assumeTrue("INFO: Test for $testInput.change is ignored", shouldRunChangeSet) + Assumptions.assumeTrue(shouldRunChangeSet, "INFO: Test for $testInput.change is ignored") and: "testing generateChangelog command for all files format" def map = new LinkedHashMap() diff --git a/src/main/groovy/liquibase/harness/util/TestUtils.groovy b/src/main/groovy/liquibase/harness/util/TestUtils.groovy index fd0b2e804..af5a6a2a6 100644 --- a/src/main/groovy/liquibase/harness/util/TestUtils.groovy +++ b/src/main/groovy/liquibase/harness/util/TestUtils.groovy @@ -7,14 +7,13 @@ import liquibase.harness.util.rollback.RollbackByTag import liquibase.harness.util.rollback.RollbackStrategy import liquibase.harness.util.rollback.RollbackToDate import liquibase.resource.SearchPathResourceAccessor -import org.junit.Assert +import org.junit.jupiter.api.Assertions import java.nio.file.Path import java.nio.file.Paths import java.util.logging.Logger import org.apache.commons.io.FileUtils -import static liquibase.harness.util.FileUtils.deleteFile class TestUtils { @@ -64,7 +63,7 @@ class TestUtils { commandScope.getCommand().toString() + ". " + exception.printStackTrace()) Logger.getLogger(this.class.name).info("If this is expected to be invalid query for this database/version, " + "create an 'expectedSql.sql' file that starts with 'INVALID TEST' and an explanation of why.") - Assert.fail exception.message + Assertions.fail exception.message } return outputStream } @@ -97,7 +96,7 @@ class TestUtils { commandScope.getCommand().toString() + ". " + exception.printStackTrace()) Logger.getLogger(this.class.name).info("If this is expected to be invalid query for this database/version, " + "create an 'expectedSql.sql' file that starts with 'INVALID TEST' and an explanation of why.") - Assert.fail exception.message + Assertions.fail exception.message } return outputStream } @@ -131,7 +130,7 @@ class TestUtils { commandScope.getCommand().toString() + ". " + exception.printStackTrace()) Logger.getLogger(this.class.name).info("If this is expected to be invalid query for this database/version, " + "create an 'expectedSql.sql' file that starts with 'INVALID TEST' and an explanation of why.") - Assert.fail exception.message + Assertions.fail exception.message } return outputStream }