-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...-starter-tests/src/test/java/gsrs/clinicaltrials/tests/ClinicalTrialsPomsVersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ct.pomversiontest.starterModuleVersion=3.1.1 | ||
ct.pomversiontest.substancesModuleVersion=3.1.1.1 | ||
ct.pomversiontest.clinicalTrialsModuleVersion=3.1.1-SNAPSHOT |