|
|
@ -6,7 +6,9 @@ import io.netty.buffer.ByteBufAllocator |
|
|
|
import io.netty.buffer.Unpooled |
|
|
|
import io.netty.buffer.Unpooled |
|
|
|
import org.junit.jupiter.api.Test |
|
|
|
import org.junit.jupiter.api.Test |
|
|
|
import org.junit.jupiter.api.assertThrows |
|
|
|
import org.junit.jupiter.api.assertThrows |
|
|
|
|
|
|
|
import org.openrs2.buffer.copiedBuffer |
|
|
|
import org.openrs2.buffer.use |
|
|
|
import org.openrs2.buffer.use |
|
|
|
|
|
|
|
import org.openrs2.buffer.wrappedBuffer |
|
|
|
import java.io.EOFException |
|
|
|
import java.io.EOFException |
|
|
|
import java.nio.channels.FileChannel |
|
|
|
import java.nio.channels.FileChannel |
|
|
|
import java.nio.file.Files |
|
|
|
import java.nio.file.Files |
|
|
@ -33,7 +35,7 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -41,7 +43,7 @@ object BufferedFileChannelTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -54,14 +56,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(1, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(1, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS22".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS22").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -74,14 +76,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(1, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(1, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("OOpenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OOpenRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -94,14 +96,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(7, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(7, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2OpenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS2OpenRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -114,14 +116,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(0, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(8, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(8, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2\u0000OpenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS2\u0000OpenRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -134,7 +136,7 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("Hello, world!".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("Hello, world!").use { buf -> |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -142,7 +144,7 @@ object BufferedFileChannelTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer(Files.readAllBytes(path)).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("Hello, world!".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("Hello, world!").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -157,7 +159,7 @@ object BufferedFileChannelTest { |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, READ), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, READ), 8, 8).use { channel -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS2").use { expected -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
|
|
|
|
|
|
|
@ -179,7 +181,7 @@ object BufferedFileChannelTest { |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, READ), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, READ), 8, 8).use { channel -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(14, 14).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(14, 14).use { actual -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2OpenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS2OpenRS2").use { expected -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
@ -225,14 +227,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer(byteArrayOf(1)).use { buf -> |
|
|
|
wrappedBuffer(1).use { buf -> |
|
|
|
channel.write(7, buf, buf.readableBytes()) |
|
|
|
channel.write(7, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(8, 8).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(8, 8).use { actual -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer(byteArrayOf(0, 0, 0, 0, 0, 0, 0, 1)).use { expected -> |
|
|
|
wrappedBuffer(0, 0, 0, 0, 0, 0, 0, 1).use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -246,14 +248,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -267,14 +269,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(6, 6).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(6, 6).use { actual -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("OpenRS".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenRS").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -288,14 +290,14 @@ object BufferedFileChannelTest { |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
val path = fs.getPath("/test.dat") |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("OpenRS2".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("OpenRS2").use { buf -> |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
channel.write(0, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(6, 6).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(6, 6).use { actual -> |
|
|
|
channel.read(1, actual, actual.writableBytes()) |
|
|
|
channel.read(1, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("penRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("penRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -311,14 +313,14 @@ object BufferedFileChannelTest { |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("Hello".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("Hello").use { buf -> |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(14, 14).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(14, 14).use { actual -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("OpenHelloenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenHelloenRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -334,14 +336,14 @@ object BufferedFileChannelTest { |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("Hello".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("Hello").use { buf -> |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("OpenHel".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("OpenHel").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -357,14 +359,14 @@ object BufferedFileChannelTest { |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("Hello".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("Hello").use { buf -> |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(7, 7).use { actual -> |
|
|
|
channel.read(7, actual, actual.writableBytes()) |
|
|
|
channel.read(7, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("loenRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("loenRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -380,14 +382,14 @@ object BufferedFileChannelTest { |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
Files.write(path, "OpenRS2OpenRS2".toByteArray()) |
|
|
|
|
|
|
|
|
|
|
|
BufferedFileChannel(FileChannel.open(path, READ, WRITE), 4, 8).use { channel -> |
|
|
|
BufferedFileChannel(FileChannel.open(path, READ, WRITE), 4, 8).use { channel -> |
|
|
|
Unpooled.wrappedBuffer("Hello".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("Hello").use { buf -> |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
channel.write(4, buf, buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
channel.read(0, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("Open".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("Open").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -395,7 +397,7 @@ object BufferedFileChannelTest { |
|
|
|
ByteBufAllocator.DEFAULT.buffer(5, 5).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(5, 5).use { actual -> |
|
|
|
channel.read(9, actual, actual.writableBytes()) |
|
|
|
channel.read(9, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("enRS2".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("enRS2").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -414,19 +416,19 @@ object BufferedFileChannelTest { |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("RS2O".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("RS2O").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ABCD".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("ABCD").use { buf -> |
|
|
|
channel.write(4, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(4, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ABCD".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("ABCD").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -445,19 +447,19 @@ object BufferedFileChannelTest { |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("RS2O".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("RS2O").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ABC".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("ABC").use { buf -> |
|
|
|
channel.write(4, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(4, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ABCO".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("ABCO").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -476,19 +478,19 @@ object BufferedFileChannelTest { |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("RS2O".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("RS2O").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("BCD".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("BCD").use { buf -> |
|
|
|
channel.write(5, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(5, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("RBCD".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("RBCD").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -507,19 +509,19 @@ object BufferedFileChannelTest { |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("RS2O".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("RS2O").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ZABCD".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("ZABCD").use { buf -> |
|
|
|
channel.write(3, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(3, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ABCD".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("ABCD").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -538,19 +540,19 @@ object BufferedFileChannelTest { |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("RS2O".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("RS2O").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ABCDZ".toByteArray()).use { buf -> |
|
|
|
copiedBuffer("ABCDZ").use { buf -> |
|
|
|
channel.write(4, buf.slice(), buf.readableBytes()) |
|
|
|
channel.write(4, buf.slice(), buf.readableBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
ByteBufAllocator.DEFAULT.buffer(4, 4).use { actual -> |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
channel.read(4, actual, actual.writableBytes()) |
|
|
|
|
|
|
|
|
|
|
|
Unpooled.wrappedBuffer("ABCD".toByteArray()).use { expected -> |
|
|
|
copiedBuffer("ABCD").use { expected -> |
|
|
|
assertEquals(expected, actual) |
|
|
|
assertEquals(expected, actual) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|