--- a/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java Wed Apr 11 00:55:41 2018 +0100
+++ b/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java Wed Apr 11 14:21:11 2018 +0100
@@ -44,36 +44,41 @@
public class PendingPongTextClose extends PendingOperations {
+ CompletableFuture<WebSocket> cfText;
+ CompletableFuture<WebSocket> cfPong;
+ CompletableFuture<WebSocket> cfClose;
+
@Test(dataProvider = "booleans")
public void pendingPongTextClose(boolean last) throws Exception {
- server = Support.notReadingServer();
- server.open();
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), new WebSocket.Listener() { })
- .join();
- ByteBuffer data = ByteBuffer.allocate(125);
- CompletableFuture<WebSocket> cfPong;
- for (int i = 0; ; i++) { // fill up the send buffer
- long start = System.currentTimeMillis();
- System.out.printf("begin cycle #%s at %s%n", i, start);
- cfPong = webSocket.sendPong(data);
- try {
- cfPong.get(MAX_WAIT_SEC, TimeUnit.SECONDS);
- data.clear();
- } catch (TimeoutException e) {
- break;
- } finally {
- long stop = System.currentTimeMillis();
- System.out.printf("end cycle #%s at %s (%s ms)%n", i, stop, stop - start);
+ repeatable( () -> {
+ server = Support.notReadingServer();
+ server.open();
+ webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), new WebSocket.Listener() { })
+ .join();
+ ByteBuffer data = ByteBuffer.allocate(125);
+ for (int i = 0; ; i++) { // fill up the send buffer
+ long start = System.currentTimeMillis();
+ System.out.printf("begin cycle #%s at %s%n", i, start);
+ cfPong = webSocket.sendPong(data);
+ try {
+ cfPong.get(MAX_WAIT_SEC, TimeUnit.SECONDS);
+ data.clear();
+ } catch (TimeoutException e) {
+ break;
+ } finally {
+ long stop = System.currentTimeMillis();
+ System.out.printf("end cycle #%s at %s (%s ms)%n", i, stop, stop - start);
+ }
}
- }
- assertFails(ISE, webSocket.sendPing(ByteBuffer.allocate(125)));
- assertFails(ISE, webSocket.sendPong(ByteBuffer.allocate(125)));
- CompletableFuture<WebSocket> cfText = webSocket.sendText("hello", last);
- assertHangs(cfText);
- CompletableFuture<WebSocket> cfClose
- = webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok");
- assertHangs(cfClose);
+ assertFails(ISE, webSocket.sendPing(ByteBuffer.allocate(125)));
+ assertFails(ISE, webSocket.sendPong(ByteBuffer.allocate(125)));
+ cfText = webSocket.sendText("hello", last);
+ assertHangs(cfText);
+ cfClose = webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok");
+ assertHangs(cfClose);
+ return null;
+ }, () -> cfPong.isDone() ? true : false);
webSocket.abort();
assertFails(IOE, cfPong);
assertFails(IOE, cfText);