Package org.apache.mina.common

Examples of org.apache.mina.common.IoSession


*/
public class ObjectSerializationTest extends TestCase {
    public void testEncoder() throws Exception {
        final String expected = "1234";

        IoSession session = new MockIoSession();
        SimpleProtocolEncoderOutput out = new SimpleProtocolEncoderOutput() {
            protected WriteFuture doFlush(ByteBuffer buf) {
                return null;
            }
        };
View Full Code Here


        assertEquals(expected, actual);

        // Test ProtocolDecoder
        ProtocolDecoder decoder = new ObjectSerializationDecoder();
        MockProtocolDecoderOutput decoderOut = new MockProtocolDecoderOutput();
        IoSession session = new MockIoSession();
        decoder.decode(session, in.duplicate(), decoderOut);

        Assert.assertEquals(expected, decoderOut.result.get(0));
        Assert.assertEquals(1, decoderOut.result.size());
    }
View Full Code Here

        }

        Zlib deflater = new Zlib(compressionLevel, Zlib.MODE_DEFLATER);
        Zlib inflater = new Zlib(compressionLevel, Zlib.MODE_INFLATER);

        IoSession session = parent.getSession();

        session.setAttribute(DEFLATER, deflater);
        session.setAttribute(INFLATER, inflater);
    }
View Full Code Here

    }

    public void onPostRemove(IoFilterChain parent, String name,
            NextFilter nextFilter) throws Exception {
        super.onPostRemove(parent, name, nextFilter);
        IoSession session = parent.getSession();
        if (session == null) {
            return;
        }

        Zlib inflater = (Zlib) session.getAttribute(INFLATER);
        Zlib deflater = (Zlib) session.getAttribute(DEFLATER);
        if (deflater != null) {
            deflater.cleanUp();
        }

        if (inflater != null) {
View Full Code Here

    public void testNormalDecode() throws Exception {
        TextLineDecoder decoder = new TextLineDecoder(Charset.forName("UTF-8"),
                LineDelimiter.WINDOWS);

        CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
        IoSession session = new DummySession();
        TestDecoderOutput out = new TestDecoderOutput();
        ByteBuffer in = ByteBuffer.allocate(16);

        // Test one decode and one output
        in.putString("ABC\r\n", encoder);
View Full Code Here

    public void testAutoDecode() throws Exception {
        TextLineDecoder decoder = new TextLineDecoder(Charset.forName("UTF-8"),
                LineDelimiter.AUTO);

        CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
        IoSession session = new DummySession();
        TestDecoderOutput out = new TestDecoderOutput();
        ByteBuffer in = ByteBuffer.allocate(16);

        // Test one decode and one output
        in.putString("ABC\r\n", encoder);
View Full Code Here

        TextLineDecoder decoder = new TextLineDecoder(Charset.forName("UTF-8"),
                LineDelimiter.AUTO);
        decoder.setMaxLineLength(3);

        CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
        IoSession session = new DummySession();
        TestDecoderOutput out = new TestDecoderOutput();
        ByteBuffer in = ByteBuffer.allocate(16);

        // Make sure the overflow exception is not thrown until
        // the delimiter is encountered.
View Full Code Here

        assertNull(future.getSession());

        TestThread thread = new TestThread(future);
        thread.start();

        IoSession session = new BaseIoSession() {
            public IoHandler getHandler() {
                return null;
            }

            public IoFilterChain getFilterChain() {
View Full Code Here

    }

    public void testEncode() throws Exception {
        TextLineEncoder encoder = new TextLineEncoder(Charset.forName("UTF-8"),
                LineDelimiter.WINDOWS);
        IoSession session = new DummySession();
        SimpleProtocolEncoderOutput out = new SimpleProtocolEncoderOutput() {
            @Override
            protected WriteFuture doFlush(ByteBuffer buf) {
                return null;
            }
View Full Code Here

        }

        Zlib deflater = new Zlib(compressionLevel, Zlib.MODE_DEFLATER);
        Zlib inflater = new Zlib(compressionLevel, Zlib.MODE_INFLATER);

        IoSession session = parent.getSession();

        session.setAttribute(DEFLATER, deflater);
        session.setAttribute(INFLATER, inflater);
    }
View Full Code Here

TOP

Related Classes of org.apache.mina.common.IoSession

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.