--- a/test/jdk/java/net/httpclient/http2/BasicTest.java Tue Apr 17 15:39:20 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/BasicTest.java Tue Apr 17 08:54:17 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,30 +27,29 @@
* @library /lib/testlibrary server
* @build jdk.testlibrary.SimpleSSLContext
* @modules java.base/sun.net.www.http
- * jdk.incubator.httpclient/jdk.incubator.http.internal.common
- * jdk.incubator.httpclient/jdk.incubator.http.internal.frame
- * jdk.incubator.httpclient/jdk.incubator.http.internal.hpack
+ * java.net.http/jdk.internal.net.http.common
+ * java.net.http/jdk.internal.net.http.frame
+ * java.net.http/jdk.internal.net.http.hpack
* @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors BasicTest
*/
import java.io.IOException;
import java.net.*;
-import jdk.incubator.http.*;
-import static jdk.incubator.http.HttpClient.Version.HTTP_2;
import javax.net.ssl.*;
+import java.net.http.HttpClient;
+import java.net.http.HttpHeaders;
+import java.net.http.HttpRequest;
+import java.net.http.HttpRequest.BodyPublishers;
+import java.net.http.HttpResponse;
+import java.net.http.HttpResponse.BodyHandlers;
import java.nio.file.*;
import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import jdk.testlibrary.SimpleSSLContext;
-import static jdk.incubator.http.HttpRequest.BodyPublisher.fromFile;
-import static jdk.incubator.http.HttpRequest.BodyPublisher.fromString;
-import static jdk.incubator.http.HttpResponse.BodyHandler.asFile;
-import static jdk.incubator.http.HttpResponse.BodyHandler.asString;
-
import org.testng.annotations.Test;
+import static java.net.http.HttpClient.Version.HTTP_2;
@Test
public class BasicTest {
@@ -77,9 +76,9 @@
httpsServer.addHandler(new Http2EchoHandler(), "/");
httpsPort = httpsServer.getAddress().getPort();
- httpURIString = "http://127.0.0.1:" + httpPort + "/foo/";
- pingURIString = "http://127.0.0.1:" + httpPort + "/ping/";
- httpsURIString = "https://127.0.0.1:" + httpsPort + "/bar/";
+ httpURIString = "http://localhost:" + httpPort + "/foo/";
+ pingURIString = "http://localhost:" + httpPort + "/ping/";
+ httpsURIString = "https://localhost:" + httpsPort + "/bar/";
httpServer.start();
httpsServer.start();
@@ -203,12 +202,12 @@
HttpClient client = getClient();
Path src = TestUtil.getAFile(FILESIZE * 4);
HttpRequest req = HttpRequest.newBuilder(uri)
- .POST(fromFile(src))
+ .POST(BodyPublishers.ofFile(src))
.build();
Path dest = Paths.get("streamtest.txt");
dest.toFile().delete();
- CompletableFuture<Path> response = client.sendAsync(req, asFile(dest))
+ CompletableFuture<Path> response = client.sendAsync(req, BodyHandlers.ofFile(dest))
.thenApply(resp -> {
if (resp.statusCode() != 200)
throw new RuntimeException();
@@ -230,10 +229,10 @@
t.sendResponseHeaders(500, -1);
}
}), "/");
- URI u = new URI("https://127.0.0.1:"+httpsPort+"/foo");
+ URI u = new URI("https://localhost:"+httpsPort+"/foo");
HttpClient client = getClient();
HttpRequest req = HttpRequest.newBuilder(u).build();
- HttpResponse<String> resp = client.send(req, asString());
+ HttpResponse<String> resp = client.send(req, BodyHandlers.ofString());
int stat = resp.statusCode();
if (stat != 200) {
throw new RuntimeException("paramsTest failed "
@@ -250,9 +249,9 @@
HttpClient client = getClient();
HttpRequest req = HttpRequest.newBuilder(uri)
- .POST(fromString(SIMPLE_STRING))
+ .POST(BodyPublishers.ofString(SIMPLE_STRING))
.build();
- HttpResponse<String> response = client.send(req, asString());
+ HttpResponse<String> response = client.send(req, BodyHandlers.ofString());
checkStatus(200, response.statusCode());
String responseBody = response.body();
HttpHeaders h = response.headers();
@@ -270,10 +269,10 @@
CompletableFuture[] responses = new CompletableFuture[LOOPS];
final Path source = TestUtil.getAFile(FILESIZE);
HttpRequest request = HttpRequest.newBuilder(uri)
- .POST(fromFile(source))
+ .POST(BodyPublishers.ofFile(source))
.build();
for (int i = 0; i < LOOPS; i++) {
- responses[i] = client.sendAsync(request, asFile(tempFile()))
+ responses[i] = client.sendAsync(request, BodyHandlers.ofFile(tempFile()))
//.thenApply(resp -> compareFiles(resp.body(), source));
.thenApply(resp -> {
System.out.printf("Resp status %d body size %d\n",