WebSocket08FrameDecoderTest Class — netty Architecture
Architecture documentation for the WebSocket08FrameDecoderTest class in WebSocket08FrameDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 30e9dec2_7c00_6d6f_80a0_7f9595928d39["WebSocket08FrameDecoderTest"] e8f1cd39_3434_3901_f32d_9383020d3734["WebSocket08FrameDecoderTest.java"] 30e9dec2_7c00_6d6f_80a0_7f9595928d39 -->|defined in| e8f1cd39_3434_3901_f32d_9383020d3734 2ea04bc8_cb8c_e8c5_9224_240dffbf6d8f["channelInactive()"] 30e9dec2_7c00_6d6f_80a0_7f9595928d39 -->|method| 2ea04bc8_cb8c_e8c5_9224_240dffbf6d8f f49a613b_1ebd_1a40_90bb_cdde736b36ff["supportIanaStatusCodes()"] 30e9dec2_7c00_6d6f_80a0_7f9595928d39 -->|method| f49a613b_1ebd_1a40_90bb_cdde736b36ff 9d09a4db_abdf_2194_fb0a_5305cb78882a["protocolViolationWhenNegativeFrameLength()"] 30e9dec2_7c00_6d6f_80a0_7f9595928d39 -->|method| 9d09a4db_abdf_2194_fb0a_5305cb78882a
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoderTest.java lines 33–97
public class WebSocket08FrameDecoderTest {
@Test
public void channelInactive() throws Exception {
final WebSocket08FrameDecoder decoder = new WebSocket08FrameDecoder(true, true, 65535, false);
final ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
decoder.channelInactive(ctx);
verify(ctx).fireChannelInactive();
}
@Test
public void supportIanaStatusCodes() throws Exception {
Set<Integer> forbiddenIanaCodes = new HashSet<Integer>();
forbiddenIanaCodes.add(1004);
forbiddenIanaCodes.add(1005);
forbiddenIanaCodes.add(1006);
Set<Integer> validIanaCodes = new HashSet<Integer>();
for (int i = 1000; i < 1015; i++) {
validIanaCodes.add(i);
}
validIanaCodes.removeAll(forbiddenIanaCodes);
for (int statusCode: validIanaCodes) {
EmbeddedChannel encoderChannel = new EmbeddedChannel(new WebSocket08FrameEncoder(true));
EmbeddedChannel decoderChannel = new EmbeddedChannel(new WebSocket08FrameDecoder(true, true, 65535, false));
assertTrue(encoderChannel.writeOutbound(new CloseWebSocketFrame(statusCode, "Bye")));
assertTrue(encoderChannel.finish());
ByteBuf serializedCloseFrame = encoderChannel.readOutbound();
assertNull(encoderChannel.readOutbound());
assertTrue(decoderChannel.writeInbound(serializedCloseFrame));
assertTrue(decoderChannel.finish());
CloseWebSocketFrame outputFrame = decoderChannel.readInbound();
assertNull(decoderChannel.readOutbound());
try {
assertEquals(statusCode, outputFrame.statusCode());
} finally {
outputFrame.release();
}
}
}
@Test
void protocolViolationWhenNegativeFrameLength() {
WebSocket08FrameDecoder decoder = new WebSocket08FrameDecoder(true, true, 65535, false);
final EmbeddedChannel channel = new EmbeddedChannel(decoder);
final ByteBuf invalidFrame = Unpooled.buffer(10).writeByte(0x81)
.writeByte(0xFF).writeLong(-1L);
Throwable exception = assertThrows(CorruptedWebSocketFrameException.class, new Executable() {
@Override
public void execute() {
channel.writeInbound(invalidFrame);
}
});
assertEquals("invalid data frame length (negative length)", exception.getMessage());
CloseWebSocketFrame closeFrame = channel.readOutbound();
assertEquals("invalid data frame length (negative length)", closeFrame.reasonText());
assertTrue(closeFrame.release());
assertFalse(channel.isActive());
}
}
Defined In
Source
Frequently Asked Questions
What is the WebSocket08FrameDecoderTest class?
WebSocket08FrameDecoderTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoderTest.java.
Where is WebSocket08FrameDecoderTest defined?
WebSocket08FrameDecoderTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoderTest.java at line 33.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free