Package org.apache.mina.common

Examples of org.apache.mina.common.IoServiceListener


    public void testServiceLifecycle() throws Exception {
        IoServiceListenerSupport support = new IoServiceListenerSupport();

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Test activation
        listener.serviceActivated(null, ADDRESS, null, null);

        listenerControl.replay();

        support.add(listener);
        support.fireServiceActivated(null, ADDRESS, null, null);

        listenerControl.verify();

        Assert.assertEquals(1, support.getManagedServiceAddresses().size());
        Assert.assertTrue(support.getManagedServiceAddresses()
                .contains(ADDRESS));

        // Test deactivation & other side effects
        listenerControl.reset();
        listener.serviceDeactivated(null, ADDRESS, null, null);

        listenerControl.replay();
        //// Activate more than once
        support.fireServiceActivated(null, ADDRESS, null, null);
        //// Deactivate
View Full Code Here


        IoFilterChain chain = (IoFilterChain) chainControl.getMock();
        session.setFilterChain(chain);

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Test creation
        listener.sessionCreated(session);
        chain.fireSessionCreated(session);
        chain.fireSessionOpened(session);

        listenerControl.replay();
        chainControl.replay();

        support.add(listener);
        support.fireSessionCreated(session);

        listenerControl.verify();
        chainControl.verify();

        Assert.assertEquals(1, support.getManagedSessions(ADDRESS).size());
        Assert
                .assertTrue(support.getManagedSessions(ADDRESS).contains(
                        session));

        // Test destruction & other side effects
        listenerControl.reset();
        chainControl.reset();
        chain.fireSessionClosed(session);
        listener.sessionDestroyed(session);

        listenerControl.replay();
        //// Activate more than once
        support.fireSessionCreated(session);
        //// Deactivate
View Full Code Here

        IoFilterChain chain = (IoFilterChain) chainControl.getMock();
        session.setFilterChain(chain);

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Activate a service and create a session.
        listener.serviceActivated(acceptor, ADDRESS, null, config);
        listener.sessionCreated(session);
        chain.fireSessionCreated(session);
        chain.fireSessionOpened(session);

        listenerControl.replay();
        chainControl.replay();

        support.add(listener);
        support.fireServiceActivated(acceptor, ADDRESS, null, config);
        support.fireSessionCreated(session);

        listenerControl.verify();
        chainControl.verify();

        // Deactivate a service and make sure the session is closed & destroyed.
        listenerControl.reset();
        chainControl.reset();

        listener.serviceDeactivated(acceptor, ADDRESS, null, config);
        configControl.expectAndReturn(config.isDisconnectOnUnbind(), true);
        listener.sessionDestroyed(session);
        chain.fireSessionClosed(session);

        listenerControl.replay();
        configControl.replay();
        chainControl.replay();
View Full Code Here

        IoFilterChain chain = (IoFilterChain) chainControl.getMock();
        session.setFilterChain(chain);

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Creating a session should activate a service automatically.
        listener.serviceActivated(connector, ADDRESS, null, null);
        listener.sessionCreated(session);
        chain.fireSessionCreated(session);
        chain.fireSessionOpened(session);

        listenerControl.replay();
        chainControl.replay();

        support.add(listener);
        support.fireSessionCreated(session);

        listenerControl.verify();
        chainControl.verify();

        // Destroying a session should deactivate a service automatically.
        listenerControl.reset();
        chainControl.reset();
        listener.sessionDestroyed(session);
        chain.fireSessionClosed(session);
        listener.serviceDeactivated(connector, ADDRESS, null, null);

        listenerControl.replay();
        chainControl.replay();

        support.fireSessionDestroyed(session);
View Full Code Here

    public void testServiceLifecycle() throws Exception {
        IoServiceListenerSupport support = new IoServiceListenerSupport();

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Test activation
        listener.serviceActivated(null, ADDRESS, null, null);

        listenerControl.replay();

        support.add(listener);
        support.fireServiceActivated(null, ADDRESS, null, null);

        listenerControl.verify();

        Assert.assertEquals(1, support.getManagedServiceAddresses().size());
        Assert.assertTrue(support.getManagedServiceAddresses()
                .contains(ADDRESS));

        // Test deactivation & other side effects
        listenerControl.reset();
        listener.serviceDeactivated(null, ADDRESS, null, null);

        listenerControl.replay();
        //// Activate more than once
        support.fireServiceActivated(null, ADDRESS, null, null);
        //// Deactivate
View Full Code Here

        IoFilterChain chain = (IoFilterChain) chainControl.getMock();
        session.setFilterChain(chain);

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Test creation
        listener.sessionCreated(session);
        chain.fireSessionCreated(session);
        chain.fireSessionOpened(session);

        listenerControl.replay();
        chainControl.replay();

        support.add(listener);
        support.fireSessionCreated(session);

        listenerControl.verify();
        chainControl.verify();

        Assert.assertEquals(1, support.getManagedSessions(ADDRESS).size());
        Assert
                .assertTrue(support.getManagedSessions(ADDRESS).contains(
                        session));

        // Test destruction & other side effects
        listenerControl.reset();
        chainControl.reset();
        chain.fireSessionClosed(session);
        listener.sessionDestroyed(session);

        listenerControl.replay();
        //// Activate more than once
        support.fireSessionCreated(session);
        //// Deactivate
View Full Code Here

        IoFilterChain chain = (IoFilterChain) chainControl.getMock();
        session.setFilterChain(chain);

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Activate a service and create a session.
        listener.serviceActivated(acceptor, ADDRESS, null, config);
        listener.sessionCreated(session);
        chain.fireSessionCreated(session);
        chain.fireSessionOpened(session);

        listenerControl.replay();
        chainControl.replay();

        support.add(listener);
        support.fireServiceActivated(acceptor, ADDRESS, null, config);
        support.fireSessionCreated(session);

        listenerControl.verify();
        chainControl.verify();

        // Deactivate a service and make sure the session is closed & destroyed.
        listenerControl.reset();
        chainControl.reset();

        listener.serviceDeactivated(acceptor, ADDRESS, null, config);
        configControl.expectAndReturn(config.isDisconnectOnUnbind(), true);
        listener.sessionDestroyed(session);
        chain.fireSessionClosed(session);

        listenerControl.replay();
        configControl.replay();
        chainControl.replay();
View Full Code Here

        IoFilterChain chain = (IoFilterChain) chainControl.getMock();
        session.setFilterChain(chain);

        MockControl listenerControl = MockControl
                .createStrictControl(IoServiceListener.class);
        IoServiceListener listener = (IoServiceListener) listenerControl
                .getMock();

        // Creating a session should activate a service automatically.
        listener.serviceActivated(connector, ADDRESS, null, null);
        listener.sessionCreated(session);
        chain.fireSessionCreated(session);
        chain.fireSessionOpened(session);

        listenerControl.replay();
        chainControl.replay();

        support.add(listener);
        support.fireSessionCreated(session);

        listenerControl.verify();
        chainControl.verify();

        // Destroying a session should deactivate a service automatically.
        listenerControl.reset();
        chainControl.reset();
        listener.sessionDestroyed(session);
        chain.fireSessionClosed(session);
        listener.serviceDeactivated(connector, ADDRESS, null, null);

        listenerControl.replay();
        chainControl.replay();

        support.fireSessionDestroyed(session);
View Full Code Here

    public void testServiceLifecycle() throws Exception
    {
        IoServiceListenerSupport support = new IoServiceListenerSupport();
   
        MockControl listenerControl = MockControl.createStrictControl( IoServiceListener.class );
        IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
       
        // Test activation
        listener.serviceActivated( null, ADDRESS, null, null );
       
        listenerControl.replay();
       
        support.add( listener );
        support.fireServiceActivated( null, ADDRESS, null, null );
       
        listenerControl.verify();
       
        Assert.assertEquals( 1, support.getManagedServiceAddresses().size() );
        Assert.assertTrue( support.getManagedServiceAddresses().contains( ADDRESS ) );
       
        // Test deactivation & other side effects
        listenerControl.reset();
        listener.serviceDeactivated( null, ADDRESS, null, null );

        listenerControl.replay();
        //// Activate more than once
        support.fireServiceActivated( null, ADDRESS, null, null );
        //// Deactivate
View Full Code Here

        MockControl chainControl = MockControl.createStrictControl( IoFilterChain.class );
        IoFilterChain chain = ( IoFilterChain ) chainControl.getMock();
        session.setFilterChain( chain );
       
        MockControl listenerControl = MockControl.createStrictControl( IoServiceListener.class );
        IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
       
        // Test creation
        listener.sessionCreated( session );
        chain.fireSessionCreated( session );
        chain.fireSessionOpened( session);
       
        listenerControl.replay();
        chainControl.replay();
       
        support.add( listener );
        support.fireSessionCreated( session );
       
        listenerControl.verify();
        chainControl.verify();
       
        Assert.assertEquals( 1, support.getManagedSessions( ADDRESS ).size() );
        Assert.assertTrue( support.getManagedSessions( ADDRESS ).contains( session ) );
       
        // Test destruction & other side effects
        listenerControl.reset();
        chainControl.reset();
        chain.fireSessionClosed( session );
        listener.sessionDestroyed( session );

        listenerControl.replay();
        //// Activate more than once
        support.fireSessionCreated( session );
        //// Deactivate
View Full Code Here

TOP

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

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.