1 4 package com.tc.net.protocol.delivery; 5 6 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue; 7 8 import com.tc.net.protocol.tcm.NullMessageMonitor; 9 import com.tc.net.protocol.tcm.msgs.PingMessage; 10 11 import junit.framework.TestCase; 12 13 16 public class ReceiveStateMachineTest extends TestCase { 17 18 public void tests() throws Exception { 19 LinkedQueue receiveQueue = new LinkedQueue(); 20 TestProtocolMessageDelivery delivery = new TestProtocolMessageDelivery(receiveQueue); 21 ReceiveStateMachine rsm = new ReceiveStateMachine(delivery); 22 TestProtocolMessage tpm = new TestProtocolMessage(); 23 tpm.isAckRequest = true; 24 25 rsm.start(); 26 27 rsm.execute(tpm); 29 assertTrue(delivery.sentAck); 30 31 delivery.clear(); 32 33 tpm.msg = new PingMessage(new NullMessageMonitor()); 34 tpm.sent = 0; 35 tpm.isAckRequest = false; 36 37 assertEquals(0, delivery.receivedMessageCount); 38 rsm.execute(tpm); 40 int received = delivery.receivedMessageCount; 41 assertTrue(delivery.receivedMessageCount > 0); 42 assertTrue(receiveQueue.poll(0) != null); 43 44 rsm.execute(tpm); 46 assertEquals(received, delivery.receivedMessageCount); 47 assertTrue(receiveQueue.poll(0) == null); 48 } 49 } | Popular Tags |