Package com.taobao.gecko.core.buffer

Examples of com.taobao.gecko.core.buffer.IoBuffer.position()



    @Test
    public void testMakeHead() throws Exception {
        final IoBuffer head = this.fileMessageSet.makeHead(-1999, 100);
        assertEquals(0, head.position());
        assertTrue(head.hasRemaining());
        assertEquals("value 100 -1999\r\n", new String(head.array()));
    }

View Full Code Here


    @Test
    public void testEncode() {
        final SyncCommand putCommand = new SyncCommand("test", 1, "hello".getBytes(), 0, 9999L, 777, 0);
        final IoBuffer buf = putCommand.encode();
        assertEquals(0, buf.position());
        assertEquals("sync test 1 5 0 9999 777 0\r\nhello", new String(buf.array()));
    }

}
View Full Code Here

    @Test
    public void testEncode_HasTransactionId() {
        final TransactionId id = new LocalTransactionId("test", 1);
        final PutCommand putCommand = new PutCommand("test", 1, "hello".getBytes(), id, 0, 0);
        final IoBuffer buf = putCommand.encode();
        assertEquals(0, buf.position());
        assertEquals("put test 1 5 0 -1 TX:test:1 0\r\nhello", new String(buf.array()));
    }


    @Test
View Full Code Here

    @Test
    public void testEncode_NoTransactionId() {
        final PutCommand putCommand = new PutCommand("test", 1, "hello".getBytes(), null, 0, 0);
        final IoBuffer buf = putCommand.encode();
        assertEquals(0, buf.position());
        assertEquals("put test 1 5 0 -1 0\r\nhello", new String(buf.array()));
    }
}
View Full Code Here

public class QuitCommandUnitTest {
    @Test
    public void testEncode() {
        final QuitCommand cmd = new QuitCommand();
        final IoBuffer buf = cmd.encode();
        assertEquals(0, buf.position());
        assertEquals("quit\r\n", new String(buf.array()));
    }

}
View Full Code Here

public class BooleanCommandUnitTest {
    @Test
    public void testEncodeWithMessage() {
        final BooleanCommand cmd = new BooleanCommand(HttpStatus.NotFound, "not found", 99);
        final IoBuffer buf = cmd.encode();
        assertEquals(0, buf.position());
        assertEquals("result 404 9 99\r\nnot found", new String(buf.array()));
    }


    @Test
View Full Code Here

    @Test
    public void testEncodeWithoutMessage() {
        final BooleanCommand cmd = new BooleanCommand(HttpStatus.NotFound, null, 99);
        final IoBuffer buf = cmd.encode();
        assertEquals(0, buf.position());
        assertEquals("result 404 0 99\r\n", new String(buf.array()));
    }
}
View Full Code Here

public class DataCommandCommandUnitTest {
    @Test
    public void testEncodeWithMessage() {
        final DataCommand cmd = new DataCommand("hello".getBytes(), 99, true);
        final IoBuffer buf = cmd.encode();
        assertEquals(0, buf.position());
        assertEquals("value 5 99\r\nhello", new String(buf.array()));
    }
}
View Full Code Here

public class StatsCommandUnitTest {
    @Test
    public void testEncodeEmptyItem() {
        final StatsCommand cmd = new StatsCommand(-1000, null);
        final IoBuffer buf = cmd.encode();
        assertEquals(0, buf.position());
        assertEquals("stats  -1000\r\n", new String(buf.array()));
    }


    @Test
View Full Code Here

    @Test
    public void testEncodeWithItem() {
        final StatsCommand cmd = new StatsCommand(-1000, "topics");
        final IoBuffer buf = cmd.encode();
        assertEquals(0, buf.position());
        assertEquals("stats topics -1000\r\n", new String(buf.array()));
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.