< prev index next >

test/jdk/java/net/httpclient/http2/Timeout.java

Print this page


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.File;
  25 import java.io.IOException;
  26 import java.net.URI;
  27 import jdk.incubator.http.HttpClient;
  28 import jdk.incubator.http.HttpRequest;
  29 import jdk.incubator.http.HttpResponse;
  30 import jdk.incubator.http.HttpTimeoutException;
  31 import java.time.Duration;
  32 import java.util.concurrent.TimeUnit;
  33 import java.util.concurrent.CompletionException;
  34 import javax.net.ssl.SSLServerSocket;
  35 import javax.net.ssl.SSLParameters;
  36 import javax.net.ssl.SSLServerSocketFactory;
  37 import javax.net.ssl.SSLSocket;
  38 import static jdk.incubator.http.HttpRequest.BodyProcessor.fromString;
  39 import static jdk.incubator.http.HttpResponse.BodyHandler.asString;
  40 
  41 /*
  42  * @test
  43  * @bug 8156710
  44  * @summary Check if HttpTimeoutException is thrown if a server doesn't reply
  45  * @run main/othervm Timeout
  46  */
  47 public class Timeout {
  48 
  49     private static final int RANDOM_PORT = 0;
  50     private static final int TIMEOUT = 3 * 1000; // in millis
  51     private static final String KEYSTORE = System.getProperty("test.src")
  52             + File.separator + "keystore.p12";
  53     private static final String PASSWORD = "password";
  54 
  55     // indicates if server is ready to accept connections
  56     private static volatile boolean ready = false;
  57 
  58     public static void main(String[] args) throws Exception {


   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.File;
  25 import java.io.IOException;
  26 import java.net.URI;
  27 import jdk.incubator.http.HttpClient;
  28 import jdk.incubator.http.HttpRequest;
  29 import jdk.incubator.http.HttpResponse;
  30 import jdk.incubator.http.HttpTimeoutException;
  31 import java.time.Duration;

  32 import java.util.concurrent.CompletionException;
  33 import javax.net.ssl.SSLServerSocket;
  34 import javax.net.ssl.SSLParameters;
  35 import javax.net.ssl.SSLServerSocketFactory;
  36 import javax.net.ssl.SSLSocket;
  37 import static jdk.incubator.http.HttpRequest.BodyPublisher.fromString;
  38 import static jdk.incubator.http.HttpResponse.BodyHandler.asString;
  39 
  40 /*
  41  * @test
  42  * @bug 8156710
  43  * @summary Check if HttpTimeoutException is thrown if a server doesn't reply
  44  * @run main/othervm Timeout
  45  */
  46 public class Timeout {
  47 
  48     private static final int RANDOM_PORT = 0;
  49     private static final int TIMEOUT = 3 * 1000; // in millis
  50     private static final String KEYSTORE = System.getProperty("test.src")
  51             + File.separator + "keystore.p12";
  52     private static final String PASSWORD = "password";
  53 
  54     // indicates if server is ready to accept connections
  55     private static volatile boolean ready = false;
  56 
  57     public static void main(String[] args) throws Exception {


< prev index next >