[java-idp-integration-tests] 02/08: Randomize Tomcat's startup port.
Tom Zeller
tzeller at dragonacea.biz
Tue Aug 2 13:28:48 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=910ca8d6eb170f71df97f5c07823c6afa42f02b2
commit 910ca8d6eb170f71df97f5c07823c6afa42f02b2
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue Jul 26 12:03:50 2016 -0500
Randomize Tomcat's startup port.
---
.../net/shibboleth/idp/test/BaseIntegrationTest.java | 5 +++--
.../net/shibboleth/idp/test/TomcatServerProcess.java | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
index 802756f..cce45db 100644
--- a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
@@ -867,10 +867,11 @@ public abstract class BaseIntegrationTest
* @param replacement string to be substituted for each match
* @throws IOException if the file cannot be overwritten
*/
- public void replaceFile(@Nonnull final Path pathToFile,
+ public static void replaceFile(@Nonnull final Path pathToFile,
@Nonnull @NotEmpty final String regex,
@Nonnull @NotEmpty final String replacement) throws IOException {
- log.debug("Replacing regex '{}' with '{}' in file '{}'", regex, replacement, pathToFile);
+ LoggerFactory.getLogger(BaseIntegrationTest.class).debug("Replacing regex '{}' with '{}' in file '{}'", regex,
+ replacement, pathToFile);
Assert.assertNotNull(pathToFile, "Path not found");
Assert.assertTrue(pathToFile.toAbsolutePath().toFile().exists(), "Path does not exist");
diff --git a/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java b/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java
index 57d03cb..da9ccdc 100644
--- a/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java
+++ b/src/test/java/net/shibboleth/idp/test/TomcatServerProcess.java
@@ -17,10 +17,17 @@
package net.shibboleth.idp.test;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Iterator;
+import java.util.SortedSet;
+
import javax.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.util.SocketUtils;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -42,6 +49,19 @@ public class TomcatServerProcess extends AbstractServerProcess {
getCommands().add(getServletContainerHomePath().toAbsolutePath().toString() + "/bin/catalina.sh");
getCommands().add("run");
+ // Randomize Tomcat's shutdown port
+ final SortedSet<Integer> ports = SocketUtils.findAvailableTcpPorts(4, 20000, 30000);
+ final Iterator<Integer> iterator = ports.iterator();
+ int shutdownPort = iterator.next();
+ log.info("Selecting shutdown port '{}' for Tomcat", shutdownPort);
+ final Path pathToCatalinaProperties = getServletContainerBasePath().resolve(Paths.get("conf", "catalina.properties"));
+ try {
+ BaseIntegrationTest.replaceFile(pathToCatalinaProperties, "tomcat.shutdown.port=.*", "tomcat.shutdown.port=" + Integer.toString(shutdownPort));
+ } catch (IOException e) {
+ 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