Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: aa8ce8cc by Tony Chemit at 2024-06-25T17:40:30+02:00 Fix persistence tests (by skipping them), when some files are missing to execute them - - - - - 5 changed files: - core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/data/AvdthDataBuilderTestSupport.java - core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/referential/AvdthReferentialBuilderTest.java - core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/referential/AvdthWeightCategoryBuilderTest.java - core/persistence/test/src/test/java/org/nuiton/topia/persistence/jdbc/JdbcHelperPostgresTest.java - toolkit/test-api/src/main/java/fr/ird/observe/test/ObserveTestConfiguration.java Changes: ===================================== core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/data/AvdthDataBuilderTestSupport.java ===================================== @@ -98,6 +98,7 @@ public abstract class AvdthDataBuilderTestSupport extends PersistenceTestSupport } public static List<String> allDatabases(Path path) { + Assume.assumeTrue("Skip, avdth root path " + path + " not found", Files.exists(path)); try (Stream<Path> pathStream = Files.find(path, 1, (p, b) -> p.toFile().getName().endsWith(".mdb"))) { List<String> collect = pathStream.map(p -> p.toFile().getName()).sorted().collect(Collectors.toList()); Collections.reverse(collect); @@ -127,6 +128,7 @@ public abstract class AvdthDataBuilderTestSupport extends PersistenceTestSupport public void build() throws SQLException, IOException, MissingReferentialException { log.info(String.format("Start for database: %s", dbName)); Path avdthFile = getRootPath().resolve(dbName); + Assume.assumeTrue("Skip, avdth file " + avdthFile + " not found", Files.exists(avdthFile)); Path scriptPath = TOPIA_TEST_CLASS_RESOURCE.getTestDirectory().toPath().resolve("export-" + dbName.replace(".mdb", ".sql")); Path scriptTemporaryDirectory = scriptPath.getParent().resolve(scriptPath.toFile().getName().replace(".sql", "-tmp")); ===================================== core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/referential/AvdthReferentialBuilderTest.java ===================================== @@ -39,10 +39,12 @@ import fr.ird.observe.test.spi.DatabaseNameConfiguration; import fr.ird.observe.test.spi.DatabasePasswordConfiguration; import fr.ird.observe.test.spi.DatabaseVersionConfiguration; import org.junit.Assert; +import org.junit.Assume; import org.junit.ClassRule; import org.junit.Test; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; import java.sql.SQLException; @@ -74,6 +76,7 @@ public class AvdthReferentialBuilderTest extends TestSupportWithConfig { Path avdthFile = AvdthFixtures.getAvdthCachePath() .resolve("OA") .resolve("OA_2020_V35.mdb"); + Assume.assumeTrue("Skip, avdth file " + avdthFile + " not found", Files.exists(avdthFile)); Path scriptPath = localTestMethodResource.getTestDirectory().toPath().resolve("export-" + avdthFile.toFile().getName().replace(".mdb", ".sql")); Path scriptTemporaryDirectory = scriptPath.getParent().resolve(scriptPath.toFile().getName().replace(".sql", "-tmp")); ===================================== core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/referential/AvdthWeightCategoryBuilderTest.java ===================================== @@ -38,10 +38,12 @@ import fr.ird.observe.test.spi.DatabaseNameConfiguration; import fr.ird.observe.test.spi.DatabasePasswordConfiguration; import fr.ird.observe.test.spi.DatabaseVersionConfiguration; import org.junit.Assert; +import org.junit.Assume; import org.junit.ClassRule; import org.junit.Test; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; import java.sql.SQLException; @@ -70,6 +72,7 @@ public class AvdthWeightCategoryBuilderTest extends TestSupportWithConfig { public void build() throws SQLException, IOException { Path avdthFile = AvdthFixtures.getAvdthCachePath() .resolve("avdth-gen-35_74.mdb"); + Assume.assumeTrue("Skip, avdth file " + avdthFile + " not found", Files.exists(avdthFile)); Path scriptPath = localTestMethodResource.getTestDirectory().toPath().resolve("export-" + avdthFile.toFile().getName().replace(".mdb", ".sql")); Path scriptTemporaryDirectory = scriptPath.getParent().resolve(scriptPath.toFile().getName().replace(".sql", "-tmp")); ===================================== core/persistence/test/src/test/java/org/nuiton/topia/persistence/jdbc/JdbcHelperPostgresTest.java ===================================== @@ -61,10 +61,10 @@ public class JdbcHelperPostgresTest { @Test public void isTableExist() throws SQLException { - boolean actual = jdbcHelper.isTableExist("Public", "Tms_version"); + boolean actual = jdbcHelper.isTableExist("Common", "database_version"); Assert.assertTrue(actual); - actual = jdbcHelper.isTableExist("PUBLIC", "tms_version-fake"); + actual = jdbcHelper.isTableExist("PUBLIC", "database_version-fake"); Assert.assertFalse(actual); } @Test ===================================== toolkit/test-api/src/main/java/fr/ird/observe/test/ObserveTestConfiguration.java ===================================== @@ -33,10 +33,12 @@ import fr.ird.observe.test.spi.DatabaseVersionConfiguration; import io.ultreia.java4all.util.Version; import io.ultreia.java4all.util.sql.conf.JdbcConfiguration; import io.ultreia.java4all.util.sql.conf.JdbcConfigurationBuilder; +import org.junit.Assume; import java.lang.reflect.AnnotatedElement; import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Files; import java.nio.file.Path; /** @@ -145,9 +147,9 @@ public class ObserveTestConfiguration { } public static JdbcConfiguration pgConfiguration() { - return new JdbcConfigurationBuilder().forDatabase(ObserveTestConfiguration.getTestPropertyAsString(ObserveTestConfiguration.PG_URL),//"jdbc:postgresql://localhost:5432/observe_9", - ObserveTestConfiguration.getTestPropertyAsString(ObserveTestConfiguration.PG_LOGIN),//"obstuna-referentiel", - ObserveTestConfiguration.getTestPropertyAsString(ObserveTestConfiguration.PG_PASSWORD)//";;dm8-referentiel.." + return new JdbcConfigurationBuilder().forDatabase(ObserveTestConfiguration.getTestPropertyAsString(ObserveTestConfiguration.PG_URL), + ObserveTestConfiguration.getTestPropertyAsString(ObserveTestConfiguration.PG_LOGIN), + ObserveTestConfiguration.getTestPropertyAsString(ObserveTestConfiguration.PG_PASSWORD) ); } @@ -155,6 +157,7 @@ public class ObserveTestConfiguration { public static void injectCredentials() { Path credentialPath = Path.of(ObserveTestConfiguration.getTestPropertyAsString(ToolkitFixtures.TEST_CREDENTIALS_KEY)); + Assume.assumeTrue("Skip, no credential file found", Files.exists(credentialPath)); ToolkitFixtures.injectCredentials(credentialPath, ObserveTestConfiguration.PG_URL, ObserveTestConfiguration.PG_LOGIN, View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/aa8ce8cce35d5bf8b9614d9a33... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/aa8ce8cce35d5bf8b9614d9a33... You're receiving this email because of your account on gitlab.com.