mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestMissionProgrammingNamespace.java
@Test
    public void testGetProgramStatus() throws UnknownHostException, IOException, InterruptedException
    {
        //message listener
        MessageListener listener = new MessageListener(m_Socket);
        
        m_MissionName = "programStatusMission";
        
        //create schedule
        MissionProgramParametersGen.MissionProgramSchedule schedule = MissionProgramParametersGen.
                MissionProgramSchedule.newBuilder().setActive(true).setImmediately(false).
                setIndefiniteInterval(false).build();

        //create mission program parameters
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramNamespaceUtils.genTimedDataLoopParams(
                    schedule, ASSET_NAME, m_MissionName);
        
        //load the parameters
        MissionProgramNamespaceUtils.loadParameters(m_Socket, params);
        
        //get the name of a program to query about
        String programName = MissionProgramNamespaceUtils.getAProgramName(m_Socket);
        
        //create mission program message
        GetProgramStatusRequestData request = GetProgramStatusRequestData.newBuilder().
                setMissionName(programName).build();
        
        //create terra harvest message   
        TerraHarvestMessage message = createMissionProgramMessage(MissionProgrammingMessageType.GetProgramStatusRequest,
                request);
        
        // send out message
        message.writeDelimitedTo(m_Socket.getOutputStream());
        
        //wait for execution and response, response is from the actual thread executing the mission program
        MissionProgrammingNamespace namespace = (MissionProgrammingNamespace)listener.waitForMessage(
                Namespace.MissionProgramming, MissionProgrammingMessageType.GetProgramStatusResponse, 1500);
        
        GetProgramStatusResponseData responseData = GetProgramStatusResponseData.parseFrom(namespace.getData());

        //verify success
        assertThat(responseData.getMissionStatus(), isOneOf(MissionStatus.EXECUTED, MissionStatus.EXECUTING, 
                MissionStatus.WAITING_INITIALIZED, MissionStatus.CANCELED, MissionStatus.EXECUTING_TEST, 
                MissionStatus.INITIALIZATION_ERROR, MissionStatus.SCHEDULED, MissionStatus.SCRIPT_ERROR, 
                MissionStatus.SHUTDOWN, MissionStatus.WAITING_UNINITIALIZED, MissionStatus.SHUTTING_DOWN, 
                MissionStatus.UNSATISFIED));
        assertThat(responseData.getMissionName(), is(programName));
    }
/**
     * Test requesting the status of a program.
     */
Test requesting the status of a program.
Test requesting the status of a program .
@Test
    public void testGetProgramStatus() throws UnknownHostException, IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(m_Socket);
        m_MissionName = "programStatusMission";
        MissionProgramParametersGen.MissionProgramSchedule schedule = MissionProgramParametersGen.
                MissionProgramSchedule.newBuilder().setActive(true).setImmediately(false).
                setIndefiniteInterval(false).build();
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramNamespaceUtils.genTimedDataLoopParams(
                    schedule, ASSET_NAME, m_MissionName);
        MissionProgramNamespaceUtils.loadParameters(m_Socket, params);
        String programName = MissionProgramNamespaceUtils.getAProgramName(m_Socket);
        GetProgramStatusRequestData request = GetProgramStatusRequestData.newBuilder().
                setMissionName(programName).build();
        TerraHarvestMessage message = createMissionProgramMessage(MissionProgrammingMessageType.GetProgramStatusRequest,
                request);
        message.writeDelimitedTo(m_Socket.getOutputStream());
        MissionProgrammingNamespace namespace = (MissionProgrammingNamespace)listener.waitForMessage(
                Namespace.MissionProgramming, MissionProgrammingMessageType.GetProgramStatusResponse, 1500);
        GetProgramStatusResponseData responseData = GetProgramStatusResponseData.parseFrom(namespace.getData());
        assertThat(responseData.getMissionStatus(), isOneOf(MissionStatus.EXECUTED, MissionStatus.EXECUTING, 
                MissionStatus.WAITING_INITIALIZED, MissionStatus.CANCELED, MissionStatus.EXECUTING_TEST, 
                MissionStatus.INITIALIZATION_ERROR, MissionStatus.SCHEDULED, MissionStatus.SCRIPT_ERROR, 
                MissionStatus.SHUTDOWN, MissionStatus.WAITING_UNINITIALIZED, MissionStatus.SHUTTING_DOWN, 
                MissionStatus.UNSATISFIED));
        assertThat(responseData.getMissionName(), is(programName));
    }
@ Test public void testGetProgramStatus ( ) throws UnknownHostException , IOException , InterruptedException { MessageListener listener = new MessageListener ( m_Socket ) ; m_MissionName = "programStatusMission" ; MissionProgramParametersGen . MissionProgramSchedule schedule = MissionProgramParametersGen . MissionProgramSchedule . newBuilder ( ) . setActive ( true ) . setImmediately ( false ) . setIndefiniteInterval ( false ) . build ( ) ; MissionProgramParametersGen . MissionProgramParameters params = MissionProgramNamespaceUtils . genTimedDataLoopParams ( schedule , ASSET_NAME , m_MissionName ) ; MissionProgramNamespaceUtils . loadParameters ( m_Socket , params ) ; String programName = MissionProgramNamespaceUtils . getAProgramName ( m_Socket ) ; GetProgramStatusRequestData request = GetProgramStatusRequestData . newBuilder ( ) . setMissionName ( programName ) . build ( ) ; TerraHarvestMessage message = createMissionProgramMessage ( MissionProgrammingMessageType . GetProgramStatusRequest , request ) ; message . writeDelimitedTo ( m_Socket . getOutputStream ( ) ) ; MissionProgrammingNamespace namespace = ( MissionProgrammingNamespace ) listener . waitForMessage ( Namespace . MissionProgramming , MissionProgrammingMessageType . GetProgramStatusResponse , 1500 ) ; GetProgramStatusResponseData responseData = GetProgramStatusResponseData . parseFrom ( namespace . getData ( ) ) ; assertThat ( responseData . getMissionStatus ( ) , isOneOf ( MissionStatus . EXECUTED , MissionStatus . EXECUTING , MissionStatus . WAITING_INITIALIZED , MissionStatus . CANCELED , MissionStatus . EXECUTING_TEST , MissionStatus . INITIALIZATION_ERROR , MissionStatus . SCHEDULED , MissionStatus . SCRIPT_ERROR , MissionStatus . SHUTDOWN , MissionStatus . WAITING_UNINITIALIZED , MissionStatus . SHUTTING_DOWN , MissionStatus . UNSATISFIED ) ) ; assertThat ( responseData . getMissionName ( ) , is ( programName ) ) ; }
Test requesting the status of a program.
Test requesting the status of a program .
//message listener //create schedule //create mission program parameters //load the parameters //get the name of a program to query about //create mission program message //create terra harvest message    // send out message //wait for execution and response, response is from the actual thread executing the mission program //verify success