FileDocCategorySizeDatePackage
TestSenderConnections.javaAPI DocApache Tomcat 6.0.144857Fri Jul 20 04:20:34 BST 2007org.apache.catalina.tribes.test.io

TestSenderConnections

public class TestSenderConnections extends TestCase

Fields Summary
private static int
count
private org.apache.catalina.tribes.ManagedChannel[]
channels
private TestMsgListener[]
listeners
Constructors Summary
Methods Summary
public voidclear()

    
public voidsendMessages(long delay, long sleep)

        Member local = channels[0].getLocalMember(true);
        Member dest = channels[1].getLocalMember(true);
        int n = 3;
        System.out.println("Sending " + n + " messages from [" + local.getName() + "] to [" + dest.getName() + "]");
        for (int i = 0; i < n; i++) {
            channels[0].send(new Member[] {dest}, new TestMsg(), 0);
            if ( delay > 0 ) Thread.sleep(delay);
        }
        System.out.println("Messages sent. Sleeping for "+(sleep/1000)+" seconds to inspect connections");
        if ( sleep > 0 ) Thread.sleep(sleep);

    
protected voidsetUp()


         
        super.setUp();
        for (int i = 0; i < channels.length; i++) {
            channels[i] = new GroupChannel();
            channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
            listeners[i] = new TestMsgListener( ("Listener-" + (i + 1)));
            channels[i].addChannelListener(listeners[i]);
            channels[i].start(Channel.SND_RX_SEQ|Channel.SND_TX_SEQ);

        }
    
protected voidtearDown()

        for (int i = 0; i < channels.length; i++) {
            channels[i].stop(Channel.DEFAULT);
        }

    
public voidtestConnectionLinger()

        sendMessages(0,15000);
    
public voidtestKeepAliveCount()

        System.out.println("Setting keep alive count to 0");
        for (int i = 0; i < channels.length; i++) {
            ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
            t.getTransport().setKeepAliveCount(0);
        }
        sendMessages(1000,15000);
    
public voidtestKeepAliveTime()

        System.out.println("Setting keep alive count to 1 second");
        for (int i = 0; i < channels.length; i++) {
            ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
            t.getTransport().setKeepAliveTime(1000);
        }
        sendMessages(2000,15000);