WebSocketProtocolHandlerTest Class — netty Architecture
Architecture documentation for the WebSocketProtocolHandlerTest class in WebSocketProtocolHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5["WebSocketProtocolHandlerTest"] f83b2dfb_daa4_5e12_cfb6_63ec53b5b000["WebSocketProtocolHandlerTest.java"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|defined in| f83b2dfb_daa4_5e12_cfb6_63ec53b5b000 a3634ff6_140e_5910_7de6_81d98b0fb9f8["testPingFrame()"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|method| a3634ff6_140e_5910_7de6_81d98b0fb9f8 412c6c21_7ca3_782b_9331_ffe3c4a94392["testPingPongFlowControlWhenAutoReadIsDisabled()"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|method| 412c6c21_7ca3_782b_9331_ffe3c4a94392 3c31931c_e0a8_0527_e3b8_7361cbb26a44["testPongFrameDropFrameFalse()"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|method| 3c31931c_e0a8_0527_e3b8_7361cbb26a44 20ce0114_6a96_45d7_3b9d_6ea92dfa0441["testPongFrameDropFrameTrue()"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|method| 20ce0114_6a96_45d7_3b9d_6ea92dfa0441 4de1718d_980b_52aa_8c94_23349e7a3c21["testTextFrame()"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|method| 4de1718d_980b_52aa_8c94_23349e7a3c21 0ec7ecda_41bb_a5d6_cec4_ed8eb07ab8de["testTimeout()"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|method| 0ec7ecda_41bb_a5d6_cec4_ed8eb07ab8de 8cf80732_3146_beb8_835c_e7d7278a759d["assertPropagatedInbound()"] 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5 -->|method| 8cf80732_3146_beb8_835c_e7d7278a759d
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandlerTest.java lines 42–187
public class WebSocketProtocolHandlerTest {
@Test
public void testPingFrame() {
ByteBuf pingData = Unpooled.copiedBuffer("Hello, world", UTF_8);
EmbeddedChannel channel = new EmbeddedChannel(new WebSocketProtocolHandler() { });
PingWebSocketFrame inputMessage = new PingWebSocketFrame(pingData);
assertFalse(channel.writeInbound(inputMessage)); // the message was not propagated inbound
// a Pong frame was written to the channel
PongWebSocketFrame response = channel.readOutbound();
assertEquals(pingData, response.content());
pingData.release();
assertFalse(channel.finish());
}
@Test
public void testPingPongFlowControlWhenAutoReadIsDisabled() {
String text1 = "Hello, world #1";
String text2 = "Hello, world #2";
String text3 = "Hello, world #3";
String text4 = "Hello, world #4";
EmbeddedChannel channel = new EmbeddedChannel();
channel.config().setAutoRead(false);
channel.pipeline().addLast(new FlowControlHandler());
channel.pipeline().addLast(new WebSocketProtocolHandler() { });
// When
assertFalse(channel.writeInbound(
new PingWebSocketFrame(Unpooled.copiedBuffer(text1, UTF_8)),
new TextWebSocketFrame(text2),
new TextWebSocketFrame(text3),
new PingWebSocketFrame(Unpooled.copiedBuffer(text4, UTF_8))
));
// Then - no messages were handled or propagated
assertNull(channel.readInbound());
assertNull(channel.readOutbound());
// When
channel.read();
// Then - pong frame was written to the outbound
PongWebSocketFrame response1 = channel.readOutbound();
assertEquals(text1, response1.content().toString(UTF_8));
// And - one requested message was handled and propagated inbound
TextWebSocketFrame message2 = channel.readInbound();
assertEquals(text2, message2.text());
// And - no more messages were handled or propagated
assertNull(channel.readInbound());
assertNull(channel.readOutbound());
// When
channel.read();
// Then - one requested message was handled and propagated inbound
TextWebSocketFrame message3 = channel.readInbound();
assertEquals(text3, message3.text());
// And - no more messages were handled or propagated
// Precisely, ping frame 'text4' was NOT read or handled.
// It would be handle ONLY on the next 'channel.read()' call.
assertNull(channel.readInbound());
assertNull(channel.readOutbound());
// Cleanup
response1.release();
message2.release();
message3.release();
assertFalse(channel.finish());
}
@Test
public void testPongFrameDropFrameFalse() {
EmbeddedChannel channel = new EmbeddedChannel(new WebSocketProtocolHandler(false) { });
Defined In
Source
Frequently Asked Questions
What is the WebSocketProtocolHandlerTest class?
WebSocketProtocolHandlerTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandlerTest.java.
Where is WebSocketProtocolHandlerTest defined?
WebSocketProtocolHandlerTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandlerTest.java at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free