< prev index next >

test/jdk/java/net/httpclient/AuthFilterCacheTest.java

Print this page

 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.IOException;
 25 import java.net.*;
 26 import java.net.http.HttpClient;
 27 import java.net.http.HttpRequest;
 28 import java.net.http.HttpResponse;
 29 import java.nio.charset.StandardCharsets;
 30 import java.util.ArrayList;
 31 import java.util.List;
 32 import java.util.concurrent.*;
 33 import java.util.concurrent.atomic.AtomicLong;
 34 import jdk.httpclient.test.lib.common.HttpServerAdapters;
 35 
 36 import com.sun.net.httpserver.HttpsConfigurator;
 37 import com.sun.net.httpserver.HttpsServer;

 38 import org.testng.annotations.AfterClass;
 39 import org.testng.annotations.BeforeClass;
 40 import org.testng.annotations.DataProvider;
 41 import org.testng.annotations.Test;
 42 
 43 import javax.net.ssl.SSLContext;
 44 
 45 import static java.net.http.HttpClient.Version.HTTP_1_1;
 46 import static java.net.http.HttpClient.Version.HTTP_2;
 47 
 48 /**
 49  * @test
 50  * @bug 8232853
 51  * @summary AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
 52  * @library /test/lib /test/jdk/java/net/httpclient/lib
 53  * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext
 54  *        DigestEchoServer
 55  * @run testng/othervm -Dtest.requiresHost=true
 56  * -Djdk.tracePinnedThreads=full
 57  * -Djdk.httpclient.HttpClient.log=headers
 58  * -Djdk.internal.httpclient.debug=false
 59  * AuthFilterCacheTest
 60  */
 61 
 62 public class AuthFilterCacheTest implements HttpServerAdapters {
 63 
 64     static final String RESPONSE_BODY = "Hello World!";
 65     static final int REQUEST_COUNT = 5;
 66     static final int URI_COUNT = 6;
 67     static final CyclicBarrier barrier = new CyclicBarrier(REQUEST_COUNT * URI_COUNT);
 68     static final SSLContext context;
 69 
 70     static {
 71         try {
 72             context = new jdk.test.lib.net.SimpleSSLContext().get();
 73             SSLContext.setDefault(context);
 74         } catch (Exception x) {

116         return builder.build();
117     }
118 
119     @BeforeClass
120     public void setUp() throws Exception {
121         try {
122             InetSocketAddress sa =
123                     new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
124             auth = new MyAuthenticator();
125 
126             // HTTP/1.1
127             http1Server = HttpTestServer.create(HTTP_1_1, null, serverExecutor);
128             http1Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/http1/");
129             http1Server.start();
130             http1URI = new URI("http://" + http1Server.serverAuthority()
131                     + "/AuthFilterCacheTest/http1/");
132 
133             // HTTPS/1.1
134             HttpsServer sserver1 = HttpsServer.create(sa, 100);
135             sserver1.setExecutor(serverExecutor);
136             sserver1.setHttpsConfigurator(new HttpsConfigurator(context));
137             https1Server = HttpTestServer.of(sserver1);
138             https1Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/https1/");
139             https1Server.start();
140             https1URI = new URI("https://" + https1Server.serverAuthority()
141                     + "/AuthFilterCacheTest/https1/");
142 
143             // HTTP/2.0
144             http2Server = HttpTestServer.create(HTTP_2);
145             http2Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/http2/");
146             http2Server.start();
147             http2URI = new URI("http://" + http2Server.serverAuthority()
148                     + "/AuthFilterCacheTest/http2/");
149 
150             // HTTPS/2.0
151             https2Server = HttpTestServer.create(HTTP_2, SSLContext.getDefault());
152             https2Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/https2/");
153             https2Server.start();
154             https2URI = new URI("https://" + https2Server.serverAuthority()
155                     + "/AuthFilterCacheTest/https2/");
156 

 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.IOException;
 25 import java.net.*;
 26 import java.net.http.HttpClient;
 27 import java.net.http.HttpRequest;
 28 import java.net.http.HttpResponse;
 29 import java.nio.charset.StandardCharsets;
 30 import java.util.ArrayList;
 31 import java.util.List;
 32 import java.util.concurrent.*;
 33 import java.util.concurrent.atomic.AtomicLong;
 34 import jdk.httpclient.test.lib.common.HttpServerAdapters;
 35 
 36 import com.sun.net.httpserver.HttpsConfigurator;
 37 import com.sun.net.httpserver.HttpsServer;
 38 import jdk.httpclient.test.lib.common.TestServerConfigurator;
 39 import org.testng.annotations.AfterClass;
 40 import org.testng.annotations.BeforeClass;
 41 import org.testng.annotations.DataProvider;
 42 import org.testng.annotations.Test;
 43 
 44 import javax.net.ssl.SSLContext;
 45 
 46 import static java.net.http.HttpClient.Version.HTTP_1_1;
 47 import static java.net.http.HttpClient.Version.HTTP_2;
 48 
 49 /**
 50  * @test
 51  * @bug 8232853
 52  * @summary AuthenticationFilter.Cache::remove may throw ConcurrentModificationException
 53  * @library /test/lib /test/jdk/java/net/httpclient/lib
 54  * @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext
 55  *        DigestEchoServer jdk.httpclient.test.lib.common.TestServerConfigurator
 56  * @run testng/othervm -Dtest.requiresHost=true
 57  * -Djdk.tracePinnedThreads=full
 58  * -Djdk.httpclient.HttpClient.log=headers
 59  * -Djdk.internal.httpclient.debug=false
 60  * AuthFilterCacheTest
 61  */
 62 
 63 public class AuthFilterCacheTest implements HttpServerAdapters {
 64 
 65     static final String RESPONSE_BODY = "Hello World!";
 66     static final int REQUEST_COUNT = 5;
 67     static final int URI_COUNT = 6;
 68     static final CyclicBarrier barrier = new CyclicBarrier(REQUEST_COUNT * URI_COUNT);
 69     static final SSLContext context;
 70 
 71     static {
 72         try {
 73             context = new jdk.test.lib.net.SimpleSSLContext().get();
 74             SSLContext.setDefault(context);
 75         } catch (Exception x) {

117         return builder.build();
118     }
119 
120     @BeforeClass
121     public void setUp() throws Exception {
122         try {
123             InetSocketAddress sa =
124                     new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
125             auth = new MyAuthenticator();
126 
127             // HTTP/1.1
128             http1Server = HttpTestServer.create(HTTP_1_1, null, serverExecutor);
129             http1Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/http1/");
130             http1Server.start();
131             http1URI = new URI("http://" + http1Server.serverAuthority()
132                     + "/AuthFilterCacheTest/http1/");
133 
134             // HTTPS/1.1
135             HttpsServer sserver1 = HttpsServer.create(sa, 100);
136             sserver1.setExecutor(serverExecutor);
137             sserver1.setHttpsConfigurator(new TestServerConfigurator(sa.getAddress(), context));
138             https1Server = HttpTestServer.of(sserver1);
139             https1Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/https1/");
140             https1Server.start();
141             https1URI = new URI("https://" + https1Server.serverAuthority()
142                     + "/AuthFilterCacheTest/https1/");
143 
144             // HTTP/2.0
145             http2Server = HttpTestServer.create(HTTP_2);
146             http2Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/http2/");
147             http2Server.start();
148             http2URI = new URI("http://" + http2Server.serverAuthority()
149                     + "/AuthFilterCacheTest/http2/");
150 
151             // HTTPS/2.0
152             https2Server = HttpTestServer.create(HTTP_2, SSLContext.getDefault());
153             https2Server.addHandler(new TestHandler(), "/AuthFilterCacheTest/https2/");
154             https2Server.start();
155             https2URI = new URI("https://" + https2Server.serverAuthority()
156                     + "/AuthFilterCacheTest/https2/");
157 
< prev index next >