mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/MessageListener.java
public List<MessageDetails> waitForMessages(int timeoutMS, boolean assertMatches, MessageMatcher ...matchers)
    {
        m_AllResponses.clear();
        m_Matches.clear();
        m_WaitSem = new Semaphore(0);
        
        MessageReader messageReader = new MessageReader(m_WaitSem, matchers);
        Thread thread = new Thread(messageReader);
        thread.start();
        
        try
        {
            m_WaitSem.tryAcquire(timeoutMS, TimeUnit.MILLISECONDS);
        }
        catch (InterruptedException e)
        {
            throw new IllegalStateException(e);
        }
        
        messageReader.stop();
        try
        {
            thread.join(1000);
        }
        catch (InterruptedException e)
        {
            throw new IllegalStateException(e);
        }
        
        if (assertMatches)
        {
            for (MessageMatcher matcher : matchers)
            {
                matcher.assertMatch(m_AllResponses);
            }
            
            assertThat("Message reader thread did not stop", thread.isAlive(), is(false));
        }
        
        return m_Matches;
    }
/**
     * Wait for the first occurrence of each given message in any order.
     * 
     * @param timeoutMS
     *      max time to wait for the message
     * @param assertMatches
     *      true if the responses should be checked against the given matchers list
     * @param matchers
     *      matchers that can be used to find a sequence of message.
     * @return
     *      details on the messages that were being waited for, messages that don't match won't be returned
     */
Wait for the first occurrence of each given message in any order.

@param timeoutMS
max time to wait for the message
@param assertMatches
true if the responses should be checked against the given matchers list
@param matchers
matchers that can be used to find a sequence of message.
@return
details on the messages that were being waited for, messages that don't match won't be returned
Wait for the first occurrence of each given message in any order . @param timeoutMS max time to wait for the message @param assertMatches true if the responses should be checked against the given matchers list @param matchers matchers that can be used to find a sequence of message . @return details on the messages that were being waited for messages that don ' t match won ' t be returned
public List<MessageDetails> waitForMessages(int timeoutMS, boolean assertMatches, MessageMatcher ...matchers)
    {
        m_AllResponses.clear();
        m_Matches.clear();
        m_WaitSem = new Semaphore(0);
        MessageReader messageReader = new MessageReader(m_WaitSem, matchers);
        Thread thread = new Thread(messageReader);
        thread.start();
        try
        {
            m_WaitSem.tryAcquire(timeoutMS, TimeUnit.MILLISECONDS);
        }
        catch (InterruptedException e)
        {
            throw new IllegalStateException(e);
        }
        messageReader.stop();
        try
        {
            thread.join(1000);
        }
        catch (InterruptedException e)
        {
            throw new IllegalStateException(e);
        }
        if (assertMatches)
        {
            for (MessageMatcher matcher : matchers)
            {
                matcher.assertMatch(m_AllResponses);
            }
            assertThat("Message reader thread did not stop", thread.isAlive(), is(false));
        }
        return m_Matches;
    }
public List < MessageDetails > waitForMessages ( int timeoutMS , boolean assertMatches , MessageMatcher ... matchers ) { m_AllResponses . clear ( ) ; m_Matches . clear ( ) ; m_WaitSem = new Semaphore ( 0 ) ; MessageReader messageReader = new MessageReader ( m_WaitSem , matchers ) ; Thread thread = new Thread ( messageReader ) ; thread . start ( ) ; try { m_WaitSem . tryAcquire ( timeoutMS , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { throw new IllegalStateException ( e ) ; } messageReader . stop ( ) ; try { thread . join ( 1000 ) ; } catch ( InterruptedException e ) { throw new IllegalStateException ( e ) ; } if ( assertMatches ) { for ( MessageMatcher matcher : matchers ) { matcher . assertMatch ( m_AllResponses ) ; } assertThat ( "Message reader thread did not stop" , thread . isAlive ( ) , is ( false ) ) ; } return m_Matches ; }
Wait for the first occurrence of each given message in any order.
Wait for the first occurrence of each given message in any order .