public void TestNonFailureSendCase() { InactivityMonitor monitor = new InactivityMonitor( this.transport ); monitor.Exception += new ExceptionHandler(OnException); monitor.Command += new CommandHandler(OnCommand); monitor.Start(); // Send the local one for the monitor to record. monitor.Oneway( this.localWireFormatInfo ); ActiveMQMessage message = new ActiveMQMessage(); for( int ix = 0; ix < 20; ++ix ) { monitor.Oneway( message ); Thread.Sleep( 500 ); this.transport.InjectCommand( message ); Thread.Sleep( 500 ); } // Channel should have been inactive for to long. Assert.IsTrue( this.exceptions.Count == 0 ); }
public void TestReadTimeout() { InactivityMonitor monitor = new InactivityMonitor( this.transport ); monitor.Exception += new ExceptionHandler(OnException); monitor.Command += new CommandHandler(OnCommand); // Send the local one for the monitor to record. monitor.Oneway( this.localWireFormatInfo ); Thread.Sleep( 2000 ); // Should not have timed out on Read yet. Assert.IsTrue( this.exceptions.Count == 0 ); Thread.Sleep( 5000 ); // Channel should have been inactive for to long. Assert.IsTrue( this.exceptions.Count > 0 ); }
public void TestWriteMessageFail() { this.transport.FailOnKeepAliveInfoSends = true ; this.transport.NumSentKeepAliveInfosBeforeFail = 4; InactivityMonitor monitor = new InactivityMonitor( this.transport ); monitor.Exception += new ExceptionHandler(OnException); monitor.Command += new CommandHandler(OnCommand); monitor.Start(); // Send the local one for the monitor to record. monitor.Oneway( this.localWireFormatInfo ); Thread.Sleep( 2000 ); ActiveMQMessage message = new ActiveMQMessage(); this.transport.InjectCommand( message ); Thread.Sleep( 2000 ); // Should not have timed out on Read yet. Assert.IsTrue( this.exceptions.Count == 0 ); for(int ix = 0; ix < 4; ix++) { this.transport.InjectCommand( message ); Thread.Sleep( 2000 ); } // Channel should have been inactive for to long. Assert.IsTrue( this.exceptions.Count > 0 ); }