WebSocketFrameAggregatorTest.java — netty Source File
Architecture documentation for WebSocketFrameAggregatorTest.java, a java file in the netty codebase.
Entity Profile
Relationship Graph
Source Code
/*
* Copyright 2013 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.http.websocketx;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.util.CharsetUtil;
import io.netty.util.ReferenceCountUtil;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public class WebSocketFrameAggregatorTest {
private static final byte[] content1 = "Content1".getBytes(CharsetUtil.UTF_8);
private static final byte[] content2 = "Content2".getBytes(CharsetUtil.UTF_8);
private static final byte[] content3 = "Content3".getBytes(CharsetUtil.UTF_8);
private static final byte[] aggregatedContent = new byte[content1.length + content2.length + content3.length];
static {
System.arraycopy(content1, 0, aggregatedContent, 0, content1.length);
System.arraycopy(content2, 0, aggregatedContent, content1.length, content2.length);
System.arraycopy(content3, 0, aggregatedContent, content1.length + content2.length, content3.length);
}
@Test
public void testAggregationBinary() {
EmbeddedChannel channel = new EmbeddedChannel(new WebSocketFrameAggregator(Integer.MAX_VALUE));
channel.writeInbound(new BinaryWebSocketFrame(true, 1, Unpooled.wrappedBuffer(content1)));
channel.writeInbound(new BinaryWebSocketFrame(false, 0, Unpooled.wrappedBuffer(content1)));
channel.writeInbound(new ContinuationWebSocketFrame(false, 0, Unpooled.wrappedBuffer(content2)));
channel.writeInbound(new PingWebSocketFrame(Unpooled.wrappedBuffer(content1)));
channel.writeInbound(new PongWebSocketFrame(Unpooled.wrappedBuffer(content1)));
channel.writeInbound(new ContinuationWebSocketFrame(true, 0, Unpooled.wrappedBuffer(content3)));
assertTrue(channel.finish());
BinaryWebSocketFrame frame = channel.readInbound();
assertTrue(frame.isFinalFragment());
assertEquals(1, frame.rsv());
assertArrayEquals(content1, toBytes(frame.content()));
// ... (95 more lines)
Domain
Subdomains
Classes
Source
Frequently Asked Questions
What does WebSocketFrameAggregatorTest.java do?
WebSocketFrameAggregatorTest.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is WebSocketFrameAggregatorTest.java in the architecture?
WebSocketFrameAggregatorTest.java is located at codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketFrameAggregatorTest.java (domain: Buffer, subdomain: Allocators, directory: codec-http/src/test/java/io/netty/handler/codec/http/websocketx).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free