Package com.google.code.yanf4j.core.CodecFactory

Examples of com.google.code.yanf4j.core.CodecFactory.Encoder.encode()


    @Test
    public void testEncodeNormal() throws Exception {
        Encoder encoder = this.codecFactory.getEncoder();
        Assert.assertNotNull(encoder);
        IoBuffer buffer = encoder.encode(IoBuffer.wrap("hello".getBytes("utf-8")), null);
        Assert.assertNotNull(buffer);
        Assert.assertTrue(buffer.hasRemaining());
        Assert.assertArrayEquals("hello".getBytes("utf-8"), buffer.array());

    }
View Full Code Here



    @Test
    public void testEncodeEmpty() throws Exception {
        Encoder encoder = this.codecFactory.getEncoder();
        Assert.assertNull(encoder.encode(null, null));
        Assert.assertEquals(IoBuffer.allocate(0), encoder.encode(IoBuffer.allocate(0), null));
    }


    @Test
View Full Code Here

    @Test
    public void testEncodeEmpty() throws Exception {
        Encoder encoder = this.codecFactory.getEncoder();
        Assert.assertNull(encoder.encode(null, null));
        Assert.assertEquals(IoBuffer.allocate(0), encoder.encode(IoBuffer.allocate(0), null));
    }


    @Test
    public void decodeNormal() throws Exception {
View Full Code Here

    @Test
    public void decodeNormal() throws Exception {
        Encoder encoder = this.codecFactory.getEncoder();
        Assert.assertNotNull(encoder);
        IoBuffer buffer = encoder.encode(IoBuffer.wrap("hello".getBytes("utf-8")), null);

        IoBuffer decodeBuffer = (IoBuffer) this.codecFactory.getDecoder().decode(buffer, null);
        Assert.assertEquals(IoBuffer.wrap("hello".getBytes("utf-8")), decodeBuffer);
    }
View Full Code Here

    @Test
    public void testEncodeNormal() throws Exception {
        Encoder encoder = this.textLineCodecFactory.getEncoder();
        Assert.assertNotNull(encoder);
        IoBuffer buffer = encoder.encode("hello", null);
        Assert.assertNotNull(buffer);
        Assert.assertTrue(buffer.hasRemaining());
        Assert.assertArrayEquals("hello\r\n".getBytes("utf-8"), buffer.array());

    }
View Full Code Here


    @Test
    public void testEncodeEmpty() throws Exception {
        Encoder encoder = this.textLineCodecFactory.getEncoder();
        Assert.assertNull(encoder.encode(null, null));
        Assert.assertEquals(TextLineCodecFactory.SPLIT, encoder.encode("", null));
    }


    @Test
View Full Code Here

    @Test
    public void testEncodeEmpty() throws Exception {
        Encoder encoder = this.textLineCodecFactory.getEncoder();
        Assert.assertNull(encoder.encode(null, null));
        Assert.assertEquals(TextLineCodecFactory.SPLIT, encoder.encode("", null));
    }


    @Test
    public void decodeNormal() throws Exception {
View Full Code Here

    @Test
    public void decodeNormal() throws Exception {
        Encoder encoder = this.textLineCodecFactory.getEncoder();
        Assert.assertNotNull(encoder);
        IoBuffer buffer = encoder.encode("hello", null);

        String str = (String) this.textLineCodecFactory.getDecoder().decode(buffer, null);
        Assert.assertEquals("hello", str);
    }
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.