mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestTransportLayerNamespace.java
@Test
    public void testShutdown() throws IOException, InterruptedException
    {
        //---Activate the link layer associated with the transport layer---
        MessageListener listener = new MessageListener(socket);
        
        //register for event so that the test does not move forward before activation is complete
        RemoteEventRegistration.regRemoteEventMessages(socket, LinkLayer.TOPIC_ACTIVATED);
        
        // construct new link layer message type
        ActivateRequestData activateRequest = ActivateRequestData.newBuilder().
                setUuid(linkUuid).
                build();
        
        LinkLayerNamespace.Builder linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.ActivateRequest).
                setData(activateRequest.toByteString());
        
        TerraHarvestMessage message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        listener.waitForMessages(3000,
                new BasicMessageMatcher(Namespace.LinkLayer, LinkLayerMessageType.ActivateResponse),
                new BasicMessageMatcher(Namespace.EventAdmin, EventAdminMessageType.SendEvent));
        
        MessageListener.unregisterEvent(socket);
        
        //---Verify the link layer was activated---
        // construct new link layer message type
        IsActivatedRequestData isActivatedRequest = IsActivatedRequestData.newBuilder().
                setUuid(linkUuid).
                build();
        
        linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsActivatedRequest).
                setData(isActivatedRequest.toByteString());
        
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        Message responseRcvd = listener.waitForMessage(Namespace.LinkLayer,
                LinkLayerMessageType.IsActivatedResponse, listenerTimeout);
        LinkLayerNamespace response = (LinkLayerNamespace)responseRcvd;
        IsActivatedResponseData dataResponse = IsActivatedResponseData.parseFrom(response.getData());
        
        assertThat(dataResponse.getIsActivated(), is(true));
        
        //register to listen for when the link layer deactivates
        RemoteEventRegistration.regRemoteEventMessages(socket, LinkLayer.TOPIC_DEACTIVATED);
        
        //---Shutdown the transport layer---
        ShutdownRequestData shutdownRequest = ShutdownRequestData.newBuilder().
                setUuid(transportUuid).
                build();
        
        TransportLayerNamespace.Builder transportLayerMessage = TransportLayerNamespace.newBuilder().
                setType(TransportLayerMessageType.ShutdownRequest).
                setData(shutdownRequest.toByteString());
        
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.TransportLayer, 
                transportLayerMessage);
        
        // send out message
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        listener.waitForMessages(3000,
                new BasicMessageMatcher(Namespace.TransportLayer, TransportLayerMessageType.ShutdownResponse),
                new BasicMessageMatcher(Namespace.EventAdmin, EventAdminMessageType.SendEvent));
        
        //---Verify that the link layer associated with the transport layer is deactivated---
        isActivatedRequest = IsActivatedRequestData.newBuilder().
                setUuid(linkUuid).
                build();
        
        linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsActivatedRequest).
                setData(isActivatedRequest.toByteString());
        
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        
        message.writeDelimitedTo(socket.getOutputStream());

        responseRcvd = listener.waitForMessage(Namespace.LinkLayer,
                LinkLayerMessageType.IsActivatedResponse, listenerTimeout);
        response = (LinkLayerNamespace)responseRcvd;
        dataResponse = IsActivatedResponseData.parseFrom(response.getData());
        
        assertThat(dataResponse.getIsActivated(), is(false));
    }
/**
     * Assuming a transport layer was created in setup with an associated link layer, verify that the transport layer 
     * can be successfully shutdown. This means activating the link layer and calling the shutdown method on the 
     * transport layer and verifying that the link layer was deactivated.
     */
Assuming a transport layer was created in setup with an associated link layer, verify that the transport layer
can be successfully shutdown. This means activating the link layer and calling the shutdown method on the
transport layer and verifying that the link layer was deactivated.
Assuming a transport layer was created in setup with an associated link layer verify that the transport layer can be successfully shutdown . This means activating the link layer and calling the shutdown method on the transport layer and verifying that the link layer was deactivated .
@Test
    public void testShutdown() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        RemoteEventRegistration.regRemoteEventMessages(socket, LinkLayer.TOPIC_ACTIVATED);
        ActivateRequestData activateRequest = ActivateRequestData.newBuilder().
                setUuid(linkUuid).
                build();
        LinkLayerNamespace.Builder linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.ActivateRequest).
                setData(activateRequest.toByteString());
        TerraHarvestMessage message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        listener.waitForMessages(3000,
                new BasicMessageMatcher(Namespace.LinkLayer, LinkLayerMessageType.ActivateResponse),
                new BasicMessageMatcher(Namespace.EventAdmin, EventAdminMessageType.SendEvent));
        MessageListener.unregisterEvent(socket);
        IsActivatedRequestData isActivatedRequest = IsActivatedRequestData.newBuilder().
                setUuid(linkUuid).
                build();
        linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsActivatedRequest).
                setData(isActivatedRequest.toByteString());
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        Message responseRcvd = listener.waitForMessage(Namespace.LinkLayer,
                LinkLayerMessageType.IsActivatedResponse, listenerTimeout);
        LinkLayerNamespace response = (LinkLayerNamespace)responseRcvd;
        IsActivatedResponseData dataResponse = IsActivatedResponseData.parseFrom(response.getData());
        assertThat(dataResponse.getIsActivated(), is(true));
        RemoteEventRegistration.regRemoteEventMessages(socket, LinkLayer.TOPIC_DEACTIVATED);
        ShutdownRequestData shutdownRequest = ShutdownRequestData.newBuilder().
                setUuid(transportUuid).
                build();
        TransportLayerNamespace.Builder transportLayerMessage = TransportLayerNamespace.newBuilder().
                setType(TransportLayerMessageType.ShutdownRequest).
                setData(shutdownRequest.toByteString());
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.TransportLayer, 
                transportLayerMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        listener.waitForMessages(3000,
                new BasicMessageMatcher(Namespace.TransportLayer, TransportLayerMessageType.ShutdownResponse),
                new BasicMessageMatcher(Namespace.EventAdmin, EventAdminMessageType.SendEvent));
        isActivatedRequest = IsActivatedRequestData.newBuilder().
                setUuid(linkUuid).
                build();
        linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsActivatedRequest).
                setData(isActivatedRequest.toByteString());
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        responseRcvd = listener.waitForMessage(Namespace.LinkLayer,
                LinkLayerMessageType.IsActivatedResponse, listenerTimeout);
        response = (LinkLayerNamespace)responseRcvd;
        dataResponse = IsActivatedResponseData.parseFrom(response.getData());
        assertThat(dataResponse.getIsActivated(), is(false));
    }
@ Test public void testShutdown ( ) throws IOException , InterruptedException { MessageListener listener = new MessageListener ( socket ) ; RemoteEventRegistration . regRemoteEventMessages ( socket , LinkLayer . TOPIC_ACTIVATED ) ; ActivateRequestData activateRequest = ActivateRequestData . newBuilder ( ) . setUuid ( linkUuid ) . build ( ) ; LinkLayerNamespace . Builder linkLayerMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . ActivateRequest ) . setData ( activateRequest . toByteString ( ) ) ; TerraHarvestMessage message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . LinkLayer , linkLayerMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; listener . waitForMessages ( 3000 , new BasicMessageMatcher ( Namespace . LinkLayer , LinkLayerMessageType . ActivateResponse ) , new BasicMessageMatcher ( Namespace . EventAdmin , EventAdminMessageType . SendEvent ) ) ; MessageListener . unregisterEvent ( socket ) ; IsActivatedRequestData isActivatedRequest = IsActivatedRequestData . newBuilder ( ) . setUuid ( linkUuid ) . build ( ) ; linkLayerMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . IsActivatedRequest ) . setData ( isActivatedRequest . toByteString ( ) ) ; message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . LinkLayer , linkLayerMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; Message responseRcvd = listener . waitForMessage ( Namespace . LinkLayer , LinkLayerMessageType . IsActivatedResponse , listenerTimeout ) ; LinkLayerNamespace response = ( LinkLayerNamespace ) responseRcvd ; IsActivatedResponseData dataResponse = IsActivatedResponseData . parseFrom ( response . getData ( ) ) ; assertThat ( dataResponse . getIsActivated ( ) , is ( true ) ) ; RemoteEventRegistration . regRemoteEventMessages ( socket , LinkLayer . TOPIC_DEACTIVATED ) ; ShutdownRequestData shutdownRequest = ShutdownRequestData . newBuilder ( ) . setUuid ( transportUuid ) . build ( ) ; TransportLayerNamespace . Builder transportLayerMessage = TransportLayerNamespace . newBuilder ( ) . setType ( TransportLayerMessageType . ShutdownRequest ) . setData ( shutdownRequest . toByteString ( ) ) ; message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . TransportLayer , transportLayerMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; listener . waitForMessages ( 3000 , new BasicMessageMatcher ( Namespace . TransportLayer , TransportLayerMessageType . ShutdownResponse ) , new BasicMessageMatcher ( Namespace . EventAdmin , EventAdminMessageType . SendEvent ) ) ; isActivatedRequest = IsActivatedRequestData . newBuilder ( ) . setUuid ( linkUuid ) . build ( ) ; linkLayerMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . IsActivatedRequest ) . setData ( isActivatedRequest . toByteString ( ) ) ; message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . LinkLayer , linkLayerMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; responseRcvd = listener . waitForMessage ( Namespace . LinkLayer , LinkLayerMessageType . IsActivatedResponse , listenerTimeout ) ; response = ( LinkLayerNamespace ) responseRcvd ; dataResponse = IsActivatedResponseData . parseFrom ( response . getData ( ) ) ; assertThat ( dataResponse . getIsActivated ( ) , is ( false ) ) ; }
Assuming a transport layer was created in setup with an associated link layer, verify that the transport layer
 can be successfully shutdown.
Assuming a transport layer was created in setup with an associated link layer verify that the transport layer can be successfully shutdown .
//---Activate the link layer associated with the transport layer--- //register for event so that the test does not move forward before activation is complete // construct new link layer message type // listen for messages for a specific time interval //---Verify the link layer was activated--- // construct new link layer message type // listen for messages for a specific time interval //register to listen for when the link layer deactivates //---Shutdown the transport layer--- // send out message // listen for messages for a specific time interval //---Verify that the link layer associated with the transport layer is deactivated---