|
1 | 1 | /* |
2 | | - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
25 | 25 | import com.sun.net.httpserver.HttpExchange; |
26 | 26 | import com.sun.net.httpserver.HttpHandler; |
27 | 27 | import com.sun.net.httpserver.HttpServer; |
| 28 | +import jdk.httpclient.test.lib.common.HttpServerAdapters; |
| 29 | + |
28 | 30 | import java.io.IOException; |
29 | 31 | import java.io.InputStream; |
30 | 32 | import java.net.HttpURLConnection; |
|
51 | 53 | * @bug 8230526 |
52 | 54 | * @summary Verifies that PlainProxyConnections are cached and reused properly. We do this by |
53 | 55 | * verifying that the remote address of the HTTP exchange (on the fake proxy server) |
54 | | - * is always the same InetSocketAddress. |
55 | | - * @modules jdk.httpserver |
56 | | - * @run main/othervm PlainProxyConnectionTest |
57 | | - * @author danielfuchs |
| 56 | + * is always the same InetSocketAddress. Logging verbosity is increased to aid in |
| 57 | + * diagnosis of intermittent failures. |
| 58 | + * @library /test/lib |
| 59 | + * /test/jdk/java/net/httpclient/lib |
| 60 | + * @run main/othervm |
| 61 | + * -Djdk.httpclient.HttpClient.log=headers,requests,trace |
| 62 | + * -Djdk.internal.httpclient.debug=true |
| 63 | + * PlainProxyConnectionTest |
58 | 64 | */ |
59 | 65 | public class PlainProxyConnectionTest { |
60 | 66 |
|
| 67 | + // Increase logging verbosity to troubleshoot intermittent failures |
| 68 | + static { |
| 69 | + HttpServerAdapters.enableServerLogging(); |
| 70 | + } |
| 71 | + |
61 | 72 | static final String RESPONSE = "<html><body><p>Hello World!</body></html>"; |
62 | | - static final String PATH = "/foo/"; |
| 73 | + |
| 74 | + // Adding some salt to the path to avoid other parallel running tests mistakenly connect to our test server |
| 75 | + private static final String PATH = String.format( |
| 76 | + "/%s-%d", PlainProxyConnectionTest.class.getSimpleName(), PlainProxyConnectionTest.class.hashCode()); |
| 77 | + |
63 | 78 | static final ConcurrentLinkedQueue<InetSocketAddress> connections = new ConcurrentLinkedQueue<>(); |
64 | 79 |
|
65 | 80 | // For convenience the server is used both as a plain server and as a plain proxy. |
|
0 commit comments