mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramSchedulerImpl.java
@Test
    public void testSubmitTwice() 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() + 300L, null,
                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);
        
        //try to execute the same program again
        m_SUT.executeProgram(m_Program1);
        
        //give enough time to make sure the program only executes ONCE
        Thread.sleep(700);
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(1)).postEvent(eventCaptor.capture());
        
        assertThat(eventCaptor.getValue().getTopic(), 
            is(Program.TOPIC_PROGRAM_EXECUTED));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);

        verify(wakeLock).delete();
    }
/**
     * Test submitting the same program twice.
     * Verify illegal arg exception.
     */
Test submitting the same program twice.
Verify illegal arg exception.
Test submitting the same program twice . Verify illegal arg exception .
@Test
    public void testSubmitTwice() throws InterruptedException
    {
        m_SUT.activate();
        MissionProgramSchedule schedule = TestProgramImpl.createMissionSchedule(System.currentTimeMillis() + 300L, null,
                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);
        m_SUT.executeProgram(m_Program1);
        Thread.sleep(700);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(1)).postEvent(eventCaptor.capture());
        assertThat(eventCaptor.getValue().getTopic(), 
            is(Program.TOPIC_PROGRAM_EXECUTED));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);
        verify(wakeLock).delete();
    }
@ Test public void testSubmitTwice ( ) throws InterruptedException { m_SUT . activate ( ) ; MissionProgramSchedule schedule = TestProgramImpl . createMissionSchedule ( System . currentTimeMillis ( ) + 300L , null , 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 ) ; m_SUT . executeProgram ( m_Program1 ) ; Thread . sleep ( 700 ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 1 ) ) . postEvent ( eventCaptor . capture ( ) ) ; assertThat ( eventCaptor . getValue ( ) . getTopic ( ) , is ( Program . TOPIC_PROGRAM_EXECUTED ) ) ; assertProgramEventProps ( eventCaptor . getValue ( ) , m_Program1 ) ; verify ( wakeLock ) . delete ( ) ; }
Test submitting the same program twice.
Test submitting the same program twice .
//activate the component //quick schedule, shouldn't be able to remove will already be gone //mock power management //try to execute the same program again //give enough time to make sure the program only executes ONCE