[java-idp-integration-tests] 02/04: Cleanup - set jetty.version as system property
Tom Zeller
tzeller at dragonacea.biz
Wed Oct 15 23:04:46 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=414733df9630c880c629b3279abc999abab1149f
commit 414733df9630c880c629b3279abc999abab1149f
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue Oct 14 18:53:26 2025 -0500
Cleanup - set jetty.version as system property
---
pom.xml | 6 +-
.../shibboleth/idp/integration/tests/BaseTest.java | 87 +++++++++-------------
2 files changed, 39 insertions(+), 54 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3b405c8..9441917 100644
--- a/pom.xml
+++ b/pom.xml
@@ -355,12 +355,16 @@
<force>true</force>
</configuration>
</plugin>
- <!-- Override parent POM test output - console or file. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<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>
+ <jetty.version>${jetty.version}</jetty.version>
+ </systemPropertyVariables>
</configuration>
</plugin>
</plugins>
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 5f40df6..36a1b1a 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
@@ -626,9 +626,10 @@ public abstract class BaseTest {
/**
* Set up paths to Jetty if they exist and if 'tomcat' system property is not true.
*
- * @throws Exception if an error occurs
+ * @throws Exception
+ * if an error occurs
*/
- @BeforeClass(dependsOnMethods = {"setUpIdPPaths"})
+ @BeforeClass(dependsOnMethods = { "setUpIdPPaths" })
public void setUpJettyPaths() throws Exception {
if (Boolean.getBoolean("tomcat")) {
@@ -641,65 +642,45 @@ 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 Jetty distribution
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(buildPath, "*jetty-home-*")) {
- for (Path entry : stream) {
- pathToJettyHome = entry;
- break;
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- log.debug("Path to jetty.home '{}'", pathToJettyHome);
+ // Get Jetty version from system property populated by Surefire plugin
+ jettyVersion = System.getProperty("jetty.version");
+ log.debug("Testing Jetty version '{}'", jettyVersion);
- if (pathToJettyHome != null) {
- log.debug("Path to jetty.home '{}'", pathToJettyHome.toAbsolutePath());
- Assert.assertTrue(pathToJettyHome.toAbsolutePath().toFile().exists(), "Path to jetty.home not found");
+ // Path to Jetty home
+ pathToJettyHome = buildPath.resolve("jetty-home-" + jettyVersion);
+ log.debug("Path to jetty.home '{}'", pathToJettyHome.toAbsolutePath());
+ Assert.assertTrue(pathToJettyHome.toAbsolutePath().toFile().exists(), "Path to jetty.home not found");
- // Determine Jetty version from distribution name
- final Pattern pattern = Pattern.compile("jetty-home-(.*)");
- final Matcher matcher = pattern.matcher(pathToJettyHome.getFileName().toString());
- if (matcher.find()) {
- jettyVersion = matcher.group(1);
- }
- log.debug("Testing Jetty version '{}'", jettyVersion);
- if (jettyVersion == null || jettyVersion.isBlank()) {
- log.error("Unable to determine version of Jetty");
- }
+ // Path to jetty.base
+ pathToJettyBase = pathToIdPHome.getParent().resolve(Paths.get("jetty-base"));
+ log.debug("Path to jetty.base '{}'", pathToJettyBase.toAbsolutePath());
- // Path to jetty.base
- pathToJettyBase = pathToIdPHome.getParent().resolve(Paths.get("jetty-base"));
- log.debug("Path to jetty.base '{}'", pathToJettyBase.toAbsolutePath());
+ // Copy jetty-base
+ final Path pathToJettyBaseDist = buildPath.resolve("jetty-base");
+ FileSystemUtils.copyRecursively(pathToJettyBaseDist, pathToJettyBase);
+ Assert.assertNotNull(pathToJettyBase, "Path to jetty.base not found");
+ Assert.assertTrue(pathToJettyBase.toAbsolutePath().toFile().exists(), "Path to jetty.base not found");
- // Copy jetty-base
- final Path pathToJettyBaseDist = buildPath.resolve("jetty-base");
- FileSystemUtils.copyRecursively(pathToJettyBaseDist, pathToJettyBase);
- Assert.assertNotNull(pathToJettyBase, "Path to jetty.base not found");
- Assert.assertTrue(pathToJettyBase.toAbsolutePath().toFile().exists(), "Path to jetty.base not found");
+ // Make tmp directories exist
+ Assert.assertTrue(pathToJettyBase.resolve("tmp").toFile().exists(), "Path to jetty.base/tmp/ not found");
- // Make tmp directories exist
- Assert.assertTrue(pathToJettyBase.resolve("tmp").toFile().exists(), "Path to jetty.base/tmp/ not found");
-
- // set idp.home system property
- serverCommands.add(0, "-Didp.home=" + System.getProperty("idp.home"));
+ // set idp.home system property
+ serverCommands.add(0, "-Didp.home=" + System.getProperty("idp.home"));
- // set tmp directory system property
- serverCommands.add("-Djava.io.tmpdir=" + pathToJettyBase.resolve("tmp").toAbsolutePath());
-
- // Adjust package name for Jetty 12
- if (jettyVersion.startsWith("12")) {
- final Path pathToTestbedXML = pathToJettyBase.resolve(Paths.get("webapps", "testbed.xml"));
- replaceFile(pathToTestbedXML, "org.eclipse.jetty.webapp.WebAppContext",
- "org.eclipse.jetty.ee9.webapp.WebAppContext");
- }
+ // set tmp directory system property
+ serverCommands.add("-Djava.io.tmpdir=" + pathToJettyBase.resolve("tmp").toAbsolutePath());
- // Adjust path to credentials
- final Path idpIni = pathToJettyBase.resolve(Paths.get("start.d", "idp.ini"));
- Assert.assertTrue(idpIni.toFile().exists());
- replaceFile(idpIni, "../credentials", "credentials");
- } else {
- Assert.fail("Unable to find jetty.home");
+ // Adjust package name for Jetty 12
+ if (jettyVersion.startsWith("12")) {
+ final Path pathToTestbedXML = pathToJettyBase.resolve(Paths.get("webapps", "testbed.xml"));
+ replaceFile(pathToTestbedXML, "org.eclipse.jetty.webapp.WebAppContext",
+ "org.eclipse.jetty.ee9.webapp.WebAppContext");
}
+
+ // Adjust path to credentials
+ final Path idpIni = pathToJettyBase.resolve(Paths.get("start.d", "idp.ini"));
+ Assert.assertTrue(idpIni.toFile().exists());
+ replaceFile(idpIni, "../credentials", "credentials");
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list