http-client-branch: review comment - WebSocket removed duplication in tests (these scenarios are better tested in PendingXYZ.java) http-client-branch
authorprappo
Fri, 13 Apr 2018 15:43:16 +0100
branchhttp-client-branch
changeset 56428 3dbf8ee93b08
parent 56427 7f1916397463
child 56429 d61066f546a7
http-client-branch: review comment - WebSocket removed duplication in tests (these scenarios are better tested in PendingXYZ.java)
test/jdk/java/net/httpclient/websocket/SendTest.java
--- a/test/jdk/java/net/httpclient/websocket/SendTest.java	Fri Apr 13 15:33:13 2018 +0100
+++ b/test/jdk/java/net/httpclient/websocket/SendTest.java	Fri Apr 13 15:43:16 2018 +0100
@@ -34,15 +34,10 @@
 
 import java.io.IOException;
 import java.net.http.WebSocket;
-import java.nio.ByteBuffer;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 import static java.net.http.HttpClient.newHttpClient;
 import static java.net.http.WebSocket.NORMAL_CLOSURE;
 import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertThrows;
 import static org.testng.Assert.assertTrue;
 
@@ -102,91 +97,4 @@
         assertEquals(webSocket.getSubprotocol(), "");
         webSocket.request(1); // No exceptions must be thrown
     }
-
-    @Test
-    public void sendClosePending() throws Exception {
-        server = Support.notReadingServer();
-        server.open();
-        webSocket = newHttpClient().newWebSocketBuilder()
-                .buildAsync(server.getURI(), new WebSocket.Listener() { })
-                .join();
-        ByteBuffer data = ByteBuffer.allocate(65536);
-        for (int i = 0; ; i++) { // fill up the send buffer
-            System.out.printf("begin cycle #%s at %s%n",
-                              i, System.currentTimeMillis());
-            try {
-                webSocket.sendBinary(data, true).get(10, TimeUnit.SECONDS);
-                data.clear();
-            } catch (TimeoutException e) {
-                break;
-            } finally {
-                System.out.printf("end cycle #%s at %s%n",
-                                  i, System.currentTimeMillis());
-            }
-        }
-        CompletableFuture<WebSocket> cf = webSocket.sendClose(NORMAL_CLOSURE, "");
-        // The output closes even if the Close message has not been sent
-        assertFalse(cf.isDone());
-        assertTrue(webSocket.isOutputClosed());
-        assertEquals(webSocket.getSubprotocol(), "");
-    }
-
-    @Test
-    public void abortPendingSendBinary() throws Exception {
-        server = Support.notReadingServer();
-        server.open();
-        webSocket = newHttpClient()
-                .newWebSocketBuilder()
-                .buildAsync(server.getURI(), new WebSocket.Listener() { })
-                .join();
-        ByteBuffer data = ByteBuffer.allocate(65536);
-        CompletableFuture<WebSocket> cf = null;
-        for (int i = 0; ; i++) {  // fill up the send buffer
-            System.out.printf("begin cycle #%s at %s%n",
-                              i, System.currentTimeMillis());
-            try {
-                cf = webSocket.sendBinary(data, true);
-                cf.get(5, TimeUnit.SECONDS);
-                data.clear();
-            } catch (TimeoutException e) {
-                break;
-            } finally {
-                System.out.printf("end cycle #%s at %s%n",
-                                  i, System.currentTimeMillis());
-            }
-        }
-        webSocket.abort();
-        assertTrue(webSocket.isOutputClosed());
-        assertTrue(webSocket.isInputClosed());
-        Support.assertFails(IOException.class, cf);
-    }
-
-    @Test
-    public void abortPendingSendText() throws Exception {
-        server = Support.notReadingServer();
-        server.open();
-        webSocket = newHttpClient()
-                .newWebSocketBuilder()
-                .buildAsync(server.getURI(), new WebSocket.Listener() { })
-                .join();
-        String data = Support.stringWith2NBytes(32768);
-        CompletableFuture<WebSocket> cf = null;
-        for (int i = 0; ; i++) {  // fill up the send buffer
-            System.out.printf("begin cycle #%s at %s%n",
-                              i, System.currentTimeMillis());
-            try {
-                cf = webSocket.sendText(data, true);
-                cf.get(5, TimeUnit.SECONDS);
-            } catch (TimeoutException e) {
-                break;
-            } finally {
-                System.out.printf("end cycle #%s at %s%n",
-                                  i, System.currentTimeMillis());
-            }
-        }
-        webSocket.abort();
-        assertTrue(webSocket.isOutputClosed());
-        assertTrue(webSocket.isInputClosed());
-        Support.assertFails(IOException.class, cf);
-    }
 }