|
38 | 38 | import jdk.test.lib.process.ProcessTools; |
39 | 39 | import jdk.test.lib.security.SecurityUtils; |
40 | 40 |
|
41 | | -import javax.net.ssl.HostnameVerifier; |
42 | | -import javax.net.ssl.HttpsURLConnection; |
43 | | -import javax.net.ssl.SSLSession; |
44 | | -import javax.net.ssl.SSLSocket; |
45 | | -import java.io.BufferedReader; |
46 | | -import java.io.DataOutputStream; |
47 | | -import java.io.IOException; |
48 | | -import java.io.InputStreamReader; |
49 | 41 | import java.net.InetAddress; |
50 | | -import java.net.URL; |
51 | | - |
52 | | -import static java.nio.charset.StandardCharsets.UTF_8; |
53 | 42 |
|
54 | 43 | public class LoggingFormatConsistency extends SSLSocketTemplate { |
55 | 44 |
|
@@ -89,63 +78,19 @@ public static void main(String[] args) throws Exception { |
89 | 78 | "LoggingFormatConsistency", |
90 | 79 | "runTest"); // Ensuring args.length is greater than 0 when test JVM starts |
91 | 80 |
|
| 81 | + output.asLines() |
| 82 | + .stream() |
| 83 | + .filter(line -> line.startsWith("Connecting to")) |
| 84 | + .forEach(System.out::println); // prints connection info from test jvm output |
| 85 | + |
92 | 86 | if (output.getExitValue() != 0) { |
93 | | - throw new RuntimeException("Test JVM process failed. JVM stderr= " + output.getStderr()); |
| 87 | + output.asLines().forEach(System.out::println); |
| 88 | + throw new RuntimeException("Test JVM process failed"); |
94 | 89 | } |
95 | 90 |
|
96 | 91 | output.shouldContain(expectedTLSVersion); |
97 | 92 | output.shouldNotContain(incorrectTLSVersion); |
98 | 93 | } |
99 | 94 | } |
100 | 95 | } |
101 | | - |
102 | | - @Override |
103 | | - protected boolean isCustomizedClientConnection() { return true; } |
104 | | - |
105 | | - @Override |
106 | | - protected void runServerApplication(SSLSocket socket) throws Exception { |
107 | | - var response = "Hello World!"; |
108 | | - var out = new DataOutputStream(socket.getOutputStream()); |
109 | | - try { |
110 | | - // We don't need to process the data from the socket |
111 | | - // Simply sending a response right away is sufficient |
112 | | - // to generate the desired debug output |
113 | | - var responseBytes = response.getBytes(UTF_8); |
114 | | - |
115 | | - out.writeBytes("HTTP/1.0 200 OK\r\n"); |
116 | | - out.writeBytes("Content-Length: " + responseBytes.length + "\r\n"); |
117 | | - out.writeBytes("Content-Type: text/html\r\n\r\n"); |
118 | | - out.write(responseBytes); |
119 | | - out.flush(); |
120 | | - } catch (IOException e) { |
121 | | - out.writeBytes("HTTP/1.0 400 " + e.getMessage() + "\r\n"); |
122 | | - out.writeBytes("Content-Type: text/html\r\n\r\n"); |
123 | | - out.flush(); |
124 | | - } |
125 | | - } |
126 | | - |
127 | | - @Override |
128 | | - protected void runClientApplication(int serverPort) throws Exception { |
129 | | - var context = createClientSSLContext(); |
130 | | - HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); |
131 | | - HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier()); |
132 | | - |
133 | | - var host = serverAddress == null ? "localhost" : serverAddress.getHostAddress(); |
134 | | - var url = new URL("https://" + host + ":" + serverPort + "/"); |
135 | | - var httpsConnection = (HttpsURLConnection) url.openConnection(); |
136 | | - httpsConnection.disconnect(); |
137 | | - try (var in = new BufferedReader(new InputStreamReader(httpsConnection.getInputStream()))) { |
138 | | - // Getting the input stream from the BufferedReader is sufficient to generate the desired debug output |
139 | | - // We don't need to process the data |
140 | | - } catch (IOException e) { |
141 | | - throw new RuntimeException(e); |
142 | | - } |
143 | | - } |
144 | | - |
145 | | - private static class NameVerifier implements HostnameVerifier { |
146 | | - @Override |
147 | | - public boolean verify(String s, SSLSession sslSession) { |
148 | | - return true; |
149 | | - } |
150 | | - } |
151 | 96 | } |
0 commit comments