Package org.apache.mina.common

Examples of org.apache.mina.common.ByteBuffer.clear()


        in.clear();
        in.putString("PQR\r", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("X\r", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
View Full Code Here


        in.clear();
        in.putString("X\r", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("\r\nSTU\r\r\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(2, out.getMessageQueue().size());
        Assert.assertEquals("PQR\rX", out.getMessageQueue().poll());
View Full Code Here

        try
        {
            int readBytes = 0;
            int ret;

            buf.clear();

            try
            {
                while( ( ret = ch.read( buf.buf() ) ) > 0 )
                {
View Full Code Here

                    buf.flip();
                    buf.limit(buf.limit() - matchCount);
                    try {
                        out.write(buf.getString(ctx.getDecoder()));
                    } finally {
                        buf.clear();
                    }
                } else {
                    int overflowPosition = ctx.getOverflowPosition();
                    ctx.reset();
                    throw new BufferDataException(
View Full Code Here

                        buf.flip();
                        buf.limit(buf.limit() - matchCount);
                        try {
                            out.write(buf.getString(ctx.getDecoder()));
                        } finally {
                            buf.clear();
                        }
                    } else {
                        int overflowPosition = ctx.getOverflowPosition();
                        ctx.reset();
                        throw new BufferDataException(
View Full Code Here

        ByteBuffer buf = ByteBuffer.allocate( session.getReadBufferSize() );
        SocketChannel ch = session.getChannel();

        try
        {
            buf.clear();

            int readBytes = 0;
            int ret;

            try
View Full Code Here

        decoder.decode( session, in, out );
        Assert.assertEquals( 1, out.getMessageQueue().size() );
        Assert.assertEquals( "ABC", out.getMessageQueue().pop() );
       
        // Test two decode and one output
        in.clear();
        in.putString( "DEF", encoder );
        in.flip();
        decoder.decode( session, in, out );
        Assert.assertEquals( 0, out.getMessageQueue().size() );
        in.clear();
View Full Code Here

        in.clear();
        in.putString( "DEF", encoder );
        in.flip();
        decoder.decode( session, in, out );
        Assert.assertEquals( 0, out.getMessageQueue().size() );
        in.clear();
        in.putString( "GHI\r\n", encoder );
        in.flip();
        decoder.decode( session, in, out );
        Assert.assertEquals( 1, out.getMessageQueue().size() );
        Assert.assertEquals( "DEFGHI", out.getMessageQueue().pop() );
View Full Code Here

        decoder.decode( session, in, out );
        Assert.assertEquals( 1, out.getMessageQueue().size() );
        Assert.assertEquals( "DEFGHI", out.getMessageQueue().pop() );
       
        // Test one decode and two output
        in.clear();
        in.putString( "JKL\r\nMNO\r\n", encoder );
        in.flip();
        decoder.decode( session, in, out );
        Assert.assertEquals( 2, out.getMessageQueue().size() );
        Assert.assertEquals( "JKL", out.getMessageQueue().pop() );
View Full Code Here

       
        // Test splitted long delimiter
        decoder = new TextLineDecoder(
                Charset.forName( "UTF-8" ),
                new LineDelimiter( "\n\n\n" ) );
        in.clear();
        in.putString( "PQR\n", encoder );
        in.flip();
        decoder.decode( session, in, out );
        Assert.assertEquals( 0, out.getMessageQueue().size() );
        in.clear();
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.