@@ -0,0 +1,1687 @@
+package cn.strong.fastdfs.client.protocol.request.storage;%0A%0Aimport static java.nio.charset.StandardCharsets.UTF_8;%0Aimport static org.junit.Assert.assertEquals;%0Aimport io.netty.buffer.ByteBuf;%0Aimport io.netty.buffer.ByteBufAllocator;%0Aimport io.netty.buffer.PooledByteBufAllocator;%0A%0Aimport java.nio.charset.Charset;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.junit.Test;%0A%0Aimport cn.strong.fastdfs.client.CommandCodes;%0Aimport cn.strong.fastdfs.client.Consts;%0Aimport cn.strong.fastdfs.model.StoragePath;%0Aimport cn.strong.fastdfs.utils.Utils;%0A%0Apublic class AppendRequestTest %7B%0A%0A%09@Test%0A%09public void test() %7B%0A%09%09Charset charset = UTF_8;%0A%09%09byte%5B%5D bytes = %22%5Cnappend fastdfs%22.getBytes(charset);%0A%09%09StoragePath spath = StoragePath%0A%09%09%09%09.fromFullPath(%22group1/M00/0A/97/wKgURFeI0ZyEeorsAAAAADVhaBw380.inf%22);%0A%09%09AppendRequest request = new AppendRequest(bytes, bytes.length, spath);%0A%0A%09%09ByteBufAllocator alloc = PooledByteBufAllocator.DEFAULT;%0A%09%09List%3CObject%3E out = new ArrayList%3C%3E();%0A%0A%09%09request.encode(alloc, out, charset);%0A%0A%09%09assertEquals(out.size(), 3);%0A%09%09ByteBuf head = (ByteBuf) out.get(0);%0A%09%09long length = head.readLong();%0A%09%09System.out.println(length);%0A%09%09assertEquals(head.readByte(), CommandCodes.STORAGE_PROTO_CMD_APPEND_FILE);%0A%09%09assertEquals(head.readByte(), Consts.ERRNO_OK);%0A%0A%09%09ByteBuf meta = (ByteBuf) out.get(1);%0A%09%09long pathLen = meta.readLong();%0A%09%09long size = meta.readLong();%0A%09%09String path = Utils.readString(meta, (int) pathLen, charset);%0A%09%09System.out.println(path);%0A%0A%09%09ByteBuf content = (ByteBuf) out.get(2);%0A%09%09System.out.println(out.get(2).getClass());%0A%09%09assertEquals(content.readableBytes(), size);%0A%09%09assertEquals(content.toString(charset), %22%5Cnappend fastdfs%22);%0A%09%7D%0A%0A%7D%0A

test for AppendRequest