246 public void onComplete() { |
247 public void onComplete() { |
247 ofString.onComplete(); |
248 ofString.onComplete(); |
248 } |
249 } |
249 } |
250 } |
250 |
251 |
|
252 static String serverAuthority(HttpServer server) { |
|
253 return InetAddress.getLoopbackAddress().getHostName() + ":" |
|
254 + server.getAddress().getPort(); |
|
255 } |
251 |
256 |
252 @BeforeTest |
257 @BeforeTest |
253 public void setup() throws Exception { |
258 public void setup() throws Exception { |
254 sslContext = new SimpleSSLContext().get(); |
259 sslContext = new SimpleSSLContext().get(); |
255 if (sslContext == null) |
260 if (sslContext == null) |
256 throw new AssertionError("Unexpected null sslContext"); |
261 throw new AssertionError("Unexpected null sslContext"); |
257 |
262 |
258 InetSocketAddress sa = new InetSocketAddress(0); |
263 InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); |
259 httpTestServer = HttpServer.create(sa, 0); |
264 httpTestServer = HttpServer.create(sa, 0); |
260 httpTestServer.createContext("/http1/fixed", new Http1FixedHandler()); |
265 httpTestServer.createContext("/http1/fixed", new Http1FixedHandler()); |
261 httpFixedURI = "http://127.0.0.1:" + httpTestServer.getAddress().getPort() + "/http1/fixed"; |
266 httpFixedURI = "http://" + serverAuthority(httpTestServer) + "/http1/fixed"; |
262 httpTestServer.createContext("/http1/chunked", new Http1ChunkedHandler()); |
267 httpTestServer.createContext("/http1/chunked", new Http1ChunkedHandler()); |
263 httpChunkedURI = "http://127.0.0.1:" + httpTestServer.getAddress().getPort() + "/http1/chunked"; |
268 httpChunkedURI = "http://" + serverAuthority(httpTestServer) + "/http1/chunked"; |
264 |
269 |
265 httpsTestServer = HttpsServer.create(sa, 0); |
270 httpsTestServer = HttpsServer.create(sa, 0); |
266 httpsTestServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); |
271 httpsTestServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); |
267 httpsTestServer.createContext("/https1/fixed", new Http1FixedHandler()); |
272 httpsTestServer.createContext("/https1/fixed", new Http1FixedHandler()); |
268 httpsFixedURI = "https://127.0.0.1:" + httpsTestServer.getAddress().getPort() + "/https1/fixed"; |
273 httpsFixedURI = "https://" + serverAuthority(httpsTestServer) + "/https1/fixed"; |
269 httpsTestServer.createContext("/https1/chunked", new Http1ChunkedHandler()); |
274 httpsTestServer.createContext("/https1/chunked", new Http1ChunkedHandler()); |
270 httpsChunkedURI = "https://127.0.0.1:" + httpsTestServer.getAddress().getPort() + "/https1/chunked"; |
275 httpsChunkedURI = "https://" + serverAuthority(httpsTestServer) + "/https1/chunked"; |
271 |
276 |
272 http2TestServer = new Http2TestServer("127.0.0.1", false, 0); |
277 http2TestServer = new Http2TestServer("localhost", false, 0); |
273 http2TestServer.addHandler(new Http2FixedHandler(), "/http2/fixed"); |
278 http2TestServer.addHandler(new Http2FixedHandler(), "/http2/fixed"); |
274 http2FixedURI = "http://127.0.0.1:" + http2TestServer.getAddress().getPort() + "/http2/fixed"; |
279 http2FixedURI = "http://" + http2TestServer.serverAuthority()+ "/http2/fixed"; |
275 http2TestServer.addHandler(new Http2VariableHandler(), "/http2/variable"); |
280 http2TestServer.addHandler(new Http2VariableHandler(), "/http2/variable"); |
276 http2VariableURI = "http://127.0.0.1:" + http2TestServer.getAddress().getPort() + "/http2/variable"; |
281 http2VariableURI = "http://" + http2TestServer.serverAuthority() + "/http2/variable"; |
277 |
282 |
278 https2TestServer = new Http2TestServer("127.0.0.1", true, 0); |
283 https2TestServer = new Http2TestServer("localhost", true, 0); |
279 https2TestServer.addHandler(new Http2FixedHandler(), "/https2/fixed"); |
284 https2TestServer.addHandler(new Http2FixedHandler(), "/https2/fixed"); |
280 https2FixedURI = "https://127.0.0.1:" + https2TestServer.getAddress().getPort() + "/https2/fixed"; |
285 https2FixedURI = "https://" + https2TestServer.serverAuthority() + "/https2/fixed"; |
281 https2TestServer.addHandler(new Http2VariableHandler(), "/https2/variable"); |
286 https2TestServer.addHandler(new Http2VariableHandler(), "/https2/variable"); |
282 https2VariableURI = "https://127.0.0.1:" + https2TestServer.getAddress().getPort() + "/https2/variable"; |
287 https2VariableURI = "https://" + https2TestServer.serverAuthority() + "/https2/variable"; |
283 |
288 |
284 httpTestServer.start(); |
289 httpTestServer.start(); |
285 httpsTestServer.start(); |
290 httpsTestServer.start(); |
286 http2TestServer.start(); |
291 http2TestServer.start(); |
287 https2TestServer.start(); |
292 https2TestServer.start(); |