mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestPhysicalLinkNamespace.java
@Test
    public void testIsOpen() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        
        //---Verify physical link is not open---
        // request data see if physical link is open
        IsOpenRequestData requestMessage = IsOpenRequestData.newBuilder()
                .setUuid(testUuid)
                .build();
        
        PhysicalLinkNamespace.Builder pLinkMessage = PhysicalLinkNamespace.newBuilder().
                setType(PhysicalLinkMessageType.IsOpenRequest).
                setData(requestMessage.toByteString());
        
        TerraHarvestMessage message = TerraHarvestMessageHelper.createTerraHarvestMsg(
                Namespace.PhysicalLink, pLinkMessage);
        
        // send out message
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        PhysicalLinkNamespace response = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink,
                PhysicalLinkMessageType.IsOpenResponse, listenerTimeout);

        IsOpenResponseData dataResponse = IsOpenResponseData.parseFrom(response.getData());
        
        assertThat(dataResponse.getIsOpen(), is(false));
        
        //---Create a link layer associated with the physical link---
        SharedMessages.UUID linkUuid = RemoteLinkLayerUtils.createLinkLayer(
              "yarrr", ExampleLinkLayer.class.getName(), testUuid, socket);
        
        //---Activate link layer---
        RemoteLinkLayerUtils.activateLink(linkUuid, socket);
        
        //---Verify physical link was opened---
        // request data see if physical link is open
        requestMessage = IsOpenRequestData.newBuilder()
                .setUuid(testUuid)
                .build();
        
        pLinkMessage = PhysicalLinkNamespace.newBuilder().
                setType(PhysicalLinkMessageType.IsOpenRequest).
                setData(requestMessage.toByteString());
        
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(
                Namespace.PhysicalLink, pLinkMessage);
        
        // send out message
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        response = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink, 
                PhysicalLinkMessageType.IsOpenResponse, listenerTimeout);

        dataResponse = IsOpenResponseData.parseFrom(response.getData());
        
        assertThat(dataResponse.getIsOpen(), is(true));
        
        //---Deactivate the link layer---
        RemoteLinkLayerUtils.deactivateLink(linkUuid, socket);

        //---Remove link layer---
        RemoteLinkLayerUtils.removeLink(linkUuid, socket);

        // verify link layer is gone
        List<UUID> linkLayers = CustomCommsNamespaceUtils.getLayerUuidsByType(socket, CommType.Linklayer);
        assertThat(linkLayers.contains(linkUuid), is(false));
    }
/**
     * Verify the default physical link isOpen property can be received. Create a link layer associated with the 
     * physical link, activate the link layer and verify that the physical link is now open. Deactivate and remove 
     * the link layer.
     */
Verify the default physical link isOpen property can be received. Create a link layer associated with the
physical link, activate the link layer and verify that the physical link is now open. Deactivate and remove
the link layer.
Verify the default physical link isOpen property can be received . Create a link layer associated with the physical link activate the link layer and verify that the physical link is now open . Deactivate and remove the link layer .
@Test
    public void testIsOpen() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        IsOpenRequestData requestMessage = IsOpenRequestData.newBuilder()
                .setUuid(testUuid)
                .build();
        PhysicalLinkNamespace.Builder pLinkMessage = PhysicalLinkNamespace.newBuilder().
                setType(PhysicalLinkMessageType.IsOpenRequest).
                setData(requestMessage.toByteString());
        TerraHarvestMessage message = TerraHarvestMessageHelper.createTerraHarvestMsg(
                Namespace.PhysicalLink, pLinkMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        PhysicalLinkNamespace response = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink,
                PhysicalLinkMessageType.IsOpenResponse, listenerTimeout);
        IsOpenResponseData dataResponse = IsOpenResponseData.parseFrom(response.getData());
        assertThat(dataResponse.getIsOpen(), is(false));
        SharedMessages.UUID linkUuid = RemoteLinkLayerUtils.createLinkLayer(
              "yarrr", ExampleLinkLayer.class.getName(), testUuid, socket);
        RemoteLinkLayerUtils.activateLink(linkUuid, socket);
        requestMessage = IsOpenRequestData.newBuilder()
                .setUuid(testUuid)
                .build();
        pLinkMessage = PhysicalLinkNamespace.newBuilder().
                setType(PhysicalLinkMessageType.IsOpenRequest).
                setData(requestMessage.toByteString());
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(
                Namespace.PhysicalLink, pLinkMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        response = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink, 
                PhysicalLinkMessageType.IsOpenResponse, listenerTimeout);
        dataResponse = IsOpenResponseData.parseFrom(response.getData());
        assertThat(dataResponse.getIsOpen(), is(true));
        RemoteLinkLayerUtils.deactivateLink(linkUuid, socket);
        RemoteLinkLayerUtils.removeLink(linkUuid, socket);
        List<UUID> linkLayers = CustomCommsNamespaceUtils.getLayerUuidsByType(socket, CommType.Linklayer);
        assertThat(linkLayers.contains(linkUuid), is(false));
    }
@ Test public void testIsOpen ( ) throws IOException , InterruptedException { MessageListener listener = new MessageListener ( socket ) ; IsOpenRequestData requestMessage = IsOpenRequestData . newBuilder ( ) . setUuid ( testUuid ) . build ( ) ; PhysicalLinkNamespace . Builder pLinkMessage = PhysicalLinkNamespace . newBuilder ( ) . setType ( PhysicalLinkMessageType . IsOpenRequest ) . setData ( requestMessage . toByteString ( ) ) ; TerraHarvestMessage message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . PhysicalLink , pLinkMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; PhysicalLinkNamespace response = ( PhysicalLinkNamespace ) listener . waitForMessage ( Namespace . PhysicalLink , PhysicalLinkMessageType . IsOpenResponse , listenerTimeout ) ; IsOpenResponseData dataResponse = IsOpenResponseData . parseFrom ( response . getData ( ) ) ; assertThat ( dataResponse . getIsOpen ( ) , is ( false ) ) ; SharedMessages . UUID linkUuid = RemoteLinkLayerUtils . createLinkLayer ( "yarrr" , ExampleLinkLayer . class . getName ( ) , testUuid , socket ) ; RemoteLinkLayerUtils . activateLink ( linkUuid , socket ) ; requestMessage = IsOpenRequestData . newBuilder ( ) . setUuid ( testUuid ) . build ( ) ; pLinkMessage = PhysicalLinkNamespace . newBuilder ( ) . setType ( PhysicalLinkMessageType . IsOpenRequest ) . setData ( requestMessage . toByteString ( ) ) ; message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . PhysicalLink , pLinkMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; response = ( PhysicalLinkNamespace ) listener . waitForMessage ( Namespace . PhysicalLink , PhysicalLinkMessageType . IsOpenResponse , listenerTimeout ) ; dataResponse = IsOpenResponseData . parseFrom ( response . getData ( ) ) ; assertThat ( dataResponse . getIsOpen ( ) , is ( true ) ) ; RemoteLinkLayerUtils . deactivateLink ( linkUuid , socket ) ; RemoteLinkLayerUtils . removeLink ( linkUuid , socket ) ; List < UUID > linkLayers = CustomCommsNamespaceUtils . getLayerUuidsByType ( socket , CommType . Linklayer ) ; assertThat ( linkLayers . contains ( linkUuid ) , is ( false ) ) ; }
Verify the default physical link isOpen property can be received.
Verify the default physical link isOpen property can be received .
//---Verify physical link is not open--- // request data see if physical link is open // send out message // listen for messages for a specific time interval //---Create a link layer associated with the physical link--- //---Activate link layer--- //---Verify physical link was opened--- // request data see if physical link is open // send out message // listen for messages for a specific time interval //---Deactivate the link layer--- //---Remove link layer--- // verify link layer is gone