WebSocket08EncoderDecoderTest Class — netty Architecture
Architecture documentation for the WebSocket08EncoderDecoderTest class in WebSocket08EncoderDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1641b287_2aaf_ce3b_c2c6_654ccc82886d["WebSocket08EncoderDecoderTest"] d9922e4c_97a6_4d62_19bd_b81db1d93240["WebSocket08EncoderDecoderTest.java"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|defined in| d9922e4c_97a6_4d62_19bd_b81db1d93240 56256270_4a10_737f_73a0_6c3b146a6140["initTestData()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| 56256270_4a10_737f_73a0_6c3b146a6140 1a0bc198_3cbd_937a_5778_4a6c5c16cecf["testWebSocketProtocolViolation()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| 1a0bc198_3cbd_937a_5778_4a6c5c16cecf 82de8b8e_7786_8b3a_c2e0_97889a7caa9d["executeProtocolViolationTest()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| 82de8b8e_7786_8b3a_c2e0_97889a7caa9d 9bf50fab_dea9_9f14_30be_52f2e34e23f3["testWebSocketEncodingAndDecoding()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| 9bf50fab_dea9_9f14_30be_52f2e34e23f3 2ef26fb3_9ddb_2c34_88fb_726150d7f587["executeTests()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| 2ef26fb3_9ddb_2c34_88fb_726150d7f587 eb12ef0f_e293_b4ee_ce25_85a0867ad801["testTextWithLen()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| eb12ef0f_e293_b4ee_ce25_85a0867ad801 0922f899_084a_8fad_20de_9e770362a721["testBinaryWithLen()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| 0922f899_084a_8fad_20de_9e770362a721 769a32ef_247a_a420_e4eb_c20e3eecc81e["transfer()"] 1641b287_2aaf_ce3b_c2c6_654ccc82886d -->|method| 769a32ef_247a_a420_e4eb_c20e3eecc81e
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08EncoderDecoderTest.java lines 34–222
public class WebSocket08EncoderDecoderTest {
private ByteBuf binTestData;
private String strTestData;
private static final int MAX_TESTDATA_LENGTH = 100 * 1024;
private void initTestData() {
binTestData = Unpooled.buffer(MAX_TESTDATA_LENGTH);
byte j = 0;
for (int i = 0; i < MAX_TESTDATA_LENGTH; i++) {
binTestData.array()[i] = j;
j++;
}
StringBuilder s = new StringBuilder();
char c = 'A';
for (int i = 0; i < MAX_TESTDATA_LENGTH; i++) {
s.append(c);
c++;
if (c == 'Z') {
c = 'A';
}
}
strTestData = s.toString();
}
@Test
public void testWebSocketProtocolViolation() {
// Given
initTestData();
int maxPayloadLength = 255;
String errorMessage = "Max frame length of " + maxPayloadLength + " has been exceeded.";
WebSocketCloseStatus expectedStatus = WebSocketCloseStatus.MESSAGE_TOO_BIG;
// With auto-close
WebSocketDecoderConfig config = WebSocketDecoderConfig.newBuilder()
.maxFramePayloadLength(maxPayloadLength)
.closeOnProtocolViolation(true)
.build();
EmbeddedChannel inChannel = new EmbeddedChannel(new WebSocket08FrameDecoder(config));
EmbeddedChannel outChannel = new EmbeddedChannel(new WebSocket08FrameEncoder(true));
executeProtocolViolationTest(outChannel, inChannel, maxPayloadLength + 1, expectedStatus, errorMessage);
CloseWebSocketFrame response = inChannel.readOutbound();
assertNotNull(response);
assertEquals(expectedStatus.code(), response.statusCode());
assertEquals(errorMessage, response.reasonText());
response.release();
assertFalse(inChannel.finish());
assertFalse(outChannel.finish());
// Without auto-close
config = WebSocketDecoderConfig.newBuilder()
.maxFramePayloadLength(maxPayloadLength)
.closeOnProtocolViolation(false)
.build();
inChannel = new EmbeddedChannel(new WebSocket08FrameDecoder(config));
outChannel = new EmbeddedChannel(new WebSocket08FrameEncoder(true));
executeProtocolViolationTest(outChannel, inChannel, maxPayloadLength + 1, expectedStatus, errorMessage);
response = inChannel.readOutbound();
assertNull(response);
assertFalse(inChannel.finish());
assertFalse(outChannel.finish());
// Release test data
binTestData.release();
}
private void executeProtocolViolationTest(EmbeddedChannel outChannel, EmbeddedChannel inChannel,
int testDataLength, WebSocketCloseStatus expectedStatus, String errorMessage) {
CorruptedWebSocketFrameException corrupted = null;
try {
testBinaryWithLen(outChannel, inChannel, testDataLength);
Defined In
Source
Frequently Asked Questions
What is the WebSocket08EncoderDecoderTest class?
WebSocket08EncoderDecoderTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08EncoderDecoderTest.java.
Where is WebSocket08EncoderDecoderTest defined?
WebSocket08EncoderDecoderTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08EncoderDecoderTest.java at line 34.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free