testGetBytesAndSetBytesWithFileChannel() — netty Function Reference
Architecture documentation for the testGetBytesAndSetBytesWithFileChannel() function in AbstractByteBufTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 864baa57_b4b0_74ef_ec3a_853bb1a3c152["testGetBytesAndSetBytesWithFileChannel()"] 6540f2d1_cdad_6705_dd1d_9a24e2e53242["AbstractByteBufTest"] 864baa57_b4b0_74ef_ec3a_853bb1a3c152 -->|defined in| 6540f2d1_cdad_6705_dd1d_9a24e2e53242 3b376070_a080_cb6d_9a78_e8acbbdd5c2c["close()"] 864baa57_b4b0_74ef_ec3a_853bb1a3c152 -->|calls| 3b376070_a080_cb6d_9a78_e8acbbdd5c2c style 864baa57_b4b0_74ef_ec3a_853bb1a3c152 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java lines 5855–5898
@Test
public void testGetBytesAndSetBytesWithFileChannel() 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.getBytes(oldReaderIndex, channel, 10, len));
assertEquals(oldReaderIndex, buffer.readerIndex());
assertEquals(channelPosition, channel.position());
ByteBuf buffer2 = newBuffer(len);
buffer2.resetReaderIndex();
buffer2.resetWriterIndex();
int oldWriterIndex = buffer2.writerIndex();
assertEquals(buffer2.setBytes(oldWriterIndex, channel, 10, len), len);
assertEquals(channelPosition, channel.position());
assertEquals(oldWriterIndex, buffer2.writerIndex());
assertEquals('a', buffer2.getByte(oldWriterIndex));
assertEquals('b', buffer2.getByte(oldWriterIndex + 1));
assertEquals('c', buffer2.getByte(oldWriterIndex + 2));
assertEquals('d', buffer2.getByte(oldWriterIndex + 3));
buffer.release();
buffer2.release();
} finally {
if (randomAccessFile != null) {
randomAccessFile.close();
}
file.delete();
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does testGetBytesAndSetBytesWithFileChannel() do?
testGetBytesAndSetBytesWithFileChannel() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java.
Where is testGetBytesAndSetBytesWithFileChannel() defined?
testGetBytesAndSetBytesWithFileChannel() is defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java at line 5855.
What does testGetBytesAndSetBytesWithFileChannel() call?
testGetBytesAndSetBytesWithFileChannel() 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