mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestQueuedMessageSender.java
@Test
    public void testFullQueue() throws InterruptedException
    {
        // have send fail to make queue fill up
        when(m_Channel.trySendMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(false);
        
        assertThat("queue is empty initially", m_SUT.getQueuedMessageCount(), is(0));
        
        boolean result;
        //Add one to the capacity to account for the message that is currently trying to be sent.
        for (int i=1; i <= QueuedMessageSender.QUEUE_CAPACITY+1; i++)
        {
            TerraHarvestMessage message = constructMessage(i);
            result = m_SUT.queue(message);
            assertThat("able to queue up to capacity limit", result, is(true));
            Thread.yield();
            m_Logging.debug("queue:" + m_SUT.getQueuedMessageCount());
            assertThat("queue size equals number of messages still queued", m_SUT.getQueuedMessageCount(), is(i));
        }
        
        TerraHarvestMessage message = constructMessage(1000);
        result = m_SUT.queue(message);
        assertThat("not able to queue since at limit", result, is(false));
        
        //empty the queue.
        m_SUT.clearQueue();
        
        //verify
        assertThat("queue was emptied", m_SUT.getQueuedMessageCount(), is(0));
        
        //try to queue a message
        message = constructMessage(1001);
        m_SUT.queue(message);
        
        assertThat("queue size equals number of messages queued", m_SUT.getQueuedMessageCount(), is(1));
    }
/**
     * Verify the queue comes back as full if limit is reached.
     * 
     * Verify queue count is correct.
     * 
     * Verify the clearing the queue allows messages to be queued again.
     */
Verify the queue comes back as full if limit is reached.

Verify queue count is correct.

Verify the clearing the queue allows messages to be queued again.
Verify the queue comes back as full if limit is reached . Verify queue count is correct . Verify the clearing the queue allows messages to be queued again .
@Test
    public void testFullQueue() throws InterruptedException
    {
        when(m_Channel.trySendMessage(Mockito.any(TerraHarvestMessage.class))).thenReturn(false);
        assertThat("queue is empty initially", m_SUT.getQueuedMessageCount(), is(0));
        boolean result;
        for (int i=1; i <= QueuedMessageSender.QUEUE_CAPACITY+1; i++)
        {
            TerraHarvestMessage message = constructMessage(i);
            result = m_SUT.queue(message);
            assertThat("able to queue up to capacity limit", result, is(true));
            Thread.yield();
            m_Logging.debug("queue:" + m_SUT.getQueuedMessageCount());
            assertThat("queue size equals number of messages still queued", m_SUT.getQueuedMessageCount(), is(i));
        }
        TerraHarvestMessage message = constructMessage(1000);
        result = m_SUT.queue(message);
        assertThat("not able to queue since at limit", result, is(false));
        m_SUT.clearQueue();
        assertThat("queue was emptied", m_SUT.getQueuedMessageCount(), is(0));
        message = constructMessage(1001);
        m_SUT.queue(message);
        assertThat("queue size equals number of messages queued", m_SUT.getQueuedMessageCount(), is(1));
    }
@ Test public void testFullQueue ( ) throws InterruptedException { when ( m_Channel . trySendMessage ( Mockito . any ( TerraHarvestMessage . class ) ) ) . thenReturn ( false ) ; assertThat ( "queue is empty initially" , m_SUT . getQueuedMessageCount ( ) , is ( 0 ) ) ; boolean result ; for ( int i = 1 ; i <= QueuedMessageSender . QUEUE_CAPACITY + 1 ; i ++ ) { TerraHarvestMessage message = constructMessage ( i ) ; result = m_SUT . queue ( message ) ; assertThat ( "able to queue up to capacity limit" , result , is ( true ) ) ; Thread . yield ( ) ; m_Logging . debug ( "queue:" + m_SUT . getQueuedMessageCount ( ) ) ; assertThat ( "queue size equals number of messages still queued" , m_SUT . getQueuedMessageCount ( ) , is ( i ) ) ; } TerraHarvestMessage message = constructMessage ( 1000 ) ; result = m_SUT . queue ( message ) ; assertThat ( "not able to queue since at limit" , result , is ( false ) ) ; m_SUT . clearQueue ( ) ; assertThat ( "queue was emptied" , m_SUT . getQueuedMessageCount ( ) , is ( 0 ) ) ; message = constructMessage ( 1001 ) ; m_SUT . queue ( message ) ; assertThat ( "queue size equals number of messages queued" , m_SUT . getQueuedMessageCount ( ) , is ( 1 ) ) ; }
Verify the queue comes back as full if limit is reached.
Verify the queue comes back as full if limit is reached .
// have send fail to make queue fill up //Add one to the capacity to account for the message that is currently trying to be sent. //empty the queue. //verify //try to queue a message