[java-idp-integration-tests] 03/03: Add timeout when waiting for Jetty server to stop
Tom Zeller
tzeller at dragonacea.biz
Fri Aug 21 00:08:29 UTC 2020
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=7e6833a0aa22f2c1bdc01f13115a9f8b760827da
commit 7e6833a0aa22f2c1bdc01f13115a9f8b760827da
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed Aug 19 17:44:19 2020 -0500
Add timeout when waiting for Jetty server to stop
---
.../java/net/shibboleth/idp/test/JettyServerProcess.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/test/java/net/shibboleth/idp/test/JettyServerProcess.java b/src/test/java/net/shibboleth/idp/test/JettyServerProcess.java
index 4878d7c..578e2fb 100644
--- a/src/test/java/net/shibboleth/idp/test/JettyServerProcess.java
+++ b/src/test/java/net/shibboleth/idp/test/JettyServerProcess.java
@@ -17,6 +17,8 @@
package net.shibboleth.idp.test;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.InetAddress;
@@ -112,11 +114,23 @@ public class JettyServerProcess extends AbstractServerProcess {
log.debug("Attempting to shutdown Jetty at '{}:{}'", hostname, port);
+ final int timeout = 5;
+
try {
try (final Socket s = new Socket(InetAddress.getByName(hostname), port)) {
+ s.setSoTimeout(timeout * 1000);
try (OutputStream out = s.getOutputStream()) {
out.write((password + "\r\nstop\r\n").getBytes());
out.flush();
+ log.debug("Waiting {} seconds for jetty to stop", timeout);
+ final LineNumberReader lin = new LineNumberReader(new InputStreamReader(s.getInputStream()));
+ String response;
+ while ((response = lin.readLine()) != null) {
+ log.debug("Received '{}'", response);
+ if ("Stopped".equals(response)) {
+ log.debug("Server reports itself as Stopped");
+ }
+ }
}
}
} catch (SocketTimeoutException e) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list