mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramSchedulerImpl.java
@Test
    public void testCancelWithShutdownRemoval() throws InterruptedException
    {
        //activate the component
        m_SUT.activate();

        //quick schedule, shouldn't be able to remove will already be gone
        MissionProgramSchedule schedule = TestProgramImpl.createMissionSchedule(System.currentTimeMillis() + 100L,
                System.currentTimeMillis() + 300L, true, false, true, true);
        
        when(m_Program1.getMissionSchedule()).thenReturn(schedule);
        
        //mock power management
        WakeLock wakeLock = mock(WakeLock.class);
        when(m_PowerManager.createWakeLock(m_SUT.getClass(), PROG1_NAME)).thenReturn(wakeLock);

        m_SUT.executeProgram(m_Program1);
        
        //remove the remaining one
        assertThat(m_SUT.cancelScheduledProgram(PROG1_NAME), is(true));
        
        //sleep again to make sure the removed program does NOT execute.
        Thread.sleep(185);
        
        //verify there was only one invocation for the execution of the program and not of the shutdown because that
        //should of been cancelled.
        verify(m_EventAdmin, never()).postEvent(Mockito.any(Event.class));

        verify(wakeLock).delete();
    }
/**
     * Test canceling a mission from the executor queue.
     * Verify the mission DOES NOT execute.
     */
Test canceling a mission from the executor queue.
Verify the mission DOES NOT execute.
Test canceling a mission from the executor queue . Verify the mission DOES NOT execute .
@Test
    public void testCancelWithShutdownRemoval() throws InterruptedException
    {
        m_SUT.activate();
        MissionProgramSchedule schedule = TestProgramImpl.createMissionSchedule(System.currentTimeMillis() + 100L,
                System.currentTimeMillis() + 300L, true, false, true, true);
        when(m_Program1.getMissionSchedule()).thenReturn(schedule);
        WakeLock wakeLock = mock(WakeLock.class);
        when(m_PowerManager.createWakeLock(m_SUT.getClass(), PROG1_NAME)).thenReturn(wakeLock);
        m_SUT.executeProgram(m_Program1);
        assertThat(m_SUT.cancelScheduledProgram(PROG1_NAME), is(true));
        Thread.sleep(185);
        verify(m_EventAdmin, never()).postEvent(Mockito.any(Event.class));
        verify(wakeLock).delete();
    }
@ Test public void testCancelWithShutdownRemoval ( ) throws InterruptedException { m_SUT . activate ( ) ; MissionProgramSchedule schedule = TestProgramImpl . createMissionSchedule ( System . currentTimeMillis ( ) + 100L , System . currentTimeMillis ( ) + 300L , true , false , true , true ) ; when ( m_Program1 . getMissionSchedule ( ) ) . thenReturn ( schedule ) ; WakeLock wakeLock = mock ( WakeLock . class ) ; when ( m_PowerManager . createWakeLock ( m_SUT . getClass ( ) , PROG1_NAME ) ) . thenReturn ( wakeLock ) ; m_SUT . executeProgram ( m_Program1 ) ; assertThat ( m_SUT . cancelScheduledProgram ( PROG1_NAME ) , is ( true ) ) ; Thread . sleep ( 185 ) ; verify ( m_EventAdmin , never ( ) ) . postEvent ( Mockito . any ( Event . class ) ) ; verify ( wakeLock ) . delete ( ) ; }
Test canceling a mission from the executor queue.
Test canceling a mission from the executor queue .
//activate the component //quick schedule, shouldn't be able to remove will already be gone //mock power management //remove the remaining one //sleep again to make sure the removed program does NOT execute. //verify there was only one invocation for the execution of the program and not of the shutdown because that //should of been cancelled.