Package org.apache.mina.codec.textline.TextLineDecoder

Examples of org.apache.mina.codec.textline.TextLineDecoder.Context


public class AutoTextLineDecoderTest {

    @Test
    public void testThatEmptyBufferReturnsEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder();
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.allocate(0), context);
        assertNull(results);
    }
View Full Code Here


    }

    @Test
    public void testThatNonLineTerminatedStringReturnsEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder();
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.wrap("a string".getBytes()), context);
        assertNull(results);
        assertEquals(8, context.getBuffer().position());
    }
View Full Code Here

    }

    @Test
    public void testThatUnixLineTerminatedStringReturnsNonEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder();
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.wrap("a string\n".getBytes()), context);
        assertEquals("a string", results);
        assertEquals(0, context.getBuffer().position());
    }
View Full Code Here

    }

    @Test
    public void testThatWindowsLineTerminatedStringReturnsNonEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder();
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.wrap("a string\r\n".getBytes()), context);
        assertNotNull(results);
        assertEquals("a string", results);
        assertEquals(0, context.getBuffer().position());
    }
View Full Code Here

    }

    @Test
    public void testThatContextIsMaintainedBetweenMessages() {
        TextLineDecoder decoder = new TextLineDecoder();
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.wrap("a string\na".getBytes()), context);
        assertNotNull(results);
        assertEquals("a string", results);
        assertEquals(1, context.getBuffer().position());
        results = decoder.decode(ByteBuffer.wrap(" string\n".getBytes()), context);
        assertNotNull(results);
        assertEquals("a string", results);
        assertEquals(0, context.getBuffer().position());
    }
View Full Code Here

    }

    @Test
    public void testThatUnixLineTerminatedLongStringReturnsNonEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder();
        Context context = decoder.createDecoderState();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < 100; ++i) {
            sb.append("a string");
        }
        String results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\n").getBytes()), context);
        assertNotNull(results);
        assertEquals(sb.toString(), results);
        assertEquals(0, context.getBuffer().position());
    }
View Full Code Here

    }

    @Test
    public void testThatWindowsLineTerminatedLongStringReturnsNonEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder();
        Context context = decoder.createDecoderState();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < 100; ++i) {
            sb.append("a string");
        }
        String results = decoder.decode(ByteBuffer.wrap((sb.toString() + "\r\n").getBytes()), context);
        assertNotNull(results);
        assertEquals(sb.toString(), results);
        assertEquals(0, context.getBuffer().position());
    }
View Full Code Here

public class UnixTextLineDecoderTest {

    @Test
    public void testThatEmptyBufferReturnsEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.allocate(0), context);
        assertNull(results);
    }
View Full Code Here

    }

    @Test
    public void testThatNonLineTerminatedStringReturnsEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.wrap("a string".getBytes()), context);
        assertNull(results);
        assertEquals(8, context.getBuffer().position());
    }
View Full Code Here

    }

    @Test
    public void testThatUnixLineTerminatedStringReturnsNonEmptyResult() {
        TextLineDecoder decoder = new TextLineDecoder(LineDelimiter.UNIX);
        Context context = decoder.createDecoderState();
        String results = decoder.decode(ByteBuffer.wrap("a string\n".getBytes()), context);
        assertNotNull(results);
        assertEquals("a string", results);
        assertEquals(0, context.getBuffer().position());
    }
View Full Code Here

TOP

Related Classes of org.apache.mina.codec.textline.TextLineDecoder.Context

Copyright © 2018 www.massapicom. 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.