test/jdk/java/net/httpclient/websocket/WebSocketTest.java
branchhttp-client-branch
changeset 56269 234813fd33bc
parent 56263 4933a477d628
child 56294 181bc33917e4
equal deleted inserted replaced
56268:481d8c9acc7f 56269:234813fd33bc
    57     private static final Class<NullPointerException> NPE = NullPointerException.class;
    57     private static final Class<NullPointerException> NPE = NullPointerException.class;
    58     private static final Class<IllegalArgumentException> IAE = IllegalArgumentException.class;
    58     private static final Class<IllegalArgumentException> IAE = IllegalArgumentException.class;
    59     private static final Class<IllegalStateException> ISE = IllegalStateException.class;
    59     private static final Class<IllegalStateException> ISE = IllegalStateException.class;
    60     private static final Class<IOException> IOE = IOException.class;
    60     private static final Class<IOException> IOE = IOException.class;
    61 
    61 
    62 //    @Test
    62     @Test
    63     public void immediateAbort() throws Exception {
    63     public void immediateAbort() throws Exception {
    64         try (DummyWebSocketServer server = serverWithCannedData(0x81, 0x00, 0x88, 0x00)) {
    64         try (DummyWebSocketServer server = serverWithCannedData(0x81, 0x00, 0x88, 0x00)) {
    65             server.open();
    65             server.open();
    66             CompletableFuture<Void> messageReceived = new CompletableFuture<>();
    66             CompletableFuture<Void> messageReceived = new CompletableFuture<>();
    67             WebSocket ws = newHttpClient()
    67             WebSocket ws = newHttpClient()
   233                     .newWebSocketBuilder()
   233                     .newWebSocketBuilder()
   234                     .buildAsync(server.getURI(), new WebSocket.Listener() { })
   234                     .buildAsync(server.getURI(), new WebSocket.Listener() { })
   235                     .join();
   235                     .join();
   236             ws.sendClose(NORMAL_CLOSURE, "").join();
   236             ws.sendClose(NORMAL_CLOSURE, "").join();
   237             assertTrue(ws.isOutputClosed());
   237             assertTrue(ws.isOutputClosed());
   238             assertFalse(ws.isInputClosed());
       
   239             assertEquals(ws.getSubprotocol(), "");
   238             assertEquals(ws.getSubprotocol(), "");
   240             ws.request(1); // No exceptions must be thrown
   239             ws.request(1); // No exceptions must be thrown
   241         }
   240         }
   242     }
   241     }
   243 
   242 
   261             }
   260             }
   262             CompletableFuture<WebSocket> cf = ws.sendClose(NORMAL_CLOSURE, "");
   261             CompletableFuture<WebSocket> cf = ws.sendClose(NORMAL_CLOSURE, "");
   263             // The output closes even if the Close message has not been sent
   262             // The output closes even if the Close message has not been sent
   264             assertFalse(cf.isDone());
   263             assertFalse(cf.isDone());
   265             assertTrue(ws.isOutputClosed());
   264             assertTrue(ws.isOutputClosed());
   266             assertFalse(ws.isInputClosed());
       
   267             assertEquals(ws.getSubprotocol(), "");
   265             assertEquals(ws.getSubprotocol(), "");
   268         }
   266         }
   269     }
   267     }
   270 
   268 
   271     /*
   269     /*
   284                 }
   282                 }
   285             }
   283             }
   286         };
   284         };
   287     }
   285     }
   288 
   286 
   289 //    @Test
   287     @Test
   290     public void abortPendingSendBinary() throws Exception {
   288     public void abortPendingSendBinary() throws Exception {
   291         try (DummyWebSocketServer server = notReadingServer()) {
   289         try (DummyWebSocketServer server = notReadingServer()) {
   292             server.open();
   290             server.open();
   293             WebSocket ws = newHttpClient()
   291             WebSocket ws = newHttpClient()
   294                     .newWebSocketBuilder()
   292                     .newWebSocketBuilder()
   311             assertTrue(ws.isInputClosed());
   309             assertTrue(ws.isInputClosed());
   312             assertCompletesExceptionally(IOException.class, cf);
   310             assertCompletesExceptionally(IOException.class, cf);
   313         }
   311         }
   314     }
   312     }
   315 
   313 
   316 //    @Test
   314     @Test
   317     public void abortPendingSendText() throws Exception {
   315     public void abortPendingSendText() throws Exception {
   318         try (DummyWebSocketServer server = notReadingServer()) {
   316         try (DummyWebSocketServer server = notReadingServer()) {
   319             server.open();
   317             server.open();
   320             WebSocket ws = newHttpClient()
   318             WebSocket ws = newHttpClient()
   321                     .newWebSocketBuilder()
   319                     .newWebSocketBuilder()