FileDocCategorySizeDatePackage
ChannelStartStop.javaAPI DocApache Tomcat 6.0.144235Fri Jul 20 04:20:34 BST 2007org.apache.catalina.tribes.test.channel

ChannelStartStop

public class ChannelStartStop extends TestCase
author
Filip Hanik
version
1.0

Fields Summary
org.apache.catalina.tribes.group.GroupChannel
channel
Constructors Summary
Methods Summary
protected voidsetUp()

         
        super.setUp();
        channel = new GroupChannel();
    
protected voidtearDown()

        super.tearDown();
        try {channel.stop(channel.DEFAULT);}catch (Exception ignore){}
    
public voidtestDoubleFullStart()

        int count = 0;
        try {
            channel.start(channel.DEFAULT);
            count++;
        } catch ( Exception x){x.printStackTrace();}
        try {
            channel.start(channel.DEFAULT);
            count++;
        } catch ( Exception x){x.printStackTrace();}
        assertEquals(count,2);
        channel.stop(channel.DEFAULT);
    
public voidtestDoublePartialStart()

        //try to double start the RX 
        int count = 0;
        try {
            channel.start(channel.SND_RX_SEQ);
            channel.start(channel.MBR_RX_SEQ);
            count++;
        } catch ( Exception x){x.printStackTrace();}
        try {
            channel.start(channel.MBR_RX_SEQ);
            count++;
        } catch ( Exception x){/*expected*/}
        assertEquals(count,1);
        channel.stop(channel.DEFAULT);
        //double the membership sender
        count = 0;
        try {
            channel.start(channel.SND_RX_SEQ);
            channel.start(channel.MBR_TX_SEQ);
            count++;
        } catch ( Exception x){x.printStackTrace();}
        try {
            channel.start(channel.MBR_TX_SEQ);
            count++;
        } catch ( Exception x){/*expected*/}
        assertEquals(count,1);
        channel.stop(channel.DEFAULT);
        
        count = 0;
        try {
            channel.start(channel.SND_RX_SEQ);
            count++;
        } catch ( Exception x){x.printStackTrace();}
        try {
            channel.start(channel.SND_RX_SEQ);
            count++;
        } catch ( Exception x){/*expected*/}
        assertEquals(count,1);
        channel.stop(channel.DEFAULT);

        count = 0;
        try {
            channel.start(channel.SND_TX_SEQ);
            count++;
        } catch ( Exception x){x.printStackTrace();}
        try {
            channel.start(channel.SND_TX_SEQ);
            count++;
        } catch ( Exception x){/*expected*/}
        assertEquals(count,1);
        channel.stop(channel.DEFAULT);
    
public voidtestFalseOption()

        int flag = 0xFFF0;//should get ignored by the underlying components
        int count = 0;
        try {
            channel.start(flag);
            count++;
        } catch ( Exception x){x.printStackTrace();}
        try {
            channel.start(flag);
            count++;
        } catch ( Exception x){/*expected*/}
        assertEquals(count,2);
        channel.stop(channel.DEFAULT);
    
public voidtestScrap()

        System.out.println(channel.getChannelReceiver().getClass());
        ((ReceiverBase)channel.getChannelReceiver()).setMaxThreads(1);