mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestBaseNamespace.java
@Test
    public void testSetOperationStatus() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        // send out message
        SetOperationModeRequestData request = SetOperationModeRequestData.newBuilder().
                setMode(OperationMode.OPERATIONAL_MODE).build();
        BaseNamespace.Builder baseNamespaceMsg = BaseNamespace.newBuilder().
                setType(BaseMessageType.SetOperationModeRequest).
                setData(request.toByteString());
        
        TerraHarvestMessage thRequest = TerraHarvestMessageHelper.
                createTerraHarvestMsg(Namespace.Base, baseNamespaceMsg);
        thRequest.writeDelimitedTo(socket.getOutputStream());

        // read in response
        Message response = listener.waitForMessage(Namespace.Base, 
                BaseMessageType.SetOperationModeResponse, 300);
        BaseNamespace namespaceResponse = (BaseNamespace)response;
        assertThat(namespaceResponse, is(notNullValue()));

        assertThat(namespaceResponse.getType(), is(BaseMessageType.SetOperationModeResponse));

        //replay 
        baseNamespaceMsg = BaseNamespace.newBuilder().
                setType(BaseMessageType.GetOperationModeRequest);
        thRequest = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.Base, baseNamespaceMsg);
        thRequest.writeDelimitedTo(socket.getOutputStream());

        // read in response
        Message getSystemResponse = listener.waitForMessage(Namespace.Base, 
                BaseMessageType.GetOperationModeResponse, 500);
        BaseNamespace getSysNamespaceResponse = (BaseNamespace)getSystemResponse;
        assertThat(getSysNamespaceResponse, is(notNullValue()));

        assertThat(getSysNamespaceResponse.getType(), is(BaseMessageType.GetOperationModeResponse));

        GetOperationModeReponseData systemMode = 
                GetOperationModeReponseData.parseFrom(getSysNamespaceResponse.getData());
        assertThat(systemMode.getMode(), is(OperationMode.OPERATIONAL_MODE));

        // send out message to reset to test mode
        request = SetOperationModeRequestData.newBuilder().
                setMode(OperationMode.TEST_MODE).build();
        baseNamespaceMsg = BaseNamespace.newBuilder().
                setType(BaseMessageType.SetOperationModeRequest).
                setData(request.toByteString());
        thRequest = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.Base, baseNamespaceMsg);
        thRequest.writeDelimitedTo(socket.getOutputStream());
    }
/**
     * Verify sending a set operation mode request message changes the operation mode of the controller.
     */
Verify sending a set operation mode request message changes the operation mode of the controller.
Verify sending a set operation mode request message changes the operation mode of the controller .
@Test
    public void testSetOperationStatus() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        SetOperationModeRequestData request = SetOperationModeRequestData.newBuilder().
                setMode(OperationMode.OPERATIONAL_MODE).build();
        BaseNamespace.Builder baseNamespaceMsg = BaseNamespace.newBuilder().
                setType(BaseMessageType.SetOperationModeRequest).
                setData(request.toByteString());
        TerraHarvestMessage thRequest = TerraHarvestMessageHelper.
                createTerraHarvestMsg(Namespace.Base, baseNamespaceMsg);
        thRequest.writeDelimitedTo(socket.getOutputStream());
        Message response = listener.waitForMessage(Namespace.Base, 
                BaseMessageType.SetOperationModeResponse, 300);
        BaseNamespace namespaceResponse = (BaseNamespace)response;
        assertThat(namespaceResponse, is(notNullValue()));
        assertThat(namespaceResponse.getType(), is(BaseMessageType.SetOperationModeResponse));
        baseNamespaceMsg = BaseNamespace.newBuilder().
                setType(BaseMessageType.GetOperationModeRequest);
        thRequest = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.Base, baseNamespaceMsg);
        thRequest.writeDelimitedTo(socket.getOutputStream());
        Message getSystemResponse = listener.waitForMessage(Namespace.Base, 
                BaseMessageType.GetOperationModeResponse, 500);
        BaseNamespace getSysNamespaceResponse = (BaseNamespace)getSystemResponse;
        assertThat(getSysNamespaceResponse, is(notNullValue()));
        assertThat(getSysNamespaceResponse.getType(), is(BaseMessageType.GetOperationModeResponse));
        GetOperationModeReponseData systemMode = 
                GetOperationModeReponseData.parseFrom(getSysNamespaceResponse.getData());
        assertThat(systemMode.getMode(), is(OperationMode.OPERATIONAL_MODE));
         to reset to test mode
        request = SetOperationModeRequestData.newBuilder().
                setMode(OperationMode.TEST_MODE).build();
        baseNamespaceMsg = BaseNamespace.newBuilder().
                setType(BaseMessageType.SetOperationModeRequest).
                setData(request.toByteString());
        thRequest = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.Base, baseNamespaceMsg);
        thRequest.writeDelimitedTo(socket.getOutputStream());
    }
@ Test public void testSetOperationStatus ( ) throws IOException , InterruptedException { MessageListener listener = new MessageListener ( socket ) ; SetOperationModeRequestData request = SetOperationModeRequestData . newBuilder ( ) . setMode ( OperationMode . OPERATIONAL_MODE ) . build ( ) ; BaseNamespace . Builder baseNamespaceMsg = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . SetOperationModeRequest ) . setData ( request . toByteString ( ) ) ; TerraHarvestMessage thRequest = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . Base , baseNamespaceMsg ) ; thRequest . writeDelimitedTo ( socket . getOutputStream ( ) ) ; Message response = listener . waitForMessage ( Namespace . Base , BaseMessageType . SetOperationModeResponse , 300 ) ; BaseNamespace namespaceResponse = ( BaseNamespace ) response ; assertThat ( namespaceResponse , is ( notNullValue ( ) ) ) ; assertThat ( namespaceResponse . getType ( ) , is ( BaseMessageType . SetOperationModeResponse ) ) ; baseNamespaceMsg = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . GetOperationModeRequest ) ; thRequest = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . Base , baseNamespaceMsg ) ; thRequest . writeDelimitedTo ( socket . getOutputStream ( ) ) ; Message getSystemResponse = listener . waitForMessage ( Namespace . Base , BaseMessageType . GetOperationModeResponse , 500 ) ; BaseNamespace getSysNamespaceResponse = ( BaseNamespace ) getSystemResponse ; assertThat ( getSysNamespaceResponse , is ( notNullValue ( ) ) ) ; assertThat ( getSysNamespaceResponse . getType ( ) , is ( BaseMessageType . GetOperationModeResponse ) ) ; GetOperationModeReponseData systemMode = GetOperationModeReponseData . parseFrom ( getSysNamespaceResponse . getData ( ) ) ; assertThat ( systemMode . getMode ( ) , is ( OperationMode . OPERATIONAL_MODE ) ) ; request = SetOperationModeRequestData . newBuilder ( ) . setMode ( OperationMode . TEST_MODE ) . build ( ) ; baseNamespaceMsg = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . SetOperationModeRequest ) . setData ( request . toByteString ( ) ) ; thRequest = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . Base , baseNamespaceMsg ) ; thRequest . writeDelimitedTo ( socket . getOutputStream ( ) ) ; }
Verify sending a set operation mode request message changes the operation mode of the controller.
Verify sending a set operation mode request message changes the operation mode of the controller .
// send out message // read in response //replay  // read in response // send out message to reset to test mode