mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramSchedulerImpl.java
@Test
    public void testExecuteSimplePosting() throws InterruptedException
    {
        //activate the component
        m_SUT.activate();
        
        //schedule
        long startInterval = System.currentTimeMillis() + 100L;
        MissionProgramSchedule schedule = TestProgramImpl.createMissionSchedule(startInterval, 
                null, true, null, false, true);
        
        //more behavior for the program instance
        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);

        //load the program
        m_SUT.executeProgram(m_Program1);
        
        //wait for it....
        Thread.sleep(200);
        
        verify(wakeLock).scheduleWakeTime(new Date(startInterval));

        //should just be once for execution
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());

        assertThat(eventCaptor.getValue().getTopic(), 
            is(Program.TOPIC_PROGRAM_EXECUTED));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);

        verify(wakeLock).delete();
    }
/**
     * Test that a program can be registered and executed.
     * Verify the programs are registered.
     */
Test that a program can be registered and executed.
Verify the programs are registered.
Test that a program can be registered and executed . Verify the programs are registered .
@Test
    public void testExecuteSimplePosting() throws InterruptedException
    {
        m_SUT.activate();
        long startInterval = System.currentTimeMillis() + 100L;
        MissionProgramSchedule schedule = TestProgramImpl.createMissionSchedule(startInterval, 
                null, true, null, false, 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);
        Thread.sleep(200);
        verify(wakeLock).scheduleWakeTime(new Date(startInterval));
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        assertThat(eventCaptor.getValue().getTopic(), 
            is(Program.TOPIC_PROGRAM_EXECUTED));
        assertProgramEventProps(eventCaptor.getValue(), m_Program1);
        verify(wakeLock).delete();
    }
@ Test public void testExecuteSimplePosting ( ) throws InterruptedException { m_SUT . activate ( ) ; long startInterval = System . currentTimeMillis ( ) + 100L ; MissionProgramSchedule schedule = TestProgramImpl . createMissionSchedule ( startInterval , null , true , null , false , 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 ) ; Thread . sleep ( 200 ) ; verify ( wakeLock ) . scheduleWakeTime ( new Date ( startInterval ) ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; assertThat ( eventCaptor . getValue ( ) . getTopic ( ) , is ( Program . TOPIC_PROGRAM_EXECUTED ) ) ; assertProgramEventProps ( eventCaptor . getValue ( ) , m_Program1 ) ; verify ( wakeLock ) . delete ( ) ; }
Test that a program can be registered and executed.
Test that a program can be registered and executed .
//activate the component //schedule //more behavior for the program instance //mock power management //load the program //wait for it.... //should just be once for execution