diff --git a/README.adoc b/README.adoc index 1b94bfa6f..4957fdc46 100644 --- a/README.adoc +++ b/README.adoc @@ -148,6 +148,36 @@ If you want to build with the regular `mvn` command, you will need https://maven _Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular please sign the https://cla.pivotal.io/sign/spring[Contributor’s Agreement] before your first non-trivial change._ +=== Running Integration Tests + +[source,bash] +---- + $ ./mvnw clean install +---- + +Runs integration test against a single in memory database. + +To run integration tests against all supported databases specify the Maven Profile `all-dbs`. + +``` +./mvnw clean install -Pall-dbs +``` + +This requires an appropriate `container-license-acceptance.txt` to be on the classpath, signaling that you accept the licence of the databases used. + +If you don't want to accept these licences you may add the Maven Profile `ignore-missing-licence`. +This will ignore the tests that require an explicit license acceptance. + +``` +./mvnw clean install -Pall-dbs,ignore-missing-licence +``` + + +If you want to run an integration tests against a different database you can do so by activating an apropriate Spring Profile. +Available are the following Spring Profiles: + +`db2`, `h2`, `hsql` (default), `mariadb`, `mssql`, `mysql`, `oracle`, `postgres` + === Building reference documentation Building the documentation builds also the project without running tests. diff --git a/pom.xml b/pom.xml index 56cfaabc4..5b0fbcd32 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,6 @@ **/*IntegrationTests.java - **/*HsqlIntegrationTests.java @@ -231,6 +230,22 @@ + + ignore-missing-licence + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ignore-test + + + + + + diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/LicenseListener.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/LicenseListener.java index f60d9c964..f1801e188 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/LicenseListener.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/LicenseListener.java @@ -16,13 +16,11 @@ package org.springframework.data.jdbc.testing; import org.junit.AssumptionViolatedException; - import org.springframework.core.annotation.Order; import org.springframework.core.env.Profiles; import org.springframework.core.env.StandardEnvironment; import org.springframework.test.context.TestContext; import org.springframework.test.context.TestExecutionListener; - import org.testcontainers.containers.Db2Container; import org.testcontainers.containers.MSSQLServerContainer; import org.testcontainers.utility.LicenseAcceptance; @@ -32,14 +30,17 @@ import org.testcontainers.utility.LicenseAcceptance; * accepted. * * @author Mark Paluch + * @author Jens Schauder */ @Order(Integer.MIN_VALUE) public class LicenseListener implements TestExecutionListener { + private StandardEnvironment environment; + @Override public void prepareTestInstance(TestContext testContext) { - StandardEnvironment environment = new StandardEnvironment(); + environment = new StandardEnvironment(); if (environment.acceptsProfiles(Profiles.of("db2"))) { assumeLicenseAccepted(Db2Container.DEFAULT_DB2_IMAGE_NAME + ":" + Db2Container.DEFAULT_TAG); @@ -50,12 +51,20 @@ public class LicenseListener implements TestExecutionListener { } } - private static void assumeLicenseAccepted(String imageName) { + private void assumeLicenseAccepted(String imageName) { try { LicenseAcceptance.assertLicenseAccepted(imageName); } catch (IllegalStateException e) { - throw new AssumptionViolatedException(e.getMessage()); + + if (environment.getProperty("on-missing-licence", "fail").equals("ignore-test")) { + throw new AssumptionViolatedException(e.getMessage()); + } else { + + throw new IllegalStateException( + "You need to accept the licence for the database with which you are testing or set \"ignore-missing-licence\" as active profile in order to skip tests for which a licence is missing.", + e); + } } }