[java-idp-integration-tests] 03/04: Cleanup - set tomcat.version as system property
Tom Zeller
tzeller at dragonacea.biz
Wed Oct 15 23:04:47 UTC 2025
This is an automated email from the git hooks/post-receive script.
tzeller pushed a commit to branch main
in repository java-idp-integration-tests.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=4d34d930448012b892282ca4406cd28dbd07a64b
commit 4d34d930448012b892282ca4406cd28dbd07a64b
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue Oct 14 18:57:35 2025 -0500
Cleanup - set tomcat.version as system property
---
pom.xml | 4 +-
.../shibboleth/idp/integration/tests/BaseTest.java | 103 +++++++++------------
2 files changed, 46 insertions(+), 61 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9441917..840f5fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -361,9 +361,11 @@
<configuration>
<!-- Override parent POM test output - console or file - defaults to false (console). -->
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
- <!-- Pass jetty.version to tests as system property -->
<systemPropertyVariables>
+ <!-- Pass jetty.version to tests as system property -->
<jetty.version>${jetty.version}</jetty.version>
+ <!-- Pass tomcat.version to tests as system property -->
+ <tomcat.version>${tomcat.version}</tomcat.version>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
index 36a1b1a..ca3a42c 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
@@ -549,9 +549,10 @@ public abstract class BaseTest {
/**
* Set up paths to Tomcat if they exist.
*
- * @throws Exception if an error occurs
+ * @throws Exception
+ * if an error occurs
*/
- @BeforeClass(dependsOnMethods = {"setUpIdPPaths"})
+ @BeforeClass(dependsOnMethods = { "setUpIdPPaths" })
public void setUpTomcatPaths() throws Exception {
// Path to the project build directory.
@@ -559,68 +560,50 @@ public abstract class BaseTest {
log.debug("Path to build directory '{}'", buildPath.toAbsolutePath());
Assert.assertTrue(buildPath.toAbsolutePath().toFile().exists(), "Path to build directory not found");
- // Path to Tomcat distribution
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(buildPath, "*apache-tomcat-*")) {
- for (Path entry : stream) {
- pathToTomcatHome = entry;
- break;
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- log.debug("Path to tomcat.home '{}'", pathToTomcatHome);
+ // Get Tomcat version from system property populated by Surefire plugin
+ tomcatVersion = System.getProperty("tomcat.version");
+ log.debug("Testing Tomcat version '{}'", tomcatVersion);
- if (pathToTomcatHome != null) {
- log.debug("Path to tomcat.home '{}'", pathToTomcatHome.toAbsolutePath());
- Assert.assertTrue(pathToTomcatHome.toAbsolutePath().toFile().exists(), "Path to tomcat.home not found");
+ // Path to Tomcat distribution
+ pathToTomcatHome = buildPath.resolve("apache-tomcat-" + tomcatVersion);
+ log.debug("Path to tomcat.home '{}'", pathToTomcatHome.toAbsolutePath());
+ Assert.assertTrue(pathToTomcatHome.toAbsolutePath().toFile().exists(), "Path to tomcat.home not found");
- // Determine Tomcat version from distribution name
- final Pattern pattern = Pattern.compile("apache-tomcat-(.*)");
- final Matcher matcher = pattern.matcher(pathToTomcatHome.getFileName().toString());
- if (matcher.find()) {
- tomcatVersion = matcher.group(1);
- }
- log.debug("Testing Tomcat version '{}'", tomcatVersion);
- if (tomcatVersion == null || tomcatVersion.isBlank()) {
- log.error("Unable to determine version of Tomcat");
- }
+ // Path to tomcat.base
+ pathToTomcatBase = pathToIdPHome.getParent().resolve(Paths.get("tomcat-base"));
+ log.debug("Path to tomcat.base '{}'", pathToTomcatBase.toAbsolutePath());
- // Path to tomcat.base
- pathToTomcatBase = pathToIdPHome.getParent().resolve(Paths.get("tomcat-base"));
- log.debug("Path to tomcat.base '{}'", pathToTomcatBase.toAbsolutePath());
-
- // Copy tomcat-base
- final Path pathToTomcatBaseDist = buildPath.resolve("tomcat-base");
- FileSystemUtils.copyRecursively(pathToTomcatBaseDist, pathToTomcatBase);
- Assert.assertNotNull(pathToTomcatBase, "Path to tomcat.base not found");
- Assert.assertTrue(pathToTomcatBase.toAbsolutePath().toFile().exists(), "Path to tomcat.base not found");
-
- // Make tmp directories exist
- Assert.assertTrue(pathToTomcatBase.resolve("temp").toFile().exists(), "Path to temp/ not found");
-
- // Delete webapps/ROOT directory if it exists
- final Path pathToRootWebapp = pathToTomcatBase.resolve(Paths.get("webapps", "ROOT"));
- log.trace("Path to ROOT webapp '{}'", pathToRootWebapp.toAbsolutePath());
- if (pathToRootWebapp.toAbsolutePath().toFile().exists()) {
- log.debug("Deleting ROOT webapp '{}'", pathToRootWebapp.toAbsolutePath());
- final boolean deleteRootWebapp = FileSystemUtils.deleteRecursively(pathToRootWebapp);
- log.trace("Deleted ROOT webapp '{}' result '{}'", pathToRootWebapp.toAbsolutePath(), deleteRootWebapp);
- }
+ // Copy tomcat-base
+ final Path pathToTomcatBaseDist = buildPath.resolve("tomcat-base");
+ FileSystemUtils.copyRecursively(pathToTomcatBaseDist, pathToTomcatBase);
+ Assert.assertNotNull(pathToTomcatBase, "Path to tomcat.base not found");
+ Assert.assertTrue(pathToTomcatBase.toAbsolutePath().toFile().exists(), "Path to tomcat.base not found");
- // Modify setenv.sh and setenv.bat with per-test idp.home directory
- final Path pathToSetenvSh = pathToTomcatBase.resolve(Paths.get("bin", "setenv.sh"));
- Assert.assertTrue(pathToSetenvSh.toAbsolutePath().toFile().exists(), "Path to setenv.sh not found");
- final Path pathToSetenvBat = pathToTomcatBase.resolve(Paths.get("bin", "setenv.bat"));
- Assert.assertTrue(pathToSetenvBat.toAbsolutePath().toFile().exists(), "Path to setenv.bat not found");
- final String oldTextSetenvSh = "-Didp.home=/opt/shibboleth-idp";
- final String newTextSetenvSh = "-Didp.home="
- + Matcher.quoteReplacement(
- pathToIdPHome.toAbsolutePath().toString()
- .replaceAll("\\(", "\\\\(")
- .replaceAll("\\)", "\\\\)"));
- replaceFile(pathToSetenvSh, oldTextSetenvSh, newTextSetenvSh);
- replaceFile(pathToSetenvBat, oldTextSetenvSh, newTextSetenvSh);
- }
+ // Make tmp directories exist
+ Assert.assertTrue(pathToTomcatBase.resolve("temp").toFile().exists(), "Path to temp/ not found");
+
+ // Delete webapps/ROOT directory if it exists
+ final Path pathToRootWebapp = pathToTomcatBase.resolve(Paths.get("webapps", "ROOT"));
+ log.trace("Path to ROOT webapp '{}'", pathToRootWebapp.toAbsolutePath());
+ if (pathToRootWebapp.toAbsolutePath().toFile().exists()) {
+ log.debug("Deleting ROOT webapp '{}'", pathToRootWebapp.toAbsolutePath());
+ final boolean deleteRootWebapp = FileSystemUtils.deleteRecursively(pathToRootWebapp);
+ log.trace("Deleted ROOT webapp '{}' result '{}'", pathToRootWebapp.toAbsolutePath(), deleteRootWebapp);
+ }
+
+ // Modify setenv.sh and setenv.bat with per-test idp.home directory
+ final Path pathToSetenvSh = pathToTomcatBase.resolve(Paths.get("bin", "setenv.sh"));
+ Assert.assertTrue(pathToSetenvSh.toAbsolutePath().toFile().exists(), "Path to setenv.sh not found");
+ final Path pathToSetenvBat = pathToTomcatBase.resolve(Paths.get("bin", "setenv.bat"));
+ Assert.assertTrue(pathToSetenvBat.toAbsolutePath().toFile().exists(), "Path to setenv.bat not found");
+ final String oldTextSetenvSh = "-Didp.home=/opt/shibboleth-idp";
+ final String newTextSetenvSh = "-Didp.home=" //
+ + Matcher.quoteReplacement( //
+ pathToIdPHome.toAbsolutePath().toString() //
+ .replaceAll("\\(", "\\\\(") //
+ .replaceAll("\\)", "\\\\)"));
+ replaceFile(pathToSetenvSh, oldTextSetenvSh, newTextSetenvSh);
+ replaceFile(pathToSetenvBat, oldTextSetenvSh, newTextSetenvSh);
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list