Issue #7086 - Fix test failure in WebSocketOpenTest
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
bd42cc1ebd
commit
750ee0a182
|
@ -33,7 +33,8 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
|
@ -157,22 +158,22 @@ public class WebSocketOpenTest extends WebSocketTester
|
|||
Parser.ParsedFrame frame = receiveFrame(client.getInputStream());
|
||||
assertThat(frame.getPayloadAsUTF8(), is("Hello"));
|
||||
|
||||
// But cannot receive
|
||||
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
|
||||
assertFalse(serverHandler.closeLatch.await(1, TimeUnit.SECONDS));
|
||||
|
||||
// Can't demand until open
|
||||
assertThrows(Throwable.class, () -> coreSession.demand(1));
|
||||
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
|
||||
assertFalse(serverHandler.closeLatch.await(1, TimeUnit.SECONDS));
|
||||
|
||||
// Succeeded moves to OPEN state and still does not read CLOSE frame
|
||||
// Succeeded moves to OPEN state.
|
||||
onOpenCallback.succeeded();
|
||||
assertThat(coreSession.toString(), containsString("OPEN"));
|
||||
|
||||
// Demand start receiving frames
|
||||
// Demanding in onOpen will allow you to receive frames.
|
||||
client.getOutputStream().write(RawFrameBuilder.buildFrame(OpCode.TEXT, "message in onOpen", true));
|
||||
assertNull(serverHandler.receivedFrames.poll(1, TimeUnit.SECONDS));
|
||||
coreSession.demand(1);
|
||||
Frame rcvFrame = serverHandler.receivedFrames.poll(5, TimeUnit.SECONDS);
|
||||
assertNotNull(rcvFrame);
|
||||
assertThat(rcvFrame.getPayloadAsUTF8(), is("message in onOpen"));
|
||||
|
||||
// Demand to receive the close frame.
|
||||
client.getOutputStream().write(RawFrameBuilder.buildClose(new CloseStatus(CloseStatus.NORMAL), true));
|
||||
assertFalse(serverHandler.closeLatch.await(1, TimeUnit.SECONDS));
|
||||
coreSession.demand(1);
|
||||
assertTrue(serverHandler.closeLatch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
// Closed handled normally
|
||||
|
|
Loading…
Reference in New Issue