mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramSchedulerImpl.java
@Test
    public void testShutdownTimeout() throws InterruptedException
    {
        m_SUT.activate();
        // cannot shutdown a program while executing
        when(m_Program1.getProgramStatus()).thenReturn(ProgramStatus.EXECUTING);
        doThrow(new IllegalStateException()).when(m_Program1).changeStatus(ProgramStatus.SHUTTING_DOWN);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);

        m_SUT.shutdownProgram(m_Program1);
        
        //shutdown retries every second
        Thread.sleep(100);
        
        //once for shutdown topic (mocked status changes do not post events)
        verify(m_EventAdmin, times (1)).postEvent(eventCaptor.capture());
        
        assertThat(eventCaptor.getValue().getTopic(), 
                is(Program.TOPIC_PROGRAM_SHUTDOWN_FAILURE));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);
        assertThat((String)eventCaptor.getValue().getProperty(Program.EVENT_PROP_PROGRAM_EXCEPTION), 
                is(nullValue()));
    }
/**
     * Test that the shutdown times out after a defined number of failed attempts.
     */
Test that the shutdown times out after a defined number of failed attempts.
Test that the shutdown times out after a defined number of failed attempts .
@Test
    public void testShutdownTimeout() throws InterruptedException
    {
        m_SUT.activate();
        when(m_Program1.getProgramStatus()).thenReturn(ProgramStatus.EXECUTING);
        doThrow(new IllegalStateException()).when(m_Program1).changeStatus(ProgramStatus.SHUTTING_DOWN);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        m_SUT.shutdownProgram(m_Program1);
        Thread.sleep(100);
        verify(m_EventAdmin, times (1)).postEvent(eventCaptor.capture());
        assertThat(eventCaptor.getValue().getTopic(), 
                is(Program.TOPIC_PROGRAM_SHUTDOWN_FAILURE));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);
        assertThat((String)eventCaptor.getValue().getProperty(Program.EVENT_PROP_PROGRAM_EXCEPTION), 
                is(nullValue()));
    }
@ Test public void testShutdownTimeout ( ) throws InterruptedException { m_SUT . activate ( ) ; when ( m_Program1 . getProgramStatus ( ) ) . thenReturn ( ProgramStatus . EXECUTING ) ; doThrow ( new IllegalStateException ( ) ) . when ( m_Program1 ) . changeStatus ( ProgramStatus . SHUTTING_DOWN ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; m_SUT . shutdownProgram ( m_Program1 ) ; Thread . sleep ( 100 ) ; verify ( m_EventAdmin , times ( 1 ) ) . postEvent ( eventCaptor . capture ( ) ) ; assertThat ( eventCaptor . getValue ( ) . getTopic ( ) , is ( Program . TOPIC_PROGRAM_SHUTDOWN_FAILURE ) ) ; assertProgramEventProps ( eventCaptor . getValue ( ) , m_Program1 ) ; assertThat ( ( String ) eventCaptor . getValue ( ) . getProperty ( Program . EVENT_PROP_PROGRAM_EXCEPTION ) , is ( nullValue ( ) ) ) ; }
Test that the shutdown times out after a defined number of failed attempts.
Test that the shutdown times out after a defined number of failed attempts .
// cannot shutdown a program while executing //shutdown retries every second //once for shutdown topic (mocked status changes do not post events)