[java-idp-integration-tests] 04/08: Support running Tomcat on Windows
Tom Zeller
tzeller at dragonacea.biz
Tue Aug 2 13:28:50 EDT 2016
This is an automated email from the git hooks/post-receive script.
tzeller pushed a commit to branch master
in repository java-idp-integration-tests.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=4167e9d08becfa0d91fd5a4a5c4875a841e691c5
commit 4167e9d08becfa0d91fd5a4a5c4875a841e691c5
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue Jul 19 15:50:51 2016 -0500
Support running Tomcat on Windows
---
.../shibboleth/idp/test/BaseIntegrationTest.java | 5 ++++-
.../shibboleth/idp/test/TomcatServerProcess.java | 23 +++++++++++++++-------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
index 6919693..2540d88 100644
--- a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
@@ -411,12 +411,15 @@ public abstract class BaseIntegrationTest
// Make tmp directories exist
Assert.assertTrue(pathToTomcatBase.resolve("temp").toFile().exists(), "Path to temp/ not found");
- // Modify setenv.sh with per-test idp.home directory
+ // 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=" + pathToIdPHome.toAbsolutePath().toString();
replaceFile(pathToSetenvSh, oldTextSetenvSh, newTextSetenvSh);
+ replaceFile(pathToSetenvBat, oldTextSetenvSh, newTextSetenvSh);
// Modify context descriptor with per-test idp.home directory
final Path pathToIdpXML = pathToTomcatBase.resolve(Paths.get("conf", "Catalina", "localhost", "idp.xml"));
diff --git a/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java b/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java
index c80d394..e58d8bc 100644
--- a/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java
+++ b/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java
@@ -42,10 +42,16 @@ public class TomcatServerProcess extends AbstractServerProcess {
@Override
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
-
- final Path pathToSetenvSh = getServletContainerBasePath().resolve(Paths.get("bin", "setenv.sh"));
- Assert.assertTrue(pathToSetenvSh.toAbsolutePath().toFile().exists(), "Path to setenv.sh not found");
+ // Windows or not ?
+ final String suffix = System.getProperty("os.name").toLowerCase().startsWith("windows") ? "bat" : "sh";
+
+ // Name of setenv script, either ending in .sh or .bat.
+ final String setenv = "setenv." + suffix;
+
+ // Append system properties to bin/setenv.sh
+ final Path pathToSetenvSh = getServletContainerBasePath().resolve(Paths.get("bin", setenv));
+ Assert.assertTrue(pathToSetenvSh.toAbsolutePath().toFile().exists(), "Path to " + setenv + " not found");
for (final String serverCommand : getAdditionalCommands()) {
if (serverCommand.startsWith("-D")) {
try {
@@ -60,10 +66,15 @@ public class TomcatServerProcess extends AbstractServerProcess {
// Add CATALINA_BASE to environment
getProcessBuilder().environment().put("CATALINA_BASE", getServletContainerBasePath().toAbsolutePath().toString());
+ // Name of catalina script, either ending in .sh or .bat.
+ final String catalina = "catalina." + suffix;
+ final Path pathToCatalina = getServletContainerHomePath().resolve(Paths.get("bin", catalina));
+ Assert.assertTrue(pathToCatalina.toAbsolutePath().toFile().exists(), "Path to " + catalina + " not found");
+
// Start Tomcat in current window
- getCommands().add(getServletContainerHomePath().toAbsolutePath().toString() + "/bin/catalina.sh");
+ getCommands().add(pathToCatalina.toAbsolutePath().toString());
getCommands().add("run");
-
+
// Randomize Tomcat's shutdown port
final SortedSet<Integer> ports = SocketUtils.findAvailableTcpPorts(4, 20000, 30000);
final Iterator<Integer> iterator = ports.iterator();
@@ -76,8 +87,6 @@ public class TomcatServerProcess extends AbstractServerProcess {
log.error("Unable to replace file", e);
throw new ComponentInitializationException(e);
}
-
- // TODO Windows file separator and .bat
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list