8305169: java/security/cert/CertPathValidator/OCSP/GetAndPostTests.java -- test server didn't start in timely manner
Reviewed-by: ssahoo, jnimeh
This commit is contained in:
parent
f143bf7c45
commit
3f6a3545a2
test/jdk/java/security
@ -62,16 +62,14 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import sun.security.testlibrary.SimpleOCSPServer;
|
||||
import sun.security.testlibrary.SimpleOCSPServer;
|
||||
import sun.security.testlibrary.SimpleOCSPServer;
|
||||
import sun.security.util.DerOutputStream;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.util.ObjectIdentifier;
|
||||
import sun.security.testlibrary.SimpleOCSPServer;
|
||||
|
||||
public class GetAndPostTests {
|
||||
private static final String PASS = "passphrase";
|
||||
private static final int SERVER_WAIT_SECS = 60;
|
||||
private static CertificateFactory certFac;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
@ -114,13 +112,8 @@ public class GetAndPostTests {
|
||||
endEntCert.getSerialNumber(),
|
||||
new SimpleOCSPServer.CertStatusInfo(
|
||||
SimpleOCSPServer.CertStatus.CERT_STATUS_GOOD)));
|
||||
ocspResponder.start();
|
||||
// Wait 5 seconds for server ready
|
||||
boolean readyStatus =
|
||||
ocspResponder.awaitServerReady(5, TimeUnit.SECONDS);
|
||||
if (!readyStatus) {
|
||||
throw new RuntimeException("Server not ready");
|
||||
}
|
||||
|
||||
startOcspServer(ocspResponder);
|
||||
|
||||
int ocspPort = ocspResponder.getPort();
|
||||
URI ocspURI = new URI("http://localhost:" + ocspPort);
|
||||
@ -169,6 +162,14 @@ public class GetAndPostTests {
|
||||
}
|
||||
}
|
||||
|
||||
private static void startOcspServer(SimpleOCSPServer ocspResponder) throws InterruptedException, IOException {
|
||||
ocspResponder.start();
|
||||
if (!ocspResponder.awaitServerReady(SERVER_WAIT_SECS, TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException("Server not ready after " + SERVER_WAIT_SECS
|
||||
+ " seconds.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an X509Certificate object from its PEM encoding
|
||||
*
|
||||
|
@ -288,10 +288,18 @@ public class SimpleOCSPServer {
|
||||
public synchronized void stop() {
|
||||
if (started) {
|
||||
receivedShutdown = true;
|
||||
started = false;
|
||||
log("Received shutdown notification");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void shutdownNow() {
|
||||
stop();
|
||||
if (threadPool != null) {
|
||||
threadPool.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print {@code SimpleOCSPServer} operating parameters.
|
||||
*
|
||||
@ -577,7 +585,7 @@ public class SimpleOCSPServer {
|
||||
* @param message the message to log
|
||||
*/
|
||||
private static synchronized void err(String message) {
|
||||
System.out.println("[" + Thread.currentThread().getName() + "]: " +
|
||||
System.err.println("[" + Thread.currentThread().getName() + "]: " +
|
||||
message);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user