diff --git a/gsrs-module-clinical-trials-spring-boot-autoconfigure/pom.xml b/gsrs-module-clinical-trials-spring-boot-autoconfigure/pom.xml index e43d303..c5f98b9 100644 --- a/gsrs-module-clinical-trials-spring-boot-autoconfigure/pom.xml +++ b/gsrs-module-clinical-trials-spring-boot-autoconfigure/pom.xml @@ -91,11 +91,6 @@ lombok true - - gov.nih.ncats - gsrs-spring-boot-starter - ${gsrs.version} - gov.nih.ncats gsrs-spring-starter-tests diff --git a/gsrs-module-clinical-trials-spring-boot-starter-tests/src/test/java/gsrs/clinicaltrials/tests/ClinicalTrialsPomsVersionTest.java b/gsrs-module-clinical-trials-spring-boot-starter-tests/src/test/java/gsrs/clinicaltrials/tests/ClinicalTrialsPomsVersionTest.java new file mode 100644 index 0000000..d2487b1 --- /dev/null +++ b/gsrs-module-clinical-trials-spring-boot-starter-tests/src/test/java/gsrs/clinicaltrials/tests/ClinicalTrialsPomsVersionTest.java @@ -0,0 +1,102 @@ +package gsrs.clinicaltrials.tests; + + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Properties; +import gsrs.startertests.pomutilities.PomUtilities; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Model; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + + +public class ClinicalTrialsPomsVersionTest { + // Check GSRS versions in all pom.xml, and select extraJars, installExtraJars.sh commands + // against the values in pom-version.properties. Helpful when making a version change + // for the whole GSRS project. + // Test effectively skipped unless CLI param -DdoPomCheck=true + // Run from command line: + // mvn test -Dtest=gsrs.clinicaltrials.tests.ClinicalTrialsPomsVersionTest -DdoPomCheck=true -pl gsrs-module-clinical-trials-spring-boot-starter-tests + + // Set to true when testing in IDE + boolean turnOffPomParameterCheck = false; + String clinicalTrialsModuleVersion; + String starterModuleVersion; + String substancesModuleVersion; + String otherModuleVersion; + String rootDir; + String propertiesFile; + String installExtraJarsScriptText; + boolean doPomCheck = false; + + @BeforeEach + public void setup() { + doPomCheck=Boolean.parseBoolean(System.getProperty("doPomCheck")); + if(!doPomCheck && !turnOffPomParameterCheck) { return; } + String scriptFile = "installExtraJars.sh"; + propertiesFile = "pom-version.properties"; + rootDir = ".."; + + try { + Properties properties = PomUtilities.readPomVersionProperties(rootDir + "/" + propertiesFile); + + + starterModuleVersion = properties.getProperty("ct.pomversiontest.starterModuleVersion"); + substancesModuleVersion = properties.getProperty("ct.pomversiontest.substancesModuleVersion"); + clinicalTrialsModuleVersion = properties.getProperty("ct.pomversiontest.clinicalTrialsModuleVersion"); + + assertNotNull(starterModuleVersion); + assertNotNull(substancesModuleVersion); + System.out.println("starterModuleVersion: " + starterModuleVersion); + System.out.println("substancesModuleVersion: " + substancesModuleVersion); + } catch (IOException e) { + throw new RuntimeException(e); + } +// try { +// installExtraJarsScriptText = PomUtilities.readTextFile(rootDir + "/" + scriptFile, StandardCharsets.UTF_8); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } + } + + @Test + public void testPomCheck() { + if(!doPomCheck && !turnOffPomParameterCheck) { + System.out.println("Effectively skipping testPomCheck because -DdoPomCheck is not true."); + return; + } + Model rootModel; + try { + rootModel = PomUtilities.readPomToModel(rootDir + "/pom.xml"); + Properties properties = rootModel.getProperties(); + System.out.println("> checking root"); + assertEquals( clinicalTrialsModuleVersion, rootModel.getVersion(), "version"); + assertEquals(starterModuleVersion, properties.getProperty("gsrs.version"), "gsrs.version:"); + assertEquals( substancesModuleVersion, properties.getProperty("gsrs.substance.version")); + List modules = rootModel.getModules(); + for (String module : modules) { + System.out.println("> checking "+ module); + Model moduleModel; + try { + moduleModel = PomUtilities.readPomToModel(rootDir + "/" + module + "/pom.xml"); + String checkVersion = moduleModel.getParent().getVersion(); + assertEquals (clinicalTrialsModuleVersion, checkVersion, "parent/version"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public void checkDependencyExtraJarExistsAndFindPathInScript(Dependency dependency) { + String jarPath = "extraJars/" + PomUtilities.makeJarFilename(dependency); + File file = new File(rootDir + "/" + jarPath); + assertTrue(file.exists()); + assertTrue(installExtraJarsScriptText.contains(jarPath)); + } +} diff --git a/pom-version.properties b/pom-version.properties new file mode 100644 index 0000000..4996008 --- /dev/null +++ b/pom-version.properties @@ -0,0 +1,3 @@ +ct.pomversiontest.starterModuleVersion=3.1.1 +ct.pomversiontest.substancesModuleVersion=3.1.1.1 +ct.pomversiontest.clinicalTrialsModuleVersion=3.1.1-SNAPSHOT diff --git a/pom.xml b/pom.xml index a9febd9..4152def 100644 --- a/pom.xml +++ b/pom.xml @@ -33,8 +33,8 @@ 1.8 Hoxton.SR1 - 3.1 - 3.1.1 + 3.1.1 + 3.1.1.1 3.1.1-SNAPSHOT 2.17.1