mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramSchedulerImpl.java
@Test
    public void testExecuteTestWithException() throws InterruptedException, PrivilegedActionException
    {
        //activate the component
        m_SUT.activate();
        
        //schedule
        MissionProgramSchedule schedule = TestProgramImpl.createMissionSchedule(null, 
                null, true, true, true, true);
        
        //more behavior for the program instance
        when(m_Program1.getMissionSchedule()).thenReturn(schedule);
        doThrow(new PrivilegedActionException(new Exception("exception something failed"))).when(m_Script).test();
        
        //load the program
        Future<?> future = m_SUT.testProgram(m_Program1);
        
        //wait for it....
        Thread.sleep(100);
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        
        assertThat(eventCaptor.getValue().getTopic(), 
            is(Program.TOPIC_PROGRAM_TESTED));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);
        
        try
        {
            future.get();
        }
        catch (ExecutionException e)
        {
            assertThat(e.getCause().getMessage(), is("java.lang.Exception: exception something failed"));
        }
    }
/**
     * Test that a program can be registered and test executed, but that if an exception is incurred that is it is 
     * contained within the future object returned.
     */
Test that a program can be registered and test executed, but that if an exception is incurred that is it is
contained within the future object returned.
Test that a program can be registered and test executed but that if an exception is incurred that is it is contained within the future object returned .
@Test
    public void testExecuteTestWithException() throws InterruptedException, PrivilegedActionException
    {
        m_SUT.activate();
        MissionProgramSchedule schedule = TestProgramImpl.createMissionSchedule(null, 
                null, true, true, true, true);
        when(m_Program1.getMissionSchedule()).thenReturn(schedule);
        doThrow(new PrivilegedActionException(new Exception("exception something failed"))).when(m_Script).test();
        Future<?> future = m_SUT.testProgram(m_Program1);
        Thread.sleep(100);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        assertThat(eventCaptor.getValue().getTopic(), 
            is(Program.TOPIC_PROGRAM_TESTED));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);
        try
        {
            future.get();
        }
        catch (ExecutionException e)
        {
            assertThat(e.getCause().getMessage(), is("java.lang.Exception: exception something failed"));
        }
    }
@ Test public void testExecuteTestWithException ( ) throws InterruptedException , PrivilegedActionException { m_SUT . activate ( ) ; MissionProgramSchedule schedule = TestProgramImpl . createMissionSchedule ( null , null , true , true , true , true ) ; when ( m_Program1 . getMissionSchedule ( ) ) . thenReturn ( schedule ) ; doThrow ( new PrivilegedActionException ( new Exception ( "exception something failed" ) ) ) . when ( m_Script ) . test ( ) ; Future < ? > future = m_SUT . testProgram ( m_Program1 ) ; Thread . sleep ( 100 ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; assertThat ( eventCaptor . getValue ( ) . getTopic ( ) , is ( Program . TOPIC_PROGRAM_TESTED ) ) ; assertProgramEventProps ( eventCaptor . getValue ( ) , m_Program1 ) ; try { future . get ( ) ; } catch ( ExecutionException e ) { assertThat ( e . getCause ( ) . getMessage ( ) , is ( "java.lang.Exception: exception something failed" ) ) ; } }
Test that a program can be registered and test executed, but that if an exception is incurred that is it is
 contained within the future object returned.
Test that a program can be registered and test executed but that if an exception is incurred that is it is contained within the future object returned .
//activate the component //schedule //more behavior for the program instance //load the program //wait for it....