Package org.apache.mina.codec

Examples of org.apache.mina.codec.IoBuffer


    @Test
    public void testTruncatedValues() {
        for (int value : new int[] { 0, 1, 127, 128, 65536, 198649, Integer.MAX_VALUE }) {

            IoBuffer buffer = IoBuffer.wrap(encoder.encode(value));

            for (int i = 0; i < buffer.remaining(); i++) {
                IoBuffer partialBuffer = buffer.slice();
                partialBuffer.limit(partialBuffer.position() + i);
                try {
                    assertNull(decoder.decode(partialBuffer));
                } catch (ProtocolDecoderException e) {
                    fail("Should not throw exception");
                }
View Full Code Here


            ByteBuffer buffer = encoder.encode(value);

            for (int i = 1; i < 5; i++) {
                int size = buffer.remaining() + i;
                IoBuffer extendedBuffer = IoBuffer.wrap(ByteBuffer.allocate(size));
                int start = extendedBuffer.position();
                extendedBuffer.put(buffer.slice());
                extendedBuffer.position(start);
                extendedBuffer.limit(start + size);

                try {
                    decoder.decode(extendedBuffer);
                    assertEquals(i, extendedBuffer.remaining());
                } catch (ProtocolDecoderException e) {
                    fail("Should not throw exception");
                }
            }
        }
View Full Code Here

        if (nextBlockSize.getValue() == null) {
            nextBlockSize.setValue(sizeDecoder.decode(input));
        }

        if (nextBlockSize.isDefined() && (input.remaining() >= nextBlockSize.getValue())) {
            IoBuffer buffer = input.slice();
            buffer.limit(buffer.position() + nextBlockSize.getValue());

            output = payloadDecoder.decode(buffer);
            nextBlockSize.reset();
        }
View Full Code Here

TOP

Related Classes of org.apache.mina.codec.IoBuffer

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.