< prev index next >

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

Print this page




  41 import java.net.http.HttpRequest;
  42 import java.net.http.HttpRequest.BodyPublishers;
  43 import java.net.http.HttpResponse;
  44 import java.net.http.HttpResponse.BodyHandlers;
  45 import javax.net.ssl.SSLContext;
  46 import javax.net.ssl.SSLParameters;
  47 import java.util.concurrent.Executors;
  48 import java.util.concurrent.ExecutorService;
  49 import jdk.testlibrary.SimpleSSLContext;
  50 import static java.net.http.HttpClient.Version.HTTP_2;
  51 
  52 import org.testng.annotations.Test;
  53 
  54 /**
  55  * When selecting an unacceptable cipher suite the TLS handshake will fail.
  56  * But, the exception that was thrown was not being returned up to application
  57  * causing hang problems
  58  */
  59 public class ErrorTest {
  60 
  61     static final String[] CIPHER_SUITES = new String[]{ "TLS_KRB5_WITH_3DES_EDE_CBC_SHA" };
  62 
  63     static final String SIMPLE_STRING = "Hello world Goodbye world";
  64 
  65     //@Test(timeOut=5000)
  66     @Test
  67     public void test() throws Exception {
  68         SSLContext sslContext = (new SimpleSSLContext()).get();
  69         ExecutorService exec = Executors.newCachedThreadPool();
  70         HttpClient client = HttpClient.newBuilder()
  71                                       .executor(exec)
  72                                       .sslContext(sslContext)
  73                                       .sslParameters(new SSLParameters(CIPHER_SUITES))
  74                                       .version(HTTP_2)
  75                                       .build();
  76 
  77         Http2TestServer httpsServer = null;
  78         try {
  79             SSLContext serverContext = (new SimpleSSLContext()).get();
  80             SSLParameters p = serverContext.getSupportedSSLParameters();
  81             p.setApplicationProtocols(new String[]{"h2"});




  41 import java.net.http.HttpRequest;
  42 import java.net.http.HttpRequest.BodyPublishers;
  43 import java.net.http.HttpResponse;
  44 import java.net.http.HttpResponse.BodyHandlers;
  45 import javax.net.ssl.SSLContext;
  46 import javax.net.ssl.SSLParameters;
  47 import java.util.concurrent.Executors;
  48 import java.util.concurrent.ExecutorService;
  49 import jdk.testlibrary.SimpleSSLContext;
  50 import static java.net.http.HttpClient.Version.HTTP_2;
  51 
  52 import org.testng.annotations.Test;
  53 
  54 /**
  55  * When selecting an unacceptable cipher suite the TLS handshake will fail.
  56  * But, the exception that was thrown was not being returned up to application
  57  * causing hang problems
  58  */
  59 public class ErrorTest {
  60 
  61     static final String[] CIPHER_SUITES = new String[]{ "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" };
  62 
  63     static final String SIMPLE_STRING = "Hello world Goodbye world";
  64 
  65     //@Test(timeOut=5000)
  66     @Test
  67     public void test() throws Exception {
  68         SSLContext sslContext = (new SimpleSSLContext()).get();
  69         ExecutorService exec = Executors.newCachedThreadPool();
  70         HttpClient client = HttpClient.newBuilder()
  71                                       .executor(exec)
  72                                       .sslContext(sslContext)
  73                                       .sslParameters(new SSLParameters(CIPHER_SUITES))
  74                                       .version(HTTP_2)
  75                                       .build();
  76 
  77         Http2TestServer httpsServer = null;
  78         try {
  79             SSLContext serverContext = (new SimpleSSLContext()).get();
  80             SSLParameters p = serverContext.getSupportedSSLParameters();
  81             p.setApplicationProtocols(new String[]{"h2"});


< prev index next >