testReadBytesAndWriteBytesWithFileChannel() — netty Function Reference
Architecture documentation for the testReadBytesAndWriteBytesWithFileChannel() function in AbstractByteBufTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5a2f4dd3_5572_26e1_fb9c_c53ed557cd0f["testReadBytesAndWriteBytesWithFileChannel()"] 6540f2d1_cdad_6705_dd1d_9a24e2e53242["AbstractByteBufTest"] 5a2f4dd3_5572_26e1_fb9c_c53ed557cd0f -->|defined in| 6540f2d1_cdad_6705_dd1d_9a24e2e53242 3b376070_a080_cb6d_9a78_e8acbbdd5c2c["close()"] 5a2f4dd3_5572_26e1_fb9c_c53ed557cd0f -->|calls| 3b376070_a080_cb6d_9a78_e8acbbdd5c2c style 5a2f4dd3_5572_26e1_fb9c_c53ed557cd0f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java lines 5812–5853
@Test
public void testReadBytesAndWriteBytesWithFileChannel() throws IOException {
File file = PlatformDependent.createTempFile("file-channel", ".tmp", null);
RandomAccessFile randomAccessFile = null;
try {
randomAccessFile = new RandomAccessFile(file, "rw");
FileChannel channel = randomAccessFile.getChannel();
// channelPosition should never be changed
long channelPosition = channel.position();
byte[] bytes = {'a', 'b', 'c', 'd'};
int len = bytes.length;
ByteBuf buffer = newBuffer(len);
buffer.resetReaderIndex();
buffer.resetWriterIndex();
buffer.writeBytes(bytes);
int oldReaderIndex = buffer.readerIndex();
assertEquals(len, buffer.readBytes(channel, 10, len));
assertEquals(oldReaderIndex + len, buffer.readerIndex());
assertEquals(channelPosition, channel.position());
ByteBuf buffer2 = newBuffer(len);
buffer2.resetReaderIndex();
buffer2.resetWriterIndex();
int oldWriterIndex = buffer2.writerIndex();
assertEquals(len, buffer2.writeBytes(channel, 10, len));
assertEquals(channelPosition, channel.position());
assertEquals(oldWriterIndex + len, buffer2.writerIndex());
assertEquals('a', buffer2.getByte(0));
assertEquals('b', buffer2.getByte(1));
assertEquals('c', buffer2.getByte(2));
assertEquals('d', buffer2.getByte(3));
buffer.release();
buffer2.release();
} finally {
if (randomAccessFile != null) {
randomAccessFile.close();
}
file.delete();
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does testReadBytesAndWriteBytesWithFileChannel() do?
testReadBytesAndWriteBytesWithFileChannel() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java.
Where is testReadBytesAndWriteBytesWithFileChannel() defined?
testReadBytesAndWriteBytesWithFileChannel() is defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java at line 5812.
What does testReadBytesAndWriteBytesWithFileChannel() call?
testReadBytesAndWriteBytesWithFileChannel() calls 1 function(s): close.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free