mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestPhysicalLinkNamespace.java
@Test
    public void testIsPhysicalLinkInUse() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);

        // request data to see if a physical link is in use
        IsInUseRequestData requestMessage = IsInUseRequestData.newBuilder().
                setPhysicalLinkUuid(testUuid).
                build();
        
        // create terra harvest message
        TerraHarvestMessage message = createPhysicalLinkMessage(PhysicalLinkMessageType.IsInUseRequest,
                requestMessage);
        
        // send out message
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        PhysicalLinkNamespace isInUseResponse = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink,
                PhysicalLinkMessageType.IsInUseResponse, 600);
        IsInUseResponseData dataResponse = IsInUseResponseData.parseFrom(
                isInUseResponse.getData());
        
        assertThat(dataResponse.getIsInUse(), is(false));
        
        //---Create a new link layer and verify physical link becomes in use---
        // request data to create a new link layer
        SharedMessages.UUID localLinkLayerUuid = RemoteLinkLayerUtils.createLinkLayer(
            "water", ExampleLinkLayer.class.getName(), testUuid, socket);
        
        //---Verify the physical link is now in use---
        // request data to see if a physical link is in use
        requestMessage = IsInUseRequestData.newBuilder().
                setPhysicalLinkUuid(testUuid).
                build();
        
        // create terra harvest message
        message = createPhysicalLinkMessage(PhysicalLinkMessageType.IsInUseRequest, 
                requestMessage);
        
        // send out message
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        isInUseResponse = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink, 
                PhysicalLinkMessageType.IsInUseResponse, 600);
        dataResponse = IsInUseResponseData.parseFrom(isInUseResponse.getData());
        
        assertThat(dataResponse.getIsInUse(), is(true));
        
        //---Remove newly created link layer and physical link---
        // request data to remove the newly created link layer
        RemoteLinkLayerUtils.removeLink(localLinkLayerUuid, socket);
        
        // verify newly created link layer is gone
        List<SharedMessages.UUID> uuidList = CustomCommsNamespaceUtils.getLayerUuidsByType(socket, CommType.Linklayer);
        assertThat(uuidList.contains(localLinkLayerUuid), is(false));
    }
/**
     * Verify that the system can remotely see if a physical link is in use or not. Creating a new physical link, then
     * verifying that it is not in use, then we create a link layer that is associated with the physical link, then 
     * verify that the physical link is now in use.. then remove both newly created layers.
     */
Verify that the system can remotely see if a physical link is in use or not. Creating a new physical link, then
verifying that it is not in use, then we create a link layer that is associated with the physical link, then
verify that the physical link is now in use.. then remove both newly created layers.
Verify that the system can remotely see if a physical link is in use or not . Creating a new physical link then verifying that it is not in use then we create a link layer that is associated with the physical link then verify that the physical link is now in use .. then remove both newly created layers .
@Test
    public void testIsPhysicalLinkInUse() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        IsInUseRequestData requestMessage = IsInUseRequestData.newBuilder().
                setPhysicalLinkUuid(testUuid).
                build();
        TerraHarvestMessage message = createPhysicalLinkMessage(PhysicalLinkMessageType.IsInUseRequest,
                requestMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        PhysicalLinkNamespace isInUseResponse = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink,
                PhysicalLinkMessageType.IsInUseResponse, 600);
        IsInUseResponseData dataResponse = IsInUseResponseData.parseFrom(
                isInUseResponse.getData());
        assertThat(dataResponse.getIsInUse(), is(false));
        SharedMessages.UUID localLinkLayerUuid = RemoteLinkLayerUtils.createLinkLayer(
            "water", ExampleLinkLayer.class.getName(), testUuid, socket);
        requestMessage = IsInUseRequestData.newBuilder().
                setPhysicalLinkUuid(testUuid).
                build();
        message = createPhysicalLinkMessage(PhysicalLinkMessageType.IsInUseRequest, 
                requestMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        isInUseResponse = (PhysicalLinkNamespace)listener.waitForMessage(Namespace.PhysicalLink, 
                PhysicalLinkMessageType.IsInUseResponse, 600);
        dataResponse = IsInUseResponseData.parseFrom(isInUseResponse.getData());
        assertThat(dataResponse.getIsInUse(), is(true));
        RemoteLinkLayerUtils.removeLink(localLinkLayerUuid, socket);
        List<SharedMessages.UUID> uuidList = CustomCommsNamespaceUtils.getLayerUuidsByType(socket, CommType.Linklayer);
        assertThat(uuidList.contains(localLinkLayerUuid), is(false));
    }
@ Test public void testIsPhysicalLinkInUse ( ) throws IOException , InterruptedException { MessageListener listener = new MessageListener ( socket ) ; IsInUseRequestData requestMessage = IsInUseRequestData . newBuilder ( ) . setPhysicalLinkUuid ( testUuid ) . build ( ) ; TerraHarvestMessage message = createPhysicalLinkMessage ( PhysicalLinkMessageType . IsInUseRequest , requestMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; PhysicalLinkNamespace isInUseResponse = ( PhysicalLinkNamespace ) listener . waitForMessage ( Namespace . PhysicalLink , PhysicalLinkMessageType . IsInUseResponse , 600 ) ; IsInUseResponseData dataResponse = IsInUseResponseData . parseFrom ( isInUseResponse . getData ( ) ) ; assertThat ( dataResponse . getIsInUse ( ) , is ( false ) ) ; SharedMessages . UUID localLinkLayerUuid = RemoteLinkLayerUtils . createLinkLayer ( "water" , ExampleLinkLayer . class . getName ( ) , testUuid , socket ) ; requestMessage = IsInUseRequestData . newBuilder ( ) . setPhysicalLinkUuid ( testUuid ) . build ( ) ; message = createPhysicalLinkMessage ( PhysicalLinkMessageType . IsInUseRequest , requestMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; isInUseResponse = ( PhysicalLinkNamespace ) listener . waitForMessage ( Namespace . PhysicalLink , PhysicalLinkMessageType . IsInUseResponse , 600 ) ; dataResponse = IsInUseResponseData . parseFrom ( isInUseResponse . getData ( ) ) ; assertThat ( dataResponse . getIsInUse ( ) , is ( true ) ) ; RemoteLinkLayerUtils . removeLink ( localLinkLayerUuid , socket ) ; List < SharedMessages . UUID > uuidList = CustomCommsNamespaceUtils . getLayerUuidsByType ( socket , CommType . Linklayer ) ; assertThat ( uuidList . contains ( localLinkLayerUuid ) , is ( false ) ) ; }
Verify that the system can remotely see if a physical link is in use or not.
Verify that the system can remotely see if a physical link is in use or not .
// request data to see if a physical link is in use // create terra harvest message // send out message // listen for messages for a specific time interval //---Create a new link layer and verify physical link becomes in use--- // request data to create a new link layer //---Verify the physical link is now in use--- // request data to see if a physical link is in use // create terra harvest message // send out message // listen for messages for a specific time interval //---Remove newly created link layer and physical link--- // request data to remove the newly created link layer // verify newly created link layer is gone