Examples of IoHandlerAdapter


Examples of org.apache.mina.common.IoHandlerAdapter

* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev: 555855 $, $Date: 2007-07-13 12:19:00 +0900 (Fri, 13 Jul 2007) $
*/
public class IoAcceptorFactoryBeanTest extends TestCase {
    public void testBindUnbind() throws Exception {
        IoHandler handler1 = new IoHandlerAdapter();
        IoHandler handler2 = new IoHandlerAdapter();
        IoHandler handler3 = new IoHandlerAdapter();
        IoServiceConfig config1 = (IoServiceConfig) MockControl.createControl(
                IoServiceConfig.class).getMock();
        IoServiceConfig config2 = (IoServiceConfig) MockControl.createControl(
                IoServiceConfig.class).getMock();
        MockControl mockIoAcceptor = MockControl
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

        if (LOG.isDebugEnabled()) {
            LOG.debug("Binding to server address: " + address + " using acceptor: " + acceptor);
        }

        IoHandler handler = new IoHandlerAdapter() {
            @Override
            public void messageReceived(IoSession session, Object object) throws Exception {
                getProcessor().process(endpoint.createExchange(session, object));
            }
        };
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

        SocketAddress address = endpoint.getAddress();
        IoConnector connector = endpoint.getConnector();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating connector to address: " + address + " using connector: " + connector);
        }
        IoHandler ioHandler = new IoHandlerAdapter() {
            @Override
            public void messageReceived(IoSession ioSession, Object object) throws Exception {
                super.messageReceived(ioSession, object);
                /** TODO */
            }
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

*/
public class IoAcceptorFactoryBeanTest extends TestCase
{
    public void testBindUnbind() throws Exception
    {
        IoHandler handler1 = new IoHandlerAdapter();
        IoHandler handler2 = new IoHandlerAdapter();
        IoHandler handler3 = new IoHandlerAdapter();
        IoServiceConfig config1 =
            ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
        IoServiceConfig config2 =
            ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
        MockControl mockIoAcceptor = MockControl.createControl( IoAcceptor.class );
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

            // ignore
        }
    }

    public void testAnonymousBind() throws Exception {
        acceptor.bind(null, new IoHandlerAdapter());
        Assert.assertEquals(1, acceptor.getManagedServiceAddresses().size());
        acceptor.unbindAll();
        Thread.sleep(500);
        Assert.assertEquals(0, acceptor.getManagedServiceAddresses().size());

        acceptor.bind(createSocketAddress(0), new IoHandlerAdapter());
        Assert.assertEquals(1, acceptor.getManagedServiceAddresses().size());
        SocketAddress address = acceptor.getManagedServiceAddresses()
                .iterator().next();
        Assert.assertTrue(getPort(address) != 0);
        acceptor.unbind(address);
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

        expectedConfig.getFilterChain().addLast("mock", mockFilter);
        acceptor.bind(new InetSocketAddress(port), mockHandler, expectedConfig);

        try {
            ConnectFuture future = connector.connect(new InetSocketAddress(
                    "localhost", port), new IoHandlerAdapter());
            future.join();

            WriteFuture writeFuture = future.getSession().write(
                    ByteBuffer.allocate(16).putInt(0).flip());
            writeFuture.join();
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

        IoConnector connector = new SocketConnector();
        IoSession[] sessions = new IoSession[5];
        for (int i = 0; i < sessions.length; i++) {
            ConnectFuture future = connector.connect(new InetSocketAddress(
                    "localhost", port), new IoHandlerAdapter());
            future.join();
            sessions[i] = future.getSession();
            Assert.assertTrue(sessions[i].isConnected());
        }
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

        IoConnector connector = new VmPipeConnector();
        connector.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
        //connector.getFilterChain().addLast( "logger", new LoggingFilter() );

        acceptor.bind(new VmPipeAddress(1), new IoHandlerAdapter() {
            public void sessionOpened(IoSession session) throws Exception {
                session.write("B");
            }

            public void messageSent(IoSession session, Object message)
                    throws Exception {
                session.close();
            }
        });

        final StringBuffer actual = new StringBuffer();

        ConnectFuture future = connector.connect(new VmPipeAddress(1),
                new IoHandlerAdapter() {

                    public void messageReceived(IoSession session,
                            Object message) throws Exception {
                        actual.append(message);
                    }
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

        connector.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
        //connector.getFilterChain().addLast( "logger", new LoggingFilter() );

        final StringBuffer actual = new StringBuffer();

        acceptor.bind(new VmPipeAddress(1), new IoHandlerAdapter() {

            public void messageReceived(IoSession session, Object message)
                    throws Exception {
                actual.append(message);
            }

            public void sessionClosed(IoSession session) throws Exception {
                actual.append("C");
            }

            public void sessionOpened(IoSession session) throws Exception {
                actual.append("A");
            }

        });

        ConnectFuture future = connector.connect(new VmPipeAddress(1),
                new IoHandlerAdapter() {
                    public void sessionOpened(IoSession session)
                            throws Exception {
                        session.write("B");
                    }
View Full Code Here

Examples of org.apache.mina.common.IoHandlerAdapter

            // ignore
        }
    }

    public void testAnonymousBind() throws Exception {
        acceptor.bind(null, new IoHandlerAdapter());
        Assert.assertEquals(1, acceptor.getManagedServiceAddresses().size());
        acceptor.unbindAll();
        Thread.sleep(500);
        Assert.assertEquals(0, acceptor.getManagedServiceAddresses().size());

        acceptor.bind(createSocketAddress(0), new IoHandlerAdapter());
        Assert.assertEquals(1, acceptor.getManagedServiceAddresses().size());
        SocketAddress address = acceptor.getManagedServiceAddresses()
                .iterator().next();
        Assert.assertTrue(getPort(address) != 0);
        acceptor.unbind(address);
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.